Added Japanese

pull/645/head
Lugiad 2024-05-11 01:35:58 +02:00 committed by GitHub
parent 94683a4dbf
commit 21be1547c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 114 additions and 110 deletions

View File

@ -1,110 +1,114 @@
import i18next from 'i18next'; import i18next from 'i18next';
import LanguageDetector from 'i18next-browser-languagedetector'; import LanguageDetector from 'i18next-browser-languagedetector';
import { deConfig } from '#app/locales/de/config.js'; import { deConfig } from '#app/locales/de/config.js';
import { enConfig } from '#app/locales/en/config.js'; import { enConfig } from '#app/locales/en/config.js';
import { esConfig } from '#app/locales/es/config.js'; import { esConfig } from '#app/locales/es/config.js';
import { frConfig } from '#app/locales/fr/config.js'; import { frConfig } from '#app/locales/fr/config.js';
import { itConfig } from '#app/locales/it/config.js'; import { itConfig } from '#app/locales/it/config.js';
import { zhCnConfig } from '#app/locales/zh_CN/config.js'; import { zhCnConfig } from '#app/locales/zh_CN/config.js';
import { jpConfig } from '#app/locales/jp/config.js';
export interface SimpleTranslationEntries {
[key: string]: string export interface SimpleTranslationEntries {
} [key: string]: string
}
export interface MoveTranslationEntry {
name: string, export interface MoveTranslationEntry {
effect: string name: string,
} effect: string
}
export interface MoveTranslationEntries {
[key: string]: MoveTranslationEntry export interface MoveTranslationEntries {
} [key: string]: MoveTranslationEntry
}
export interface AbilityTranslationEntry {
name: string, export interface AbilityTranslationEntry {
description: string name: string,
} description: string
}
export interface AbilityTranslationEntries {
[key: string]: AbilityTranslationEntry export interface AbilityTranslationEntries {
} [key: string]: AbilityTranslationEntry
}
export interface Localizable {
localize(): void; export interface Localizable {
} localize(): void;
}
export function initI18n(): void {
let lang = ''; export function initI18n(): void {
let lang = '';
if (localStorage.getItem('prLang'))
lang = localStorage.getItem('prLang'); if (localStorage.getItem('prLang'))
lang = localStorage.getItem('prLang');
/**
* i18next is a localization library for maintaining and using translation resources. /**
* * i18next is a localization library for maintaining and using translation resources.
* Q: How do I add a new language? *
* A: To add a new language, create a new folder in the locales directory with the language code. * Q: How do I add a new language?
* Each language folder should contain a file for each namespace (ex. menu.ts) with the translations. * A: To add a new language, create a new folder in the locales directory with the language code.
* Don't forget to declare new language in `supportedLngs` i18next initializer * Each language folder should contain a file for each namespace (ex. menu.ts) with the translations.
* * Don't forget to declare new language in `supportedLngs` i18next initializer
* Q: How do I add a new namespace? *
* A: To add a new namespace, create a new file in each language folder with the translations. * Q: How do I add a new namespace?
* Then update the `resources` field in the init() call and the CustomTypeOptions interface. * A: To add a new namespace, create a new file in each language folder with the translations.
* * Then update the `resources` field in the init() call and the CustomTypeOptions interface.
* Q: How do I make a language selectable in the settings? *
* A: In src/system/settings.ts, add a new case to the Setting.Language switch statement. * Q: How do I make a language selectable in the settings?
*/ * A: In src/system/settings.ts, add a new case to the Setting.Language switch statement.
*/
i18next.use(LanguageDetector).init({
lng: lang, i18next.use(LanguageDetector).init({
fallbackLng: 'en', lng: lang,
supportedLngs: ['en', 'es', 'fr', 'it', 'de', 'zh_CN'], fallbackLng: 'en',
debug: true, supportedLngs: ['en', 'es', 'fr', 'it', 'de', 'zh_CN', 'jp'],
interpolation: { debug: true,
escapeValue: false, interpolation: {
}, escapeValue: false,
resources: { },
en: { resources: {
...enConfig en: {
}, ...enConfig
es: { },
...esConfig es: {
}, ...esConfig
fr: { },
...frConfig fr: {
}, ...frConfig
it: { },
...itConfig it: {
}, ...itConfig
de: { },
...deConfig de: {
}, ...deConfig
zh_CN: { },
...zhCnConfig zh_CN: {
} ...zhCnConfig
}, },
}); jp: {
} ...jpConfig
}
// Module declared to make referencing keys in the localization files type-safe. },
declare module 'i18next' { });
interface CustomTypeOptions { }
resources: {
menu: SimpleTranslationEntries; // Module declared to make referencing keys in the localization files type-safe.
menuUiHandler: SimpleTranslationEntries; declare module 'i18next' {
move: MoveTranslationEntries; interface CustomTypeOptions {
battle: SimpleTranslationEntries, resources: {
ability: AbilityTranslationEntries; menu: SimpleTranslationEntries;
pokeball: SimpleTranslationEntries; menuUiHandler: SimpleTranslationEntries;
pokemon: SimpleTranslationEntries; move: MoveTranslationEntries;
pokemonStat: SimpleTranslationEntries; battle: SimpleTranslationEntries,
commandUiHandler: SimpleTranslationEntries; ability: AbilityTranslationEntries;
fightUiHandler: SimpleTranslationEntries; pokeball: SimpleTranslationEntries;
tutorial: SimpleTranslationEntries; pokemon: SimpleTranslationEntries;
starterSelectUiHandler: SimpleTranslationEntries; pokemonStat: SimpleTranslationEntries;
}; commandUiHandler: SimpleTranslationEntries;
} fightUiHandler: SimpleTranslationEntries;
} tutorial: SimpleTranslationEntries;
starterSelectUiHandler: SimpleTranslationEntries;
export default i18next; };
}
}
export default i18next;