2024-04-12 04:47:03 +01:00
|
|
|
import i18next from 'i18next';
|
2024-04-30 16:07:15 +01:00
|
|
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
|
|
|
2024-04-12 04:47:03 +01:00
|
|
|
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-05-01 23:53:48 +01:00
|
|
|
import { battle as enBattle } from '../locales/en/battle';
|
|
|
|
import { battle as esBattle } from '../locales/es/battle';
|
|
|
|
import { battle as itBattle } from '../locales/it/battle';
|
|
|
|
import { battle as frBattle } from '../locales/fr/battle';
|
|
|
|
import { battle as deBattle } from '../locales/de/battle';
|
|
|
|
|
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-05-05 03:00:28 +01:00
|
|
|
import { move as itMove } from '../locales/it/move';
|
2024-04-16 19:29:32 +01:00
|
|
|
import { move as frMove } from '../locales/fr/move';
|
2024-04-26 02:20:07 +01:00
|
|
|
import { move as deMove } from '../locales/de/move';
|
2024-04-16 19:29:32 +01:00
|
|
|
|
2024-04-25 02:10:09 +01:00
|
|
|
import { ability as enAbility } from '../locales/en/ability';
|
|
|
|
import { ability as esAbility } from '../locales/es/ability';
|
2024-05-05 03:00:28 +01:00
|
|
|
import { ability as itAbility } from '../locales/it/ability';
|
2024-04-25 02:10:09 +01:00
|
|
|
import { ability as frAbility } from '../locales/fr/ability';
|
2024-04-26 02:20:07 +01:00
|
|
|
import { ability as deAbility } from '../locales/de/ability';
|
2024-04-25 02:10:09 +01:00
|
|
|
|
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-05-05 03:00:28 +01:00
|
|
|
import { pokeball as itPokeball } from '../locales/it/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-05-05 03:00:28 +01:00
|
|
|
import { pokemon as itPokemon } from '../locales/it/pokemon';
|
2024-04-22 00:53:24 +01:00
|
|
|
import { pokemon as frPokemon } from '../locales/fr/pokemon';
|
2024-04-26 02:20:07 +01:00
|
|
|
import { pokemon as dePokemon } from '../locales/de/pokemon';
|
2024-04-22 00:53:24 +01:00
|
|
|
|
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';
|
2024-05-05 03:00:28 +01:00
|
|
|
import { commandUiHandler as itCommandUiHandler } from '../locales/it/command-ui-handler';
|
2024-04-24 05:36:07 +01:00
|
|
|
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';
|
2024-05-01 23:53:48 +01:00
|
|
|
import { fightUiHandler as esFightUiHandler } from '../locales/es/fight-ui-handler';
|
2024-04-25 23:54:56 +01:00
|
|
|
import { fightUiHandler as frFightUiHandler } from '../locales/fr/fight-ui-handler';
|
2024-05-01 23:53:48 +01:00
|
|
|
import { fightUiHandler as itFightUiHandler } from '../locales/it/fight-ui-handler';
|
|
|
|
import { fightUiHandler as deFightUiHandler } from '../locales/de/fight-ui-handler';
|
2024-04-25 23:54:56 +01:00
|
|
|
|
2024-04-29 17:33:18 +01:00
|
|
|
import { tutorial as enTutorial } from '../locales/en/tutorial';
|
|
|
|
import { tutorial as esTutorial } from '../locales/es/tutorial';
|
|
|
|
import { tutorial as frTutorial } from '../locales/fr/tutorial';
|
|
|
|
import { tutorial as itTutorial} from '../locales/it/tutorial';
|
|
|
|
import { tutorial as deTutorial } from '../locales/de/tutorial';
|
|
|
|
|
2024-05-06 17:02:45 +01:00
|
|
|
import { starterSelectUiHandler as enStarterSelectUiHandler } from '../locales/en/starter-select-ui-handler';
|
|
|
|
import { starterSelectUiHandler as esStarterSelectUiHandler } from '../locales/es/starter-select-ui-handler';
|
|
|
|
import { starterSelectUiHandler as frStarterSelectUiHandler } from '../locales/fr/starter-select-ui-handler';
|
|
|
|
import { starterSelectUiHandler as itStarterSelectUiHandler} from '../locales/it/starter-select-ui-handler';
|
|
|
|
import { starterSelectUiHandler as deStarterSelectUiHandler } from '../locales/de/starter-select-ui-handler';
|
|
|
|
|
2024-04-22 00:53:24 +01:00
|
|
|
export interface SimpleTranslationEntries {
|
|
|
|
[key: string]: string
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function initI18n(): void {
|
2024-04-30 16:07:15 +01:00
|
|
|
let lang = '';
|
2024-04-19 19:55:01 +01:00
|
|
|
|
|
|
|
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-30 16:07:15 +01:00
|
|
|
* Don't forget to declare new language in `supportedLngs` i18next initializer
|
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-30 16:07:15 +01:00
|
|
|
*
|
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
|
|
|
*/
|
|
|
|
|
2024-04-30 16:07:15 +01:00
|
|
|
i18next.use(LanguageDetector).init({
|
|
|
|
lng: lang,
|
2024-04-19 19:55:01 +01:00
|
|
|
fallbackLng: 'en',
|
2024-04-30 16:07:15 +01:00
|
|
|
supportedLngs: ['en', 'es', 'fr', 'it', 'de'],
|
2024-04-19 19:55:01 +01:00
|
|
|
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-05-01 23:53:48 +01:00
|
|
|
battle: enBattle,
|
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-29 17:33:18 +01:00
|
|
|
tutorial: enTutorial,
|
2024-05-06 17:02:45 +01:00
|
|
|
starterSelectUiHandler: enStarterSelectUiHandler
|
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-05-01 23:53:48 +01:00
|
|
|
battle: esBattle,
|
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-05-01 23:53:48 +01:00
|
|
|
fightUiHandler: esFightUiHandler,
|
2024-04-29 17:33:18 +01:00
|
|
|
tutorial: esTutorial,
|
2024-05-06 17:02:45 +01:00
|
|
|
starterSelectUiHandler: esStarterSelectUiHandler
|
2024-04-19 19:55:01 +01:00
|
|
|
},
|
|
|
|
fr: {
|
|
|
|
menu: frMenu,
|
2024-04-25 18:38:33 +01:00
|
|
|
menuUiHandler: frMenuUiHandler,
|
2024-05-01 23:53:48 +01:00
|
|
|
battle: frBattle,
|
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-29 17:33:18 +01:00
|
|
|
tutorial: frTutorial,
|
2024-05-06 17:02:45 +01:00
|
|
|
starterSelectUiHandler: frStarterSelectUiHandler
|
2024-04-24 05:36:07 +01:00
|
|
|
},
|
|
|
|
it: {
|
|
|
|
menu: itMenu,
|
2024-04-25 18:38:33 +01:00
|
|
|
menuUiHandler: itMenuUiHandler,
|
2024-05-01 23:53:48 +01:00
|
|
|
battle: itBattle,
|
2024-05-05 03:00:28 +01:00
|
|
|
move: itMove,
|
|
|
|
ability: itAbility,
|
|
|
|
pokeball: itPokeball,
|
|
|
|
pokemon: itPokemon,
|
2024-04-24 21:10:03 +01:00
|
|
|
pokemonStat: itPokemonStat,
|
2024-05-05 03:00:28 +01:00
|
|
|
commandUiHandler: itCommandUiHandler,
|
2024-05-01 23:53:48 +01:00
|
|
|
fightUiHandler: itFightUiHandler,
|
2024-04-29 17:33:18 +01:00
|
|
|
tutorial: itTutorial,
|
2024-05-06 17:02:45 +01:00
|
|
|
starterSelectUiHandler: itStarterSelectUiHandler
|
2024-04-24 05:36:07 +01:00
|
|
|
},
|
2024-04-25 22:24:53 +01:00
|
|
|
de: {
|
|
|
|
menu: deMenu,
|
|
|
|
menuUiHandler: deMenuUiHandler,
|
2024-05-01 23:53:48 +01:00
|
|
|
battle: deBattle,
|
2024-04-26 02:20:07 +01:00
|
|
|
move: deMove,
|
|
|
|
ability: deAbility,
|
2024-04-25 22:24:53 +01:00
|
|
|
pokeball: dePokeball,
|
2024-04-26 02:20:07 +01:00
|
|
|
pokemon: dePokemon,
|
2024-04-25 22:24:53 +01:00
|
|
|
pokemonStat: dePokemonStat,
|
|
|
|
commandUiHandler: deCommandUiHandler,
|
2024-05-01 23:53:48 +01:00
|
|
|
fightUiHandler: deFightUiHandler,
|
2024-04-29 17:33:18 +01:00
|
|
|
tutorial: deTutorial,
|
2024-05-06 17:02:45 +01:00
|
|
|
starterSelectUiHandler: deStarterSelectUiHandler
|
2024-04-25 22:24:53 +01:00
|
|
|
}
|
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-05-01 23:53:48 +01:00
|
|
|
battle: typeof enBattle,
|
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-29 17:33:18 +01:00
|
|
|
tutorial: typeof enTutorial;
|
2024-05-06 17:02:45 +01:00
|
|
|
starterSelectUiHandler: typeof enStarterSelectUiHandler;
|
2024-04-12 04:47:03 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default i18next;
|