mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-06 00:12:16 +02:00
Reload ability localization when language is changed
This commit is contained in:
parent
389a347b07
commit
19bb8c3759
@ -21,6 +21,7 @@ import { ModifierPoolType, getDefaultModifierTypeForTier, getEnemyModifierTypesF
|
||||
import AbilityBar from './ui/ability-bar';
|
||||
import { BlockItemTheftAbAttr, DoubleBattleChanceAbAttr, IncrementMovePriorityAbAttr, applyAbAttrs, initAbilities } from './data/ability';
|
||||
import { Abilities } from "./data/enums/abilities";
|
||||
import { allAbilities } from "./data/ability";
|
||||
import Battle, { BattleType, FixedBattleConfig, fixedBattles } from './battle';
|
||||
import { GameMode, GameModes, gameModes } from './game-mode';
|
||||
import FieldSpritePipeline from './pipelines/field-sprite';
|
||||
@ -808,6 +809,7 @@ export default class BattleScene extends SceneBase {
|
||||
const localizable: Localizable[] = [
|
||||
...allSpecies,
|
||||
...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()
|
||||
];
|
||||
for (let item of localizable)
|
||||
|
@ -18,9 +18,9 @@ import { Moves } from "./enums/moves";
|
||||
import { TerrainType } from "./terrain";
|
||||
import { SpeciesFormChangeManualTrigger } from "./pokemon-forms";
|
||||
import { Abilities } from "./enums/abilities";
|
||||
import i18next from "#app/plugins/i18n.js";
|
||||
import i18next, { Localizable } from "#app/plugins/i18n.js";
|
||||
|
||||
export class Ability {
|
||||
export class Ability implements Localizable {
|
||||
public id: Abilities;
|
||||
public name: string;
|
||||
public description: string;
|
||||
@ -32,16 +32,18 @@ export class Ability {
|
||||
|
||||
constructor(id: Abilities, generation: integer) {
|
||||
this.id = id;
|
||||
|
||||
const i18nKey = Abilities[id].split('_').filter(f => f).map((f, i) => i ? `${f[0]}${f.slice(1).toLowerCase()}` : f.toLowerCase()).join('') as string;
|
||||
|
||||
this.name = id ? i18next.t(`ability:${i18nKey}.name`) as string : '';
|
||||
this.description = id ? i18next.t(`ability:${i18nKey}.description`) as string : '';
|
||||
this.generation = generation;
|
||||
this.attrs = [];
|
||||
this.conditions = [];
|
||||
}
|
||||
|
||||
localize(): void {
|
||||
const i18nKey = Abilities[this.id].split('_').filter(f => f).map((f, i) => i ? `${f[0]}${f.slice(1).toLowerCase()}` : f.toLowerCase()).join('') as string;
|
||||
|
||||
this.name = this.id ? i18next.t(`ability:${i18nKey}.name`) as string : '';
|
||||
this.description = this.id ? i18next.t(`ability:${i18nKey}.description`) as string : '';
|
||||
}
|
||||
|
||||
getAttrs(attrType: { new(...args: any[]): AbAttr }): AbAttr[] {
|
||||
return this.attrs.filter(a => a instanceof attrType);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user