enhance(backend): バックエンドで言語リストのみを参照するように (#16915)

This commit is contained in:
かっこかり 2025-12-01 18:51:36 +09:00 committed by GitHub
parent 483483bc44
commit 7b9e83a6b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 47 additions and 38 deletions

View File

@ -6,7 +6,7 @@
import { dirname } from 'node:path'; import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url'; import { fileURLToPath } from 'node:url';
import { promises as fsp } from 'node:fs'; import { promises as fsp } from 'node:fs';
import { languages } from 'i18n'; import { languages } from 'i18n/const';
import { Injectable, Inject } from '@nestjs/common'; import { Injectable, Inject } from '@nestjs/common';
import { DI } from '@/di-symbols.js'; import { DI } from '@/di-symbols.js';
import { bindThis } from '@/decorators.js'; import { bindThis } from '@/decorators.js';

View File

@ -8,6 +8,10 @@
".": { ".": {
"types": "./built/index.d.ts", "types": "./built/index.d.ts",
"import": "./built/index.js" "import": "./built/index.js"
},
"./const": {
"types": "./built/const.d.ts",
"import": "./built/const.js"
} }
}, },
"scripts": { "scripts": {

View File

@ -0,0 +1,41 @@
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
export const languages = [
'ar-SA',
'ca-ES',
'cs-CZ',
'da-DK',
'de-DE',
'en-US',
'es-ES',
'fr-FR',
'id-ID',
'it-IT',
'ja-JP',
'ja-KS',
'kab-KAB',
'kn-IN',
'ko-KR',
'nl-NL',
'no-NO',
'pl-PL',
'pt-PT',
'ru-RU',
'sk-SK',
'th-TH',
'tr-TR',
'ug-CN',
'uk-UA',
'vi-VN',
'zh-CN',
'zh-TW',
] as const;
export const primaries = {
'en': 'US',
'ja': 'JP',
'zh': 'CN',
} as const satisfies Record<string, string>;

View File

@ -9,48 +9,12 @@
import * as fs from 'node:fs'; import * as fs from 'node:fs';
import * as yaml from 'js-yaml'; import * as yaml from 'js-yaml';
import { languages, primaries } from './const.js';
import type { Locale } from './autogen/locale.js'; import type { Locale } from './autogen/locale.js';
import type { ILocale, ParameterizedString } from './types.js'; import type { ILocale, ParameterizedString } from './types.js';
const languages = [
'ar-SA',
'ca-ES',
'cs-CZ',
'da-DK',
'de-DE',
'en-US',
'es-ES',
'fr-FR',
'id-ID',
'it-IT',
'ja-JP',
'ja-KS',
'kab-KAB',
'kn-IN',
'ko-KR',
'nl-NL',
'no-NO',
'pl-PL',
'pt-PT',
'ru-RU',
'sk-SK',
'th-TH',
'tr-TR',
'ug-CN',
'uk-UA',
'vi-VN',
'zh-CN',
'zh-TW',
] as const;
type Language = typeof languages[number]; type Language = typeof languages[number];
const primaries = {
'en': 'US',
'ja': 'JP',
'zh': 'CN',
} as const satisfies Record<string, string>;
type PrimaryLang = keyof typeof primaries; type PrimaryLang = keyof typeof primaries;
type Locales = Record<Language, ILocale>; type Locales = Record<Language, ILocale>;