From 674b2257be53e98cbee8fa5f665e0223fde85ae9 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 6 May 2024 14:25:17 -0400 Subject: [PATCH] I18n import cleanup (#562) * config import change * all other configs --- src/locales/de/config.ts | 28 +++++++ src/locales/en/config.ts | 28 +++++++ src/locales/es/config.ts | 28 +++++++ src/locales/fr/config.ts | 28 +++++++ src/locales/it/config.ts | 28 +++++++ src/plugins/i18n.ts | 165 ++++++--------------------------------- 6 files changed, 162 insertions(+), 143 deletions(-) create mode 100644 src/locales/de/config.ts create mode 100644 src/locales/en/config.ts create mode 100644 src/locales/es/config.ts create mode 100644 src/locales/fr/config.ts create mode 100644 src/locales/it/config.ts diff --git a/src/locales/de/config.ts b/src/locales/de/config.ts new file mode 100644 index 000000000..c388d7dec --- /dev/null +++ b/src/locales/de/config.ts @@ -0,0 +1,28 @@ +import { ability } from "./ability"; +import { battle } from "./battle"; +import { commandUiHandler } from "./command-ui-handler"; +import { fightUiHandler } from "./fight-ui-handler"; +import { menu } from "./menu"; +import { menuUiHandler } from "./menu-ui-handler"; +import { move } from "./move"; +import { pokeball } from "./pokeball"; +import { pokemon } from "./pokemon"; +import { pokemonStat } from "./pokemon-stat"; +import { starterSelectUiHandler } from "./starter-select-ui-handler"; +import { tutorial } from "./tutorial"; + + +export const deConfig = { + ability: ability, + battle: battle, + commandUiHandler: commandUiHandler, + fightUiHandler: fightUiHandler, + menuUiHandler: menuUiHandler, + menu: menu, + move: move, + pokeball: pokeball, + pokemonStat: pokemonStat, + pokemon: pokemon, + starterSelectUiHandler: starterSelectUiHandler, + tutorial: tutorial +} \ No newline at end of file diff --git a/src/locales/en/config.ts b/src/locales/en/config.ts new file mode 100644 index 000000000..11cbc42d9 --- /dev/null +++ b/src/locales/en/config.ts @@ -0,0 +1,28 @@ +import { ability } from "./ability"; +import { battle } from "./battle"; +import { commandUiHandler } from "./command-ui-handler"; +import { fightUiHandler } from "./fight-ui-handler"; +import { menu } from "./menu"; +import { menuUiHandler } from "./menu-ui-handler"; +import { move } from "./move"; +import { pokeball } from "./pokeball"; +import { pokemon } from "./pokemon"; +import { pokemonStat } from "./pokemon-stat"; +import { starterSelectUiHandler } from "./starter-select-ui-handler"; +import { tutorial } from "./tutorial"; + + +export const enConfig = { + ability: ability, + battle: battle, + commandUiHandler: commandUiHandler, + fightUiHandler: fightUiHandler, + menuUiHandler: menuUiHandler, + menu: menu, + move: move, + pokeball: pokeball, + pokemonStat: pokemonStat, + pokemon: pokemon, + starterSelectUiHandler: starterSelectUiHandler, + tutorial: tutorial +} \ No newline at end of file diff --git a/src/locales/es/config.ts b/src/locales/es/config.ts new file mode 100644 index 000000000..093a4b393 --- /dev/null +++ b/src/locales/es/config.ts @@ -0,0 +1,28 @@ +import { ability } from "./ability"; +import { battle } from "./battle"; +import { commandUiHandler } from "./command-ui-handler"; +import { fightUiHandler } from "./fight-ui-handler"; +import { menu } from "./menu"; +import { menuUiHandler } from "./menu-ui-handler"; +import { move } from "./move"; +import { pokeball } from "./pokeball"; +import { pokemon } from "./pokemon"; +import { pokemonStat } from "./pokemon-stat"; +import { starterSelectUiHandler } from "./starter-select-ui-handler"; +import { tutorial } from "./tutorial"; + + +export const esConfig = { + ability: ability, + battle: battle, + commandUiHandler: commandUiHandler, + fightUiHandler: fightUiHandler, + menuUiHandler: menuUiHandler, + menu: menu, + move: move, + pokeball: pokeball, + pokemonStat: pokemonStat, + pokemon: pokemon, + starterSelectUiHandler: starterSelectUiHandler, + tutorial: tutorial +} \ No newline at end of file diff --git a/src/locales/fr/config.ts b/src/locales/fr/config.ts new file mode 100644 index 000000000..a2e678ca6 --- /dev/null +++ b/src/locales/fr/config.ts @@ -0,0 +1,28 @@ +import { ability } from "./ability"; +import { battle } from "./battle"; +import { commandUiHandler } from "./command-ui-handler"; +import { fightUiHandler } from "./fight-ui-handler"; +import { menu } from "./menu"; +import { menuUiHandler } from "./menu-ui-handler"; +import { move } from "./move"; +import { pokeball } from "./pokeball"; +import { pokemon } from "./pokemon"; +import { pokemonStat } from "./pokemon-stat"; +import { starterSelectUiHandler } from "./starter-select-ui-handler"; +import { tutorial } from "./tutorial"; + + +export const frConfig = { + ability: ability, + battle: battle, + commandUiHandler: commandUiHandler, + fightUiHandler: fightUiHandler, + menuUiHandler: menuUiHandler, + menu: menu, + move: move, + pokeball: pokeball, + pokemonStat: pokemonStat, + pokemon: pokemon, + starterSelectUiHandler: starterSelectUiHandler, + tutorial: tutorial +} \ No newline at end of file diff --git a/src/locales/it/config.ts b/src/locales/it/config.ts new file mode 100644 index 000000000..af394bd64 --- /dev/null +++ b/src/locales/it/config.ts @@ -0,0 +1,28 @@ +import { ability } from "./ability"; +import { battle } from "./battle"; +import { commandUiHandler } from "./command-ui-handler"; +import { fightUiHandler } from "./fight-ui-handler"; +import { menu } from "./menu"; +import { menuUiHandler } from "./menu-ui-handler"; +import { move } from "./move"; +import { pokeball } from "./pokeball"; +import { pokemon } from "./pokemon"; +import { pokemonStat } from "./pokemon-stat"; +import { starterSelectUiHandler } from "./starter-select-ui-handler"; +import { tutorial } from "./tutorial"; + + +export const itConfig = { + ability: ability, + battle: battle, + commandUiHandler: commandUiHandler, + fightUiHandler: fightUiHandler, + menuUiHandler: menuUiHandler, + menu: menu, + move: move, + pokeball: pokeball, + pokemonStat: pokemonStat, + pokemon: pokemon, + starterSelectUiHandler: starterSelectUiHandler, + tutorial: tutorial +} \ No newline at end of file diff --git a/src/plugins/i18n.ts b/src/plugins/i18n.ts index 8ad0711f5..6265d35cf 100644 --- a/src/plugins/i18n.ts +++ b/src/plugins/i18n.ts @@ -1,77 +1,11 @@ import i18next from 'i18next'; import LanguageDetector from 'i18next-browser-languagedetector'; -import { menu as enMenu } from '../locales/en/menu'; -import { menu as esMenu } from '../locales/es/menu'; -import { menu as itMenu } from '../locales/it/menu'; -import { menu as frMenu } from '../locales/fr/menu'; -import { menu as deMenu } from '../locales/de/menu'; - -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'; -import { menuUiHandler as deMenuUiHandler } from '../locales/de/menu-ui-handler.js'; - -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'; - -import { move as enMove } from '../locales/en/move'; -import { move as esMove } from '../locales/es/move'; -import { move as itMove } from '../locales/it/move'; -import { move as frMove } from '../locales/fr/move'; -import { move as deMove } from '../locales/de/move'; - -import { ability as enAbility } from '../locales/en/ability'; -import { ability as esAbility } from '../locales/es/ability'; -import { ability as itAbility } from '../locales/it/ability'; -import { ability as frAbility } from '../locales/fr/ability'; -import { ability as deAbility } from '../locales/de/ability'; - -import { pokeball as enPokeball } from '../locales/en/pokeball'; -import { pokeball as esPokeball } from '../locales/es/pokeball'; -import { pokeball as itPokeball } from '../locales/it/pokeball'; -import { pokeball as frPokeball } from '../locales/fr/pokeball'; -import { pokeball as dePokeball } from '../locales/de/pokeball'; - -import { pokemon as enPokemon } from '../locales/en/pokemon'; -import { pokemon as esPokemon } from '../locales/es/pokemon'; -import { pokemon as itPokemon } from '../locales/it/pokemon'; -import { pokemon as frPokemon } from '../locales/fr/pokemon'; -import { pokemon as dePokemon } from '../locales/de/pokemon'; - -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'; -import { pokemonStat as dePokemonStat } from '../locales/de/pokemon-stat'; - -import { commandUiHandler as enCommandUiHandler } from '../locales/en/command-ui-handler'; -import { commandUiHandler as esCommandUiHandler } from '../locales/es/command-ui-handler'; -import { commandUiHandler as itCommandUiHandler } from '../locales/it/command-ui-handler'; -import { commandUiHandler as frCommandUiHandler } from '../locales/fr/command-ui-handler'; -import { commandUiHandler as deCommandUiHandler } from '../locales/de/command-ui-handler'; - -import { fightUiHandler as enFightUiHandler } from '../locales/en/fight-ui-handler'; -import { fightUiHandler as esFightUiHandler } from '../locales/es/fight-ui-handler'; -import { fightUiHandler as frFightUiHandler } from '../locales/fr/fight-ui-handler'; -import { fightUiHandler as itFightUiHandler } from '../locales/it/fight-ui-handler'; -import { fightUiHandler as deFightUiHandler } from '../locales/de/fight-ui-handler'; - -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'; - -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'; +import { deConfig } from '#app/locales/de/config.js'; +import { enConfig } from '#app/locales/en/config.js'; +import { esConfig } from '#app/locales/es/config.js'; +import { frConfig } from '#app/locales/fr/config.js'; +import { itConfig } from '#app/locales/it/config.js'; export interface SimpleTranslationEntries { [key: string]: string @@ -131,74 +65,19 @@ export function initI18n(): void { }, resources: { en: { - menu: enMenu, - menuUiHandler: enMenuUiHandler, - battle: enBattle, - move: enMove, - ability: enAbility, - pokeball: enPokeball, - pokemon: enPokemon, - pokemonStat: enPokemonStat, - commandUiHandler: enCommandUiHandler, - fightUiHandler: enFightUiHandler, - tutorial: enTutorial, - starterSelectUiHandler: enStarterSelectUiHandler + ...enConfig }, es: { - menu: esMenu, - menuUiHandler: esMenuUiHandler, - battle: esBattle, - move: esMove, - ability: esAbility, - pokeball: esPokeball, - pokemon: esPokemon, - pokemonStat: esPokemonStat, - commandUiHandler: esCommandUiHandler, - fightUiHandler: esFightUiHandler, - tutorial: esTutorial, - starterSelectUiHandler: esStarterSelectUiHandler + ...esConfig }, fr: { - menu: frMenu, - menuUiHandler: frMenuUiHandler, - battle: frBattle, - move: frMove, - ability: frAbility, - pokeball: frPokeball, - pokemon: frPokemon, - pokemonStat: frPokemonStat, - commandUiHandler: frCommandUiHandler, - fightUiHandler: frFightUiHandler, - tutorial: frTutorial, - starterSelectUiHandler: frStarterSelectUiHandler + ...frConfig }, it: { - menu: itMenu, - menuUiHandler: itMenuUiHandler, - battle: itBattle, - move: itMove, - ability: itAbility, - pokeball: itPokeball, - pokemon: itPokemon, - pokemonStat: itPokemonStat, - commandUiHandler: itCommandUiHandler, - fightUiHandler: itFightUiHandler, - tutorial: itTutorial, - starterSelectUiHandler: itStarterSelectUiHandler + ...itConfig }, de: { - menu: deMenu, - menuUiHandler: deMenuUiHandler, - battle: deBattle, - move: deMove, - ability: deAbility, - pokeball: dePokeball, - pokemon: dePokemon, - pokemonStat: dePokemonStat, - commandUiHandler: deCommandUiHandler, - fightUiHandler: deFightUiHandler, - tutorial: deTutorial, - starterSelectUiHandler: deStarterSelectUiHandler + ...deConfig } }, }); @@ -208,18 +87,18 @@ export function initI18n(): void { declare module 'i18next' { interface CustomTypeOptions { resources: { - menu: typeof enMenu; - menuUiHandler: typeof enMenuUiHandler; - move: typeof enMove; - battle: typeof enBattle, - ability: typeof enAbility; - pokeball: typeof enPokeball; - pokemon: typeof enPokemon; - pokemonStat: typeof enPokemonStat; - commandUiHandler: typeof enCommandUiHandler; - fightUiHandler: typeof enFightUiHandler; - tutorial: typeof enTutorial; - starterSelectUiHandler: typeof enStarterSelectUiHandler; + menu: SimpleTranslationEntries; + menuUiHandler: SimpleTranslationEntries; + move: MoveTranslationEntries; + battle: SimpleTranslationEntries, + ability: AbilityTranslationEntries; + pokeball: SimpleTranslationEntries; + pokemon: SimpleTranslationEntries; + pokemonStat: SimpleTranslationEntries; + commandUiHandler: SimpleTranslationEntries; + fightUiHandler: SimpleTranslationEntries; + tutorial: SimpleTranslationEntries; + starterSelectUiHandler: SimpleTranslationEntries; }; } }