Add egg list localization for multiple languages

This commit is contained in:
José Ricardo Fleury Oliveira 2024-05-13 23:00:37 -03:00
parent 74ee3329f8
commit 0cd93caff1
17 changed files with 168 additions and 25 deletions

View File

@ -1,9 +1,9 @@
import { Type } from "./type";
import * as Utils from "../utils";
import BattleScene from "../battle-scene";
import i18next from '../plugins/i18n';
import * as Utils from "../utils";
import { EggTier } from "./enums/egg-type";
import { Species } from "./enums/species";
import { getPokemonSpecies, speciesStarters } from "./pokemon-species";
import { EggTier } from "./enums/egg-type";
export const EGG_SEED = 1073741824;
@ -54,36 +54,53 @@ export function getEggTierDefaultHatchWaves(tier: EggTier): integer {
export function getEggDescriptor(egg: Egg): string {
if (egg.isManaphyEgg())
return 'Manaphy';
let ret: string;
switch (egg.tier) {
case EggTier.GREAT:
return 'Rare';
ret = i18next.t('eggList:rare');
return ret;
case EggTier.ULTRA:
return 'Epic';
ret = i18next.t('eggList:epic');
return ret;
case EggTier.MASTER:
return 'Legendary';
ret = i18next.t('eggList:legendary');
return ret;
default:
return 'Common';
ret = i18next.t('eggList:common');
return ret;
}
}
export function getEggHatchWavesMessage(hatchWaves: integer): string {
if (hatchWaves <= 5)
return 'Sounds can be heard coming from inside! It will hatch soon!';
if (hatchWaves <= 15)
return 'It appears to move occasionally. It may be close to hatching.';
if (hatchWaves <= 50)
return 'What will hatch from this? It doesn\'t seem close to hatching.';
return 'It looks like this Egg will take a long time to hatch.';
let ret: string;
switch (true) {
case hatchWaves <= 5:
ret = i18next.t('eggList:5waves');
return ret;
case hatchWaves <= 15:
ret = i18next.t('eggList:15waves');
return ret;
case hatchWaves <= 50:
ret = i18next.t('eggList:50waves');
return ret;
default:
ret = i18next.t('eggList:>50waves');
return ret;
}
}
export function getEggGachaTypeDescriptor(scene: BattleScene, egg: Egg): string {
let ret: string;
switch (egg.gachaType) {
case GachaType.LEGENDARY:
return `Legendary Rate Up (${getPokemonSpecies(getLegendaryGachaSpeciesForTimestamp(scene, egg.timestamp)).getName()})`;
ret = `${i18next.t('eggList:legendaryRateUp')} (${getPokemonSpecies(getLegendaryGachaSpeciesForTimestamp(scene, egg.timestamp)).getName()})`
return ret;
case GachaType.MOVE:
return 'Rare Egg Move Rate Up';
ret = i18next.t('eggList:rareEggMoveRateUp');
return ret;
case GachaType.SHINY:
return 'Shiny Rate Up';
ret = i18next.t('eggList:shinyRateUp');
return ret;
}
}

View File

@ -1,6 +1,7 @@
import { ability } from "./ability";
import { battle } from "./battle";
import { commandUiHandler } from "./command-ui-handler";
import { eggList } from "./egg-list";
import { fightUiHandler } from "./fight-ui-handler";
import { growth } from "./growth";
import { menu } from "./menu";
@ -18,6 +19,7 @@ export const deConfig = {
ability: ability,
battle: battle,
commandUiHandler: commandUiHandler,
eggList: eggList,
fightUiHandler: fightUiHandler,
menuUiHandler: menuUiHandler,
menu: menu,

View File

@ -0,0 +1,16 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const eggList: SimpleTranslationEntries = {
"egg": "Egg",
"common": "Common",
"rare": "Rare",
"epic": "Epic",
"legendary": "Legendary",
"5waves": "Sounds can be heard coming from inside! It will hatch soon!",
"15waves": "It appears to move occasionally. It may be close to hatching.",
"50waves": "What will hatch from this? It doesn't seem close to hatching.",
">50waves": "It looks like this Egg will take a long time to hatch.",
"legendaryRateUp": "Legendary Rate Up",
"rareEggMoveRateUp": "Rare Egg Move Rate Up",
"shinyRateUp": "Shiny Rate Up",
} as const;

View File

@ -1,6 +1,7 @@
import { ability } from "./ability";
import { battle } from "./battle";
import { commandUiHandler } from "./command-ui-handler";
import { eggList } from "./egg-list";
import { fightUiHandler } from "./fight-ui-handler";
import { growth } from "./growth";
import { menu } from "./menu";
@ -18,6 +19,7 @@ export const enConfig = {
ability: ability,
battle: battle,
commandUiHandler: commandUiHandler,
eggList: eggList,
fightUiHandler: fightUiHandler,
menuUiHandler: menuUiHandler,
menu: menu,

View File

@ -0,0 +1,16 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const eggList: SimpleTranslationEntries = {
"egg": "Egg",
"common": "Common",
"rare": "Rare",
"epic": "Epic",
"legendary": "Legendary",
"5waves": "Sounds can be heard coming from inside! It will hatch soon!",
"15waves": "It appears to move occasionally. It may be close to hatching.",
"50waves": "What will hatch from this? It doesn't seem close to hatching.",
">50waves": "It looks like this Egg will take a long time to hatch.",
"legendaryRateUp": "Legendary Rate Up",
"rareEggMoveRateUp": "Rare Egg Move Rate Up",
"shinyRateUp": "Shiny Rate Up",
} as const;

View File

@ -1,6 +1,7 @@
import { ability } from "./ability";
import { battle } from "./battle";
import { commandUiHandler } from "./command-ui-handler";
import { eggList } from "./egg-list";
import { fightUiHandler } from "./fight-ui-handler";
import { growth } from "./growth";
import { menu } from "./menu";
@ -18,6 +19,7 @@ export const esConfig = {
ability: ability,
battle: battle,
commandUiHandler: commandUiHandler,
eggList: eggList,
fightUiHandler: fightUiHandler,
menuUiHandler: menuUiHandler,
menu: menu,

View File

@ -0,0 +1,16 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const eggList: SimpleTranslationEntries = {
"egg": "Egg",
"common": "Common",
"rare": "Rare",
"epic": "Epic",
"legendary": "Legendary",
"5waves": "Sounds can be heard coming from inside! It will hatch soon!",
"15waves": "It appears to move occasionally. It may be close to hatching.",
"50waves": "What will hatch from this? It doesn't seem close to hatching.",
">50waves": "It looks like this Egg will take a long time to hatch.",
"legendaryRateUp": "Legendary Rate Up",
"rareEggMoveRateUp": "Rare Egg Move Rate Up",
"shinyRateUp": "Shiny Rate Up",
} as const;

View File

@ -1,6 +1,7 @@
import { ability } from "./ability";
import { battle } from "./battle";
import { commandUiHandler } from "./command-ui-handler";
import { eggList } from "./egg-list";
import { fightUiHandler } from "./fight-ui-handler";
import { growth } from "./growth";
import { menu } from "./menu";
@ -18,6 +19,7 @@ export const frConfig = {
ability: ability,
battle: battle,
commandUiHandler: commandUiHandler,
eggList: eggList,
fightUiHandler: fightUiHandler,
menuUiHandler: menuUiHandler,
menu: menu,

View File

@ -0,0 +1,16 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const eggList: SimpleTranslationEntries = {
"egg": "Egg",
"common": "Common",
"rare": "Rare",
"epic": "Epic",
"legendary": "Legendary",
"5waves": "Sounds can be heard coming from inside! It will hatch soon!",
"15waves": "It appears to move occasionally. It may be close to hatching.",
"50waves": "What will hatch from this? It doesn't seem close to hatching.",
">50waves": "It looks like this Egg will take a long time to hatch.",
"legendaryRateUp": "Legendary Rate Up",
"rareEggMoveRateUp": "Rare Egg Move Rate Up",
"shinyRateUp": "Shiny Rate Up",
} as const;

View File

@ -1,6 +1,7 @@
import { ability } from "./ability";
import { battle } from "./battle";
import { commandUiHandler } from "./command-ui-handler";
import { eggList } from "./egg-list";
import { fightUiHandler } from "./fight-ui-handler";
import { growth } from "./growth";
import { menu } from "./menu";
@ -18,6 +19,7 @@ export const itConfig = {
ability: ability,
battle: battle,
commandUiHandler: commandUiHandler,
eggList: eggList,
fightUiHandler: fightUiHandler,
menuUiHandler: menuUiHandler,
menu: menu,

View File

@ -0,0 +1,16 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const eggList: SimpleTranslationEntries = {
"egg": "Egg",
"common": "Common",
"rare": "Rare",
"epic": "Epic",
"legendary": "Legendary",
"5waves": "Sounds can be heard coming from inside! It will hatch soon!",
"15waves": "It appears to move occasionally. It may be close to hatching.",
"50waves": "What will hatch from this? It doesn't seem close to hatching.",
">50waves": "It looks like this Egg will take a long time to hatch.",
"legendaryRateUp": "Legendary Rate Up",
"rareEggMoveRateUp": "Rare Egg Move Rate Up",
"shinyRateUp": "Shiny Rate Up",
} as const;

View File

@ -1,6 +1,7 @@
import { ability } from "./ability";
import { battle } from "./battle";
import { commandUiHandler } from "./command-ui-handler";
import { eggList } from "./egg-list";
import { fightUiHandler } from "./fight-ui-handler";
import { growth } from "./growth";
import { menu } from "./menu";
@ -13,11 +14,11 @@ import { pokemonStat } from "./pokemon-stat";
import { starterSelectUiHandler } from "./starter-select-ui-handler";
import { tutorial } from "./tutorial";
export const ptBrConfig = {
ability: ability,
battle: battle,
commandUiHandler: commandUiHandler,
eggList: eggList,
fightUiHandler: fightUiHandler,
menuUiHandler: menuUiHandler,
menu: menu,

View File

@ -0,0 +1,16 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const eggList: SimpleTranslationEntries = {
"egg": "Ovo",
"common": "Comum",
"rare": "Raro",
"epic": "Épico",
"legendary": "Lendário",
"5waves": "Barulhos podem ser ouvidos vindo de dentro! Vai chocar em breve!",
"15waves": "Parece se mover ocasionalmente. Pode estar perto de chocar.",
"50waves": "O que vai nascer disso? Não parece estar perto de chocar.",
">50waves": "Parece que este ovo vai demorar bastante para chocar.",
"legendaryRateUp": "Taxa de Lendário Aumentada",
"rareEggMoveRateUp": "Taxa de Movimento de Ovo Raro Aumentada",
"shinyRateUp": "Taxa de Shiny Aumentada",
} as const;

View File

@ -1,22 +1,24 @@
import { ability } from "./ability";
import { battle } from "./battle";
import { commandUiHandler } from "./command-ui-handler";
import { eggList } from "./egg-list";
import { fightUiHandler } from "./fight-ui-handler";
import { menu } from "./menu";
import { menuUiHandler } from "./menu-ui-handler";
import { move } from "./move";
import { nature } from "./nature";
import { pokeball } from "./pokeball";
import { pokemon } from "./pokemon";
import { pokemonStat } from "./pokemon-stat";
import { starterSelectUiHandler } from "./starter-select-ui-handler";
import { tutorial } from "./tutorial";
import { nature } from "./nature";
export const zhCnConfig = {
ability: ability,
battle: battle,
commandUiHandler: commandUiHandler,
eggList: eggList,
fightUiHandler: fightUiHandler,
menuUiHandler: menuUiHandler,
menu: menu,

View File

@ -0,0 +1,16 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const eggList: SimpleTranslationEntries = {
"egg": "Egg",
"common": "Common",
"rare": "Rare",
"epic": "Epic",
"legendary": "Legendary",
"5waves": "Sounds can be heard coming from inside! It will hatch soon!",
"15waves": "It appears to move occasionally. It may be close to hatching.",
"50waves": "What will hatch from this? It doesn't seem close to hatching.",
">50waves": "It looks like this Egg will take a long time to hatch.",
"legendaryRateUp": "Legendary Rate Up",
"rareEggMoveRateUp": "Rare Egg Move Rate Up",
"shinyRateUp": "Shiny Rate Up",
} as const;

View File

@ -109,6 +109,7 @@ declare module 'i18next' {
starterSelectUiHandler: SimpleTranslationEntries;
nature: SimpleTranslationEntries;
growth: SimpleTranslationEntries;
eggList: SimpleTranslationEntries;
};
}
}

View File

@ -1,12 +1,12 @@
import BattleScene from "../battle-scene";
import { Mode } from "./ui";
import { Egg, getEggDescriptor, getEggGachaTypeDescriptor, getEggHatchWavesMessage } from "../data/egg";
import { Button } from "../enums/buttons";
import i18next from '../plugins/i18n';
import MessageUiHandler from "./message-ui-handler";
import PokemonIconAnimHandler, { PokemonIconAnimMode } from "./pokemon-icon-anim-handler";
import { TextStyle, addTextObject } from "./text";
import MessageUiHandler from "./message-ui-handler";
import { EGG_SEED, Egg, GachaType, getEggGachaTypeDescriptor, getEggHatchWavesMessage, getEggDescriptor } from "../data/egg";
import * as Utils from "../utils";
import { Mode } from "./ui";
import { addWindow } from "./ui-theme";
import {Button} from "../enums/buttons";
export default class EggListUiHandler extends MessageUiHandler {
private eggListContainer: Phaser.GameObjects.Container;
@ -165,7 +165,7 @@ export default class EggListUiHandler extends MessageUiHandler {
setEggDetails(egg: Egg): void {
this.eggSprite.setFrame(`egg_${egg.getKey()}`);
this.eggNameText.setText(`Egg (${getEggDescriptor(egg)})`);
this.eggNameText.setText(`${i18next.t('eggList:egg')} (${getEggDescriptor(egg)})`);
this.eggDateText.setText(
new Date(egg.timestamp).toLocaleString(undefined, {
weekday: 'short',