Support localization of Pokémon abilities (#271)

* Support localization of Pokemon abilities

* Reload ability localization when language is changed

* Add Spanish localization for abilities

* Add missing French abilities localization

* Add missing localize call on abilities

---------

Co-authored-by: Flashfyre <flashfireex@gmail.com>
pull/283/head^2
Pablo González 2024-04-25 03:10:09 +02:00 committed by GitHub
parent ebad76c335
commit 7055ea49c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 4228 additions and 361 deletions

View File

@ -21,6 +21,7 @@ import { ModifierPoolType, getDefaultModifierTypeForTier, getEnemyModifierTypesF
import AbilityBar from './ui/ability-bar'; import AbilityBar from './ui/ability-bar';
import { BlockItemTheftAbAttr, DoubleBattleChanceAbAttr, IncrementMovePriorityAbAttr, applyAbAttrs, initAbilities } from './data/ability'; import { BlockItemTheftAbAttr, DoubleBattleChanceAbAttr, IncrementMovePriorityAbAttr, applyAbAttrs, initAbilities } from './data/ability';
import { Abilities } from "./data/enums/abilities"; import { Abilities } from "./data/enums/abilities";
import { allAbilities } from "./data/ability";
import Battle, { BattleType, FixedBattleConfig, fixedBattles } from './battle'; import Battle, { BattleType, FixedBattleConfig, fixedBattles } from './battle';
import { GameMode, GameModes, gameModes } from './game-mode'; import { GameMode, GameModes, gameModes } from './game-mode';
import FieldSpritePipeline from './pipelines/field-sprite'; import FieldSpritePipeline from './pipelines/field-sprite';
@ -808,6 +809,7 @@ export default class BattleScene extends SceneBase {
const localizable: Localizable[] = [ const localizable: Localizable[] = [
...allSpecies, ...allSpecies,
...allMoves, ...allMoves,
...allAbilities,
...Utils.getEnumValues(ModifierPoolType).map(mpt => getModifierPoolForType(mpt)).map(mp => Object.values(mp).flat().map(mt => mt.modifierType).filter(mt => 'localize' in mt).map(lpb => lpb as unknown as Localizable)).flat() ...Utils.getEnumValues(ModifierPoolType).map(mpt => getModifierPoolForType(mpt)).map(mp => Object.values(mp).flat().map(mt => mt.modifierType).filter(mt => 'localize' in mt).map(lpb => lpb as unknown as Localizable)).flat()
]; ];
for (let item of localizable) for (let item of localizable)

File diff suppressed because it is too large Load Diff

1244
src/locales/en/ability.ts Normal file

File diff suppressed because it is too large Load Diff

1244
src/locales/es/ability.ts Normal file

File diff suppressed because it is too large Load Diff

1244
src/locales/fr/ability.ts Normal file

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,10 @@ import { move as enMove } from '../locales/en/move';
import { move as esMove } from '../locales/es/move'; import { move as esMove } from '../locales/es/move';
import { move as frMove } from '../locales/fr/move'; import { move as frMove } from '../locales/fr/move';
import { ability as enAbility } from '../locales/en/ability';
import { ability as esAbility } from '../locales/es/ability';
import { ability as frAbility } from '../locales/fr/ability';
import { pokeball as enPokeball } from '../locales/en/pokeball'; import { pokeball as enPokeball } from '../locales/en/pokeball';
import { pokeball as esPokeball } from '../locales/es/pokeball'; import { pokeball as esPokeball } from '../locales/es/pokeball';
import { pokeball as frPokeball } from '../locales/fr/pokeball'; import { pokeball as frPokeball } from '../locales/fr/pokeball';
@ -39,6 +43,15 @@ export interface MoveTranslationEntries {
[key: string]: MoveTranslationEntry [key: string]: MoveTranslationEntry
} }
export interface AbilityTranslationEntry {
name: string,
description: string
}
export interface AbilityTranslationEntries {
[key: string]: AbilityTranslationEntry
}
export interface Localizable { export interface Localizable {
localize(): void; localize(): void;
} }
@ -74,6 +87,7 @@ export function initI18n(): void {
en: { en: {
menu: enMenu, menu: enMenu,
move: enMove, move: enMove,
ability: enAbility,
pokeball: enPokeball, pokeball: enPokeball,
pokemon: enPokemon, pokemon: enPokemon,
pokemonStat: enPokemonStat, pokemonStat: enPokemonStat,
@ -82,6 +96,7 @@ export function initI18n(): void {
es: { es: {
menu: esMenu, menu: esMenu,
move: esMove, move: esMove,
ability: esAbility,
pokeball: esPokeball, pokeball: esPokeball,
pokemon: esPokemon, pokemon: esPokemon,
pokemonStat: esPokemonStat, pokemonStat: esPokemonStat,
@ -90,6 +105,7 @@ export function initI18n(): void {
fr: { fr: {
menu: frMenu, menu: frMenu,
move: frMove, move: frMove,
ability: frAbility,
pokeball: frPokeball, pokeball: frPokeball,
pokemon: frPokemon, pokemon: frPokemon,
pokemonStat: frPokemonStat, pokemonStat: frPokemonStat,
@ -109,6 +125,7 @@ declare module 'i18next' {
resources: { resources: {
menu: typeof enMenu; menu: typeof enMenu;
move: typeof enMove; move: typeof enMove;
ability: typeof enAbility;
pokeball: typeof enPokeball; pokeball: typeof enPokeball;
pokemon: typeof enPokemon; pokemon: typeof enPokemon;
pokemonStat: typeof enPokemonStat; pokemonStat: typeof enPokemonStat;