mirror of
https://iceshrimp.dev/Crimekillz/jointrashposs.git
synced 2024-11-22 08:53:49 +01:00
parent
ea7d492b7e
commit
4cc0ace0e3
17
assets/data/locales.ts
Normal file
17
assets/data/locales.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import type { LocaleObject } from '@nuxtjs/i18n/dist/runtime/composables';
|
||||||
|
|
||||||
|
export const localesConst = [
|
||||||
|
{ files: [ 'ja-JP.json' ], code: 'ja', iso: 'ja-JP', name: '日本語' },
|
||||||
|
{ files: [ 'en-US.json' ], code: 'en', iso: 'en-US', name: 'English' },
|
||||||
|
{ files: [ 'id-ID.json' ], code: 'id', iso: 'id-ID', name: 'Bahasa Indonesia' },
|
||||||
|
{ files: [ 'ko-KR.json' ], code: 'ko', iso: 'ko-KR', name: '한국어' },
|
||||||
|
{ files: [ 'it-IT.json' ], code: 'it', iso: 'it-IT', name: 'Italiano' },
|
||||||
|
{ files: [ 'pl-PL.json' ], code: 'pl', iso: 'pl-PL', name: 'Polski' },
|
||||||
|
{ files: [ 'fr-FR.json' ], code: 'fr', iso: 'fr-FR', name: 'Français' },
|
||||||
|
{ files: [ 'zh-CN.json' ], code: 'cn', iso: 'zh-CN', name: '简体中文' },
|
||||||
|
{ files: [ 'zh-TW.json' ], code: 'tw', iso: 'zh-TW', name: '繁体中文' },
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
export type LocaleCodes = typeof localesConst[number]['code'];
|
||||||
|
|
||||||
|
export const locales = localesConst as unknown as LocaleObject[];
|
1330
assets/data/old-hub-redirects.ts
Normal file
1330
assets/data/old-hub-redirects.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,10 @@
|
|||||||
# AiScript
|
# AiScript
|
||||||
AiScriptは、Misskeyで使用できるスクリプト言語です。
|
AiScriptは、Misskeyで使用できるスクリプト言語です。
|
||||||
|
|
||||||
::: tip
|
:::tip
|
||||||
|
|
||||||
AiScript実装はMisskeyとは別リポジトリで、[オープンソースで公開されています](https://github.com/syuilo/aiscript)。
|
AiScript実装はMisskeyとは別リポジトリで、[オープンソースで公開されています](https://github.com/syuilo/aiscript)。
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
## 使い方
|
## 使い方
|
@ -3,30 +3,16 @@ import yaml from '@rollup/plugin-yaml';
|
|||||||
import svgLoader from 'vite-svg-loader';
|
import svgLoader from 'vite-svg-loader';
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import { genApiTranslationFiles } from './scripts/gen-api-translations';
|
import { genApiTranslationFiles } from './scripts/gen-api-translations';
|
||||||
import type { LocaleObject } from '@nuxtjs/i18n/dist/runtime/composables';
|
import { getOldHubRedirects } from './scripts/get-old-hub-redirects';
|
||||||
import { genLocalesJson } from './scripts/gen-locales';
|
import { genLocalesJson } from './scripts/gen-locales';
|
||||||
import { getStaticEndpoints } from './scripts/get-static-endpoints';
|
import { getStaticEndpoints } from './scripts/get-static-endpoints';
|
||||||
|
import { locales } from './assets/data/locales';
|
||||||
import type { NuxtConfig } from 'nuxt/schema';
|
import type { NuxtConfig } from 'nuxt/schema';
|
||||||
|
|
||||||
// 公開時のドメイン(末尾スラッシュなし)
|
// 公開時のドメイン(末尾スラッシュなし)
|
||||||
const baseUrl = 'https://misskey-hub-next.vercel.app';
|
const baseUrl = 'https://misskey-hub-next.vercel.app';
|
||||||
|
|
||||||
// 言語定義
|
// 言語定義は /assets/data/locales.ts に移動しました
|
||||||
export const localesConst = [
|
|
||||||
{ files: [ 'ja-JP.json' ], code: 'ja', iso: 'ja-JP', name: '日本語' },
|
|
||||||
{ files: [ 'en-US.json' ], code: 'en', iso: 'en-US', name: 'English' },
|
|
||||||
{ files: [ 'id-ID.json' ], code: 'id', iso: 'id-ID', name: 'Bahasa Indonesia' },
|
|
||||||
{ files: [ 'ko-KR.json' ], code: 'ko', iso: 'ko-KR', name: '한국어' },
|
|
||||||
{ files: [ 'it-IT.json' ], code: 'it', iso: 'it-IT', name: 'Italiano' },
|
|
||||||
{ files: [ 'pl-PL.json' ], code: 'pl', iso: 'pl-PL', name: 'Polski' },
|
|
||||||
{ files: [ 'fr-FR.json' ], code: 'fr', iso: 'fr-FR', name: 'Français' },
|
|
||||||
{ files: [ 'zh-CN.json' ], code: 'cn', iso: 'zh-CN', name: '简体中文' },
|
|
||||||
{ files: [ 'zh-TW.json' ], code: 'tw', iso: 'zh-TW', name: '繁体中文' },
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
export type LocaleCodes = typeof localesConst[number]['code'];
|
|
||||||
|
|
||||||
export const locales = localesConst as unknown as LocaleObject[];
|
|
||||||
|
|
||||||
function getRouteRules(): NuxtConfig['routeRules'] {
|
function getRouteRules(): NuxtConfig['routeRules'] {
|
||||||
// 言語ごとに割り当てる必要のないRouteRules
|
// 言語ごとに割り当てる必要のないRouteRules
|
||||||
@ -63,6 +49,7 @@ function getRouteRules(): NuxtConfig['routeRules'] {
|
|||||||
return {
|
return {
|
||||||
...staticRules,
|
...staticRules,
|
||||||
..._localeBasedRules,
|
..._localeBasedRules,
|
||||||
|
...getOldHubRedirects(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
44
scripts/get-old-hub-redirects.ts
Normal file
44
scripts/get-old-hub-redirects.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import { redirects } from './../assets/data/old-hub-redirects';
|
||||||
|
import { localesConst } from './../assets/data/locales';
|
||||||
|
import type { LocaleCodes } from './../assets/data/locales';
|
||||||
|
import type { NuxtConfig } from 'nuxt/schema';
|
||||||
|
import { joinURL } from 'ufo';
|
||||||
|
|
||||||
|
export function getOldHubRedirects(): NuxtConfig['routeRules'] {
|
||||||
|
|
||||||
|
// 旧Hub時代の各言語のプレフィックス
|
||||||
|
const hubLocales: Record<LocaleCodes, string> = {
|
||||||
|
ja: '/',
|
||||||
|
en: '/en',
|
||||||
|
id: '/id',
|
||||||
|
ko: '/ko',
|
||||||
|
it: '/it',
|
||||||
|
pl: '/pl',
|
||||||
|
fr: '/fr',
|
||||||
|
cn: '/zh-CN',
|
||||||
|
tw: '/zh-TW',
|
||||||
|
};
|
||||||
|
|
||||||
|
const out: NuxtConfig['routeRules'] = {};
|
||||||
|
|
||||||
|
localesConst.forEach((locale) => {
|
||||||
|
redirects.forEach((route) => {
|
||||||
|
if (route[0].startsWith('/ns')) return;
|
||||||
|
|
||||||
|
let destination = route[1];
|
||||||
|
|
||||||
|
if (route[0].endsWith('.html') && !new RegExp(`^/(${localesConst.map((e) => e.code).join('|')})/`, 'g').test(destination)) {
|
||||||
|
destination = joinURL(`/${locale.code}`, destination);
|
||||||
|
}
|
||||||
|
|
||||||
|
out[joinURL(hubLocales[locale.code], route[0])] = {
|
||||||
|
redirect: {
|
||||||
|
to: destination,
|
||||||
|
statusCode: 301,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user