Allowing pokemon name translation (#228)

* Allow pokemon name translation

* Improve Pokemon localization

---------

Co-authored-by: Flashfyre <flashfireex@gmail.com>
pull/201/head^2
Gwendal 2024-04-22 01:53:24 +02:00 committed by GitHub
parent 1a53c19e3b
commit 8d7f1ae554
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 3300 additions and 1103 deletions

View File

@ -796,6 +796,7 @@ export default class BattleScene extends SceneBase {
if (reloadI18n) {
const localizable: Localizable[] = [
...allSpecies,
...allMoves,
...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()
];

View File

@ -249,7 +249,7 @@ export async function printPokemon() {
Math.max(abilities.indexOf(pokemon.abilities.find(a => a.slot === 3)?.ability.name), 0)
];
const pokemonSpecies = new PokemonSpecies(dexId, species.names.find(n => n.language.name === 'en').name, generationIndex, species.is_legendary && baseTotal < 660, species.is_legendary && baseTotal >= 660, species.is_mythical,
const pokemonSpecies = new PokemonSpecies(dexId, generationIndex, species.is_legendary && baseTotal < 660, species.is_legendary && baseTotal >= 660, species.is_mythical,
species.genera.find(g => g.language.name === 'en')?.genus, type1 as Type, type2 > -1 ? type2 as Type : null, pokemon.height / 10, pokemon.weight / 10, ability1 as Abilities, ability2 as Abilities, abilityHidden as Abilities,
baseTotal, baseStats[0], baseStats[1], baseStats[2], baseStats[3], baseStats[4], baseStats[5], species.capture_rate, species.base_happiness, pokemon.base_experience, growthRateMap[species.growth_rate.name],
species.gender_rate < 9 ? 100 - (species.gender_rate * 12.5) : null, species.has_gender_differences, species.forms_switchable);

View File

@ -96,9 +96,6 @@ export default class Move implements Localizable {
constructor(id: Moves, type: Type, category: MoveCategory, defaultMoveTarget: MoveTarget, power: integer, accuracy: integer, pp: integer, chance: integer, priority: integer, generation: integer) {
this.id = id;
const i18nKey = Moves[id].split('_').filter(f => f).map((f, i) => i ? `${f[0]}${f.slice(1).toLowerCase()}` : f.toLowerCase()).join('') as unknown as string;
this.name = id ? i18next.t(`move:${i18nKey}.name`).toString() : '';
this.nameAppend = '';
this.type = type;
this.category = category;
@ -106,7 +103,6 @@ export default class Move implements Localizable {
this.power = power;
this.accuracy = accuracy;
this.pp = pp;
this.effect = id ? i18next.t(`move:${i18nKey}.effect`).toString() : '';
this.chance = chance;
this.priority = priority;
this.generation = generation;
@ -119,9 +115,11 @@ export default class Move implements Localizable {
this.setFlag(MoveFlags.IGNORE_PROTECT, true);
if (category === MoveCategory.PHYSICAL)
this.setFlag(MoveFlags.MAKES_CONTACT, true);
this.localize();
}
localize() {
localize(): void {
const i18nKey = Moves[this.id].split('_').filter(f => f).map((f, i) => i ? `${f[0]}${f.slice(1).toLowerCase()}` : f.toLowerCase()).join('') as unknown as string;
this.name = this.id ? `${i18next.t(`move:${i18nKey}.name`).toString()}${this.nameAppend}` : '';
@ -6162,7 +6160,7 @@ export function initMoves() {
.slicingMove(),
new AttackMove(Moves.HYDRO_STEAM, Type.WATER, MoveCategory.SPECIAL, 80, 100, 15, -1, 0, 9)
.partial(),
new AttackMove(Moves.RUINATION, Type.DARK, MoveCategory.SPECIAL, 1, 90, 10, -1, 0, 9)
new AttackMove(Moves.RUINATION, Type.DARK, MoveCategory.SPECIAL, -1, 90, 10, -1, 0, 9)
.attr(TargetHalfHpDamageAttr),
new AttackMove(Moves.COLLISION_COURSE, Type.FIGHTING, MoveCategory.PHYSICAL, 100, 100, 5, -1, 0, 9)
.attr(MovePowerMultiplierAttr, (user, target, move) => target.getAttackTypeEffectiveness(move.type) >= 2 ? 5461/4096 : 1),

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,11 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
/**
* The menu namespace holds most miscellaneous text that isn't directly part of the game's
* contents or directly related to Pokemon data. This includes menu navigation, settings,
* account interactions, descriptive text, etc.
*/
export const menu = {
export const menu: SimpleTranslationEntries = {
"cancel": "Cancel",
"continue": "Continue",
"dailyRun": "Daily Run (Beta)",

View File

@ -1,6 +1,6 @@
import { MoveTranslations } from "#app/plugins/i18n";
import { MoveTranslationEntries } from "#app/plugins/i18n";
export const move: MoveTranslations = {
export const move: MoveTranslationEntries = {
"pound": {
name: "Pound",
effect: "The target is physically pounded with a long tail, a foreleg, or the like."

View File

@ -1,4 +1,6 @@
export const pokeball = {
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const pokeball: SimpleTranslationEntries = {
"pokeBall": "Poké Ball",
"greatBall": "Great Ball",
"ultraBall": "Ultra Ball",

1086
src/locales/en/pokemon.ts Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,6 @@
export const menu = {
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const menu: SimpleTranslationEntries = {
"cancel": "Annuler",
"continue": "Continuer",
"dailyRun": "Défi du jour (Bêta)",

View File

@ -1,6 +1,6 @@
import { MoveTranslations } from "#app/plugins/i18n";
import { MoveTranslationEntries } from "#app/plugins/i18n";
export const move: MoveTranslations = {
export const move: MoveTranslationEntries = {
"pound": {
name: "Écras'Face",
effect: "Le lanceur écrase la cible avec lun de ses membres, tels quune de ses pattes avant ou sa longue queue."

View File

@ -1,4 +1,6 @@
export const pokeball = {
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const pokeball: SimpleTranslationEntries = {
"pokeBall": "Poké Ball",
"greatBall": "Super Ball",
"ultraBall": "Hyper Ball",

1086
src/locales/fr/pokemon.ts Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,6 @@
export const menu = {
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const menu: SimpleTranslationEntries = {
"cancel": "Annulla",
"continue": "Continua",
"newGame": "Nuova Partita",

View File

@ -142,7 +142,7 @@ class AddPokeballModifierType extends ModifierType implements Localizable {
this.count = count;
}
localize() {
localize(): void {
this.name = `${this.count}x ${getPokeballName(this.pokeballType)}`;
this.description = `Receive ${getPokeballName(this.pokeballType)} x${this.count}\nCatch Rate: ${getPokeballCatchMultiplier(this.pokeballType) > -1 ? `${getPokeballCatchMultiplier(this.pokeballType)}x` : 'Certain'}`;
}

View File

@ -9,12 +9,19 @@ import { move as frMove } from '../locales/fr/move';
import { pokeball as enPokeball } from '../locales/en/pokeball';
import { pokeball as frPokeball } from '../locales/fr/pokeball';
import { pokemon as enPokemon } from '../locales/en/pokemon';
import { pokemon as frPokemon } from '../locales/fr/pokemon';
export interface SimpleTranslationEntries {
[key: string]: string
}
export interface MoveTranslationEntry {
name: string,
effect: string
}
export interface MoveTranslations {
export interface MoveTranslationEntries {
[key: string]: MoveTranslationEntry
}
@ -54,6 +61,7 @@ export function initI18n(): void {
menu: enMenu,
move: enMove,
pokeball: enPokeball,
pokemon: enPokemon,
},
it: {
menu: itMenu,
@ -62,6 +70,7 @@ export function initI18n(): void {
menu: frMenu,
move: frMove,
pokeball: frPokeball,
pokemon: frPokemon,
}
},
});
@ -74,6 +83,7 @@ declare module 'i18next' {
menu: typeof enMenu;
move: typeof enMove;
pokeball: typeof enPokeball;
pokemon: typeof enPokemon;
};
}
}