2024-04-12 04:47:03 +01:00
|
|
|
import i18next from 'i18next';
|
|
|
|
import { menu as enMenu } from '../locales/en/menu';
|
2024-04-23 16:53:56 +01:00
|
|
|
import { menu as esMenu } from '../locales/es/menu';
|
2024-04-12 04:47:03 +01:00
|
|
|
import { menu as itMenu } from '../locales/it/menu';
|
2024-04-18 11:49:18 +01:00
|
|
|
import { menu as frMenu } from '../locales/fr/menu';
|
2024-04-25 22:24:53 +01:00
|
|
|
import { menu as deMenu } from '../locales/de/menu';
|
2024-04-12 04:47:03 +01:00
|
|
|
|
2024-04-25 18:38:33 +01:00
|
|
|
import { menuUiHandler as enMenuUiHandler } from '../locales/en/menu-ui-handler.js';
|
|
|
|
import { menuUiHandler as esMenuUiHandler } from '../locales/es/menu-ui-handler.js';
|
|
|
|
import { menuUiHandler as frMenuUiHandler } from '../locales/fr/menu-ui-handler.js';
|
|
|
|
import { menuUiHandler as itMenuUiHandler } from '../locales/it/menu-ui-handler.js';
|
2024-04-25 22:24:53 +01:00
|
|
|
import { menuUiHandler as deMenuUiHandler } from '../locales/de/menu-ui-handler.js';
|
2024-04-25 18:38:33 +01:00
|
|
|
|
2024-04-16 19:29:32 +01:00
|
|
|
import { move as enMove } from '../locales/en/move';
|
2024-04-23 16:53:56 +01:00
|
|
|
import { move as esMove } from '../locales/es/move';
|
2024-04-16 19:29:32 +01:00
|
|
|
import { move as frMove } from '../locales/fr/move';
|
|
|
|
|
2024-04-25 02:10:09 +01:00
|
|
|
import { ability as enAbility } from '../locales/en/ability';
|
|
|
|
import { ability as esAbility } from '../locales/es/ability';
|
|
|
|
import { ability as frAbility } from '../locales/fr/ability';
|
|
|
|
|
2024-04-21 11:18:09 +01:00
|
|
|
import { pokeball as enPokeball } from '../locales/en/pokeball';
|
2024-04-23 16:53:56 +01:00
|
|
|
import { pokeball as esPokeball } from '../locales/es/pokeball';
|
2024-04-21 11:18:09 +01:00
|
|
|
import { pokeball as frPokeball } from '../locales/fr/pokeball';
|
2024-04-25 22:24:53 +01:00
|
|
|
import { pokeball as dePokeball } from '../locales/de/pokeball';
|
2024-04-21 11:18:09 +01:00
|
|
|
|
2024-04-22 00:53:24 +01:00
|
|
|
import { pokemon as enPokemon } from '../locales/en/pokemon';
|
2024-04-24 05:36:07 +01:00
|
|
|
import { pokemon as esPokemon } from '../locales/es/pokemon';
|
2024-04-22 00:53:24 +01:00
|
|
|
import { pokemon as frPokemon } from '../locales/fr/pokemon';
|
|
|
|
|
2024-04-24 21:10:03 +01:00
|
|
|
import { pokemonStat as enPokemonStat } from '../locales/en/pokemon-stat';
|
|
|
|
import { pokemonStat as esPokemonStat } from '../locales/es/pokemon-stat';
|
|
|
|
import { pokemonStat as frPokemonStat } from '../locales/fr/pokemon-stat';
|
|
|
|
import { pokemonStat as itPokemonStat } from '../locales/it/pokemon-stat';
|
2024-04-25 22:24:53 +01:00
|
|
|
import { pokemonStat as dePokemonStat } from '../locales/de/pokemon-stat';
|
2024-04-24 21:10:03 +01:00
|
|
|
|
2024-04-24 05:36:07 +01:00
|
|
|
import { commandUiHandler as enCommandUiHandler } from '../locales/en/command-ui-handler';
|
|
|
|
import { commandUiHandler as esCommandUiHandler } from '../locales/es/command-ui-handler';
|
|
|
|
import { commandUiHandler as frCommandUiHandler } from '../locales/fr/command-ui-handler';
|
2024-04-25 22:24:53 +01:00
|
|
|
import { commandUiHandler as deCommandUiHandler } from '../locales/de/command-ui-handler';
|
2024-04-24 05:36:07 +01:00
|
|
|
|
2024-04-25 23:54:56 +01:00
|
|
|
import { fightUiHandler as enFightUiHandler } from '../locales/en/fight-ui-handler';
|
|
|
|
import { fightUiHandler as frFightUiHandler } from '../locales/fr/fight-ui-handler';
|
|
|
|
|
2024-04-22 00:53:24 +01:00
|
|
|
export interface SimpleTranslationEntries {
|
|
|
|
[key: string]: string
|
|
|
|
}
|
|
|
|
|
2024-04-24 05:36:07 +01:00
|
|
|
|
2024-04-18 13:40:42 +01:00
|
|
|
export interface MoveTranslationEntry {
|
|
|
|
name: string,
|
|
|
|
effect: string
|
|
|
|
}
|
|
|
|
|
2024-04-22 00:53:24 +01:00
|
|
|
export interface MoveTranslationEntries {
|
2024-04-18 13:40:42 +01:00
|
|
|
[key: string]: MoveTranslationEntry
|
|
|
|
}
|
|
|
|
|
2024-04-25 02:10:09 +01:00
|
|
|
export interface AbilityTranslationEntry {
|
|
|
|
name: string,
|
|
|
|
description: string
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface AbilityTranslationEntries {
|
|
|
|
[key: string]: AbilityTranslationEntry
|
|
|
|
}
|
|
|
|
|
2024-04-19 19:55:01 +01:00
|
|
|
export interface Localizable {
|
|
|
|
localize(): void;
|
|
|
|
}
|
|
|
|
|
2024-04-12 04:47:03 +01:00
|
|
|
const DEFAULT_LANGUAGE_OVERRIDE = '';
|
|
|
|
|
2024-04-19 19:55:01 +01:00
|
|
|
export function initI18n(): void {
|
|
|
|
let lang = 'en';
|
|
|
|
|
|
|
|
if (localStorage.getItem('prLang'))
|
|
|
|
lang = localStorage.getItem('prLang');
|
2024-04-12 04:47:03 +01:00
|
|
|
|
2024-04-19 19:55:01 +01:00
|
|
|
/**
|
|
|
|
* i18next is a localization library for maintaining and using translation resources.
|
2024-04-25 23:54:56 +01:00
|
|
|
*
|
2024-04-19 19:55:01 +01:00
|
|
|
* 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.
|
|
|
|
* Each language folder should contain a file for each namespace (ex. menu.ts) with the translations.
|
2024-04-25 23:54:56 +01:00
|
|
|
*
|
2024-04-19 19:55:01 +01:00
|
|
|
* 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.
|
|
|
|
* Then update the `resources` field in the init() call and the CustomTypeOptions interface.
|
2024-04-25 22:24:53 +01:00
|
|
|
*
|
|
|
|
* 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.
|
2024-04-19 19:55:01 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
i18next.init({
|
|
|
|
lng: DEFAULT_LANGUAGE_OVERRIDE ? DEFAULT_LANGUAGE_OVERRIDE : lang,
|
|
|
|
fallbackLng: 'en',
|
|
|
|
debug: true,
|
|
|
|
interpolation: {
|
|
|
|
escapeValue: false,
|
2024-04-12 04:47:03 +01:00
|
|
|
},
|
2024-04-19 19:55:01 +01:00
|
|
|
resources: {
|
|
|
|
en: {
|
|
|
|
menu: enMenu,
|
2024-04-25 18:38:33 +01:00
|
|
|
menuUiHandler: enMenuUiHandler,
|
2024-04-19 19:55:01 +01:00
|
|
|
move: enMove,
|
2024-04-25 02:10:09 +01:00
|
|
|
ability: enAbility,
|
2024-04-21 11:18:09 +01:00
|
|
|
pokeball: enPokeball,
|
2024-04-22 00:53:24 +01:00
|
|
|
pokemon: enPokemon,
|
2024-04-24 21:10:03 +01:00
|
|
|
pokemonStat: enPokemonStat,
|
2024-04-24 05:36:07 +01:00
|
|
|
commandUiHandler: enCommandUiHandler,
|
2024-04-25 23:54:56 +01:00
|
|
|
fightUiHandler: enFightUiHandler,
|
2024-04-19 19:55:01 +01:00
|
|
|
},
|
2024-04-23 16:53:56 +01:00
|
|
|
es: {
|
|
|
|
menu: esMenu,
|
2024-04-25 18:38:33 +01:00
|
|
|
menuUiHandler: esMenuUiHandler,
|
2024-04-23 16:53:56 +01:00
|
|
|
move: esMove,
|
2024-04-25 02:10:09 +01:00
|
|
|
ability: esAbility,
|
2024-04-23 16:53:56 +01:00
|
|
|
pokeball: esPokeball,
|
2024-04-24 05:36:07 +01:00
|
|
|
pokemon: esPokemon,
|
2024-04-24 21:10:03 +01:00
|
|
|
pokemonStat: esPokemonStat,
|
2024-04-24 05:36:07 +01:00
|
|
|
commandUiHandler: esCommandUiHandler,
|
2024-04-19 19:55:01 +01:00
|
|
|
},
|
|
|
|
fr: {
|
|
|
|
menu: frMenu,
|
2024-04-25 18:38:33 +01:00
|
|
|
menuUiHandler: frMenuUiHandler,
|
2024-04-19 19:55:01 +01:00
|
|
|
move: frMove,
|
2024-04-25 02:10:09 +01:00
|
|
|
ability: frAbility,
|
2024-04-21 11:18:09 +01:00
|
|
|
pokeball: frPokeball,
|
2024-04-22 00:53:24 +01:00
|
|
|
pokemon: frPokemon,
|
2024-04-24 21:10:03 +01:00
|
|
|
pokemonStat: frPokemonStat,
|
2024-04-24 05:36:07 +01:00
|
|
|
commandUiHandler: frCommandUiHandler,
|
2024-04-25 23:54:56 +01:00
|
|
|
fightUiHandler: frFightUiHandler,
|
2024-04-24 05:36:07 +01:00
|
|
|
},
|
|
|
|
it: {
|
|
|
|
menu: itMenu,
|
2024-04-25 18:38:33 +01:00
|
|
|
menuUiHandler: itMenuUiHandler,
|
2024-04-24 21:10:03 +01:00
|
|
|
pokemonStat: itPokemonStat,
|
2024-04-24 05:36:07 +01:00
|
|
|
},
|
2024-04-25 22:24:53 +01:00
|
|
|
de: {
|
|
|
|
menu: deMenu,
|
|
|
|
menuUiHandler: deMenuUiHandler,
|
|
|
|
pokeball: dePokeball,
|
|
|
|
pokemonStat: dePokemonStat,
|
|
|
|
commandUiHandler: deCommandUiHandler,
|
|
|
|
}
|
2024-04-16 19:29:32 +01:00
|
|
|
},
|
2024-04-19 19:55:01 +01:00
|
|
|
});
|
|
|
|
}
|
2024-04-12 04:47:03 +01:00
|
|
|
|
|
|
|
// Module declared to make referencing keys in the localization files type-safe.
|
|
|
|
declare module 'i18next' {
|
|
|
|
interface CustomTypeOptions {
|
|
|
|
resources: {
|
|
|
|
menu: typeof enMenu;
|
2024-04-25 18:38:33 +01:00
|
|
|
menuUiHandler: typeof enMenuUiHandler;
|
2024-04-16 19:29:32 +01:00
|
|
|
move: typeof enMove;
|
2024-04-25 02:10:09 +01:00
|
|
|
ability: typeof enAbility;
|
2024-04-21 11:18:09 +01:00
|
|
|
pokeball: typeof enPokeball;
|
2024-04-22 00:53:24 +01:00
|
|
|
pokemon: typeof enPokemon;
|
2024-04-24 21:10:03 +01:00
|
|
|
pokemonStat: typeof enPokemonStat;
|
2024-04-24 05:36:07 +01:00
|
|
|
commandUiHandler: typeof enCommandUiHandler;
|
2024-04-25 23:54:56 +01:00
|
|
|
fightUiHandler: typeof enFightUiHandler;
|
2024-04-12 04:47:03 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default i18next;
|