From 250142083a21214d6cd4823239809c5741d215a9 Mon Sep 17 00:00:00 2001 From: FanHua Date: Fri, 17 May 2024 18:09:08 +0800 Subject: [PATCH] Implements localization for BerryType (#1007) --- src/data/berry.ts | 29 ++++------------------ src/locales/de/berry.ts | 48 +++++++++++++++++++++++++++++++++++++ src/locales/de/config.ts | 2 ++ src/locales/en/berry.ts | 48 +++++++++++++++++++++++++++++++++++++ src/locales/en/config.ts | 3 +++ src/locales/es/berry.ts | 48 +++++++++++++++++++++++++++++++++++++ src/locales/es/config.ts | 2 ++ src/locales/fr/berry.ts | 48 +++++++++++++++++++++++++++++++++++++ src/locales/fr/config.ts | 2 ++ src/locales/it/berry.ts | 48 +++++++++++++++++++++++++++++++++++++ src/locales/it/config.ts | 2 ++ src/locales/pt_BR/berry.ts | 48 +++++++++++++++++++++++++++++++++++++ src/locales/pt_BR/config.ts | 2 ++ src/locales/zh_CN/berry.ts | 48 +++++++++++++++++++++++++++++++++++++ src/locales/zh_CN/config.ts | 2 ++ src/plugins/i18n.ts | 10 ++++++++ 16 files changed, 366 insertions(+), 24 deletions(-) create mode 100644 src/locales/de/berry.ts create mode 100644 src/locales/en/berry.ts create mode 100644 src/locales/es/berry.ts create mode 100644 src/locales/fr/berry.ts create mode 100644 src/locales/it/berry.ts create mode 100644 src/locales/pt_BR/berry.ts create mode 100644 src/locales/zh_CN/berry.ts diff --git a/src/data/berry.ts b/src/data/berry.ts index 96b50caa932..1521f3488ef 100644 --- a/src/data/berry.ts +++ b/src/data/berry.ts @@ -7,6 +7,7 @@ import { BattlerTagType } from "./enums/battler-tag-type"; import { getStatusEffectHealText } from "./status-effect"; import * as Utils from "../utils"; import { DoubleBerryEffectAbAttr, ReduceBerryUseThresholdAbAttr, applyAbAttrs } from "./ability"; +import i18next from '../plugins/i18n'; export enum BerryType { SITRUS, @@ -22,32 +23,12 @@ export enum BerryType { LEPPA } -export function getBerryName(berryType: BerryType) { - return `${Utils.toReadableString(BerryType[berryType])} Berry`; +export function getBerryName(berryType: BerryType): string { + return i18next.t(`berry:${BerryType[berryType]}.name`); } -export function getBerryEffectDescription(berryType: BerryType) { - switch (berryType) { - case BerryType.SITRUS: - return 'Restores 25% HP if HP is below 50%'; - case BerryType.LUM: - return 'Cures any non-volatile status condition and confusion'; - case BerryType.ENIGMA: - return 'Restores 25% HP if hit by a super effective move'; - case BerryType.LIECHI: - case BerryType.GANLON: - case BerryType.PETAYA: - case BerryType.APICOT: - case BerryType.SALAC: - const stat = (berryType - BerryType.LIECHI) as BattleStat; - return `Raises ${getBattleStatName(stat)} if HP is below 25%`; - case BerryType.LANSAT: - return 'Raises critical hit ratio if HP is below 25%'; - case BerryType.STARF: - return 'Sharply raises a random stat if HP is below 25%'; - case BerryType.LEPPA: - return 'Restores 10 PP to a move if its PP reaches 0'; - } +export function getBerryEffectDescription(berryType: BerryType): string { + return i18next.t(`berry:${BerryType[berryType]}.effect`); } export type BerryPredicate = (pokemon: Pokemon) => boolean; diff --git a/src/locales/de/berry.ts b/src/locales/de/berry.ts new file mode 100644 index 00000000000..8c8bc5ee280 --- /dev/null +++ b/src/locales/de/berry.ts @@ -0,0 +1,48 @@ +import { BerryTranslationEntries } from "#app/plugins/i18n"; + +export const berry: BerryTranslationEntries = { + "SITRUS": { + name: "Sitrus Berry", + effect: "Restores 25% HP if HP is below 50%", + }, + "LUM": { + name: "Lum Berry", + effect: "Cures any non-volatile status condition and confusion", + }, + "ENIGMA": { + name: "Enigma Berry", + effect: "Restores 25% HP if hit by a super effective move", + }, + "LIECHI": { + name: "Liechi Berry", + effect: "Raises Attack if HP is below 25%", + }, + "GANLON": { + name: "Ganlon Berry", + effect: "Raises Defense if HP is below 25%", + }, + "PETAYA": { + name: "Petaya Berry", + effect: "Raises Sp. Atk if HP is below 25%", + }, + "APICOT": { + name: "Apicot Berry", + effect: "Raises Sp. Def if HP is below 25%", + }, + "SALAC": { + name: "Salac Berry", + effect: "Raises Speed if HP is below 25%", + }, + "LANSAT": { + name: "Lansat Berry", + effect: "Raises critical hit ratio if HP is below 25%", + }, + "STARF": { + name: "Starf Berry", + effect: "Sharply raises a random stat if HP is below 25%", + }, + "LEPPA": { + name: "Leppa Berry", + effect: "Restores 10 PP to a move if its PP reaches 0", + }, +} as const; \ No newline at end of file diff --git a/src/locales/de/config.ts b/src/locales/de/config.ts index 44bd5a66f1a..9ff1699778b 100644 --- a/src/locales/de/config.ts +++ b/src/locales/de/config.ts @@ -18,6 +18,7 @@ import { starterSelectUiHandler } from "./starter-select-ui-handler"; import { titles, trainerClasses, trainerNames } from "./trainers"; import { tutorial } from "./tutorial"; import { weather } from "./weather"; +import { berry } from "./berry"; export const deConfig = { @@ -43,4 +44,5 @@ export const deConfig = { trainerNames: trainerNames, tutorial: tutorial, weather: weather, + berry: berry, } diff --git a/src/locales/en/berry.ts b/src/locales/en/berry.ts new file mode 100644 index 00000000000..8c8bc5ee280 --- /dev/null +++ b/src/locales/en/berry.ts @@ -0,0 +1,48 @@ +import { BerryTranslationEntries } from "#app/plugins/i18n"; + +export const berry: BerryTranslationEntries = { + "SITRUS": { + name: "Sitrus Berry", + effect: "Restores 25% HP if HP is below 50%", + }, + "LUM": { + name: "Lum Berry", + effect: "Cures any non-volatile status condition and confusion", + }, + "ENIGMA": { + name: "Enigma Berry", + effect: "Restores 25% HP if hit by a super effective move", + }, + "LIECHI": { + name: "Liechi Berry", + effect: "Raises Attack if HP is below 25%", + }, + "GANLON": { + name: "Ganlon Berry", + effect: "Raises Defense if HP is below 25%", + }, + "PETAYA": { + name: "Petaya Berry", + effect: "Raises Sp. Atk if HP is below 25%", + }, + "APICOT": { + name: "Apicot Berry", + effect: "Raises Sp. Def if HP is below 25%", + }, + "SALAC": { + name: "Salac Berry", + effect: "Raises Speed if HP is below 25%", + }, + "LANSAT": { + name: "Lansat Berry", + effect: "Raises critical hit ratio if HP is below 25%", + }, + "STARF": { + name: "Starf Berry", + effect: "Sharply raises a random stat if HP is below 25%", + }, + "LEPPA": { + name: "Leppa Berry", + effect: "Restores 10 PP to a move if its PP reaches 0", + }, +} as const; \ No newline at end of file diff --git a/src/locales/en/config.ts b/src/locales/en/config.ts index 2962633e26a..b2dfe9c9b4c 100644 --- a/src/locales/en/config.ts +++ b/src/locales/en/config.ts @@ -18,6 +18,8 @@ import { starterSelectUiHandler } from "./starter-select-ui-handler"; import { titles, trainerClasses, trainerNames } from "./trainers"; import { tutorial } from "./tutorial"; import { weather } from "./weather"; +import { berry } from "./berry"; + export const enConfig = { ability: ability, @@ -42,4 +44,5 @@ export const enConfig = { trainerNames: trainerNames, tutorial: tutorial, weather: weather, + berry: berry, } diff --git a/src/locales/es/berry.ts b/src/locales/es/berry.ts new file mode 100644 index 00000000000..8c8bc5ee280 --- /dev/null +++ b/src/locales/es/berry.ts @@ -0,0 +1,48 @@ +import { BerryTranslationEntries } from "#app/plugins/i18n"; + +export const berry: BerryTranslationEntries = { + "SITRUS": { + name: "Sitrus Berry", + effect: "Restores 25% HP if HP is below 50%", + }, + "LUM": { + name: "Lum Berry", + effect: "Cures any non-volatile status condition and confusion", + }, + "ENIGMA": { + name: "Enigma Berry", + effect: "Restores 25% HP if hit by a super effective move", + }, + "LIECHI": { + name: "Liechi Berry", + effect: "Raises Attack if HP is below 25%", + }, + "GANLON": { + name: "Ganlon Berry", + effect: "Raises Defense if HP is below 25%", + }, + "PETAYA": { + name: "Petaya Berry", + effect: "Raises Sp. Atk if HP is below 25%", + }, + "APICOT": { + name: "Apicot Berry", + effect: "Raises Sp. Def if HP is below 25%", + }, + "SALAC": { + name: "Salac Berry", + effect: "Raises Speed if HP is below 25%", + }, + "LANSAT": { + name: "Lansat Berry", + effect: "Raises critical hit ratio if HP is below 25%", + }, + "STARF": { + name: "Starf Berry", + effect: "Sharply raises a random stat if HP is below 25%", + }, + "LEPPA": { + name: "Leppa Berry", + effect: "Restores 10 PP to a move if its PP reaches 0", + }, +} as const; \ No newline at end of file diff --git a/src/locales/es/config.ts b/src/locales/es/config.ts index a986bbfc75c..61b01cfa6b5 100644 --- a/src/locales/es/config.ts +++ b/src/locales/es/config.ts @@ -18,6 +18,7 @@ import { starterSelectUiHandler } from "./starter-select-ui-handler"; import { titles, trainerClasses, trainerNames } from "./trainers"; import { tutorial } from "./tutorial"; import { weather } from "./weather"; +import { berry } from "./berry"; export const esConfig = { @@ -43,4 +44,5 @@ export const esConfig = { trainerNames: trainerNames, tutorial: tutorial, weather: weather, + berry: berry, } diff --git a/src/locales/fr/berry.ts b/src/locales/fr/berry.ts new file mode 100644 index 00000000000..8c8bc5ee280 --- /dev/null +++ b/src/locales/fr/berry.ts @@ -0,0 +1,48 @@ +import { BerryTranslationEntries } from "#app/plugins/i18n"; + +export const berry: BerryTranslationEntries = { + "SITRUS": { + name: "Sitrus Berry", + effect: "Restores 25% HP if HP is below 50%", + }, + "LUM": { + name: "Lum Berry", + effect: "Cures any non-volatile status condition and confusion", + }, + "ENIGMA": { + name: "Enigma Berry", + effect: "Restores 25% HP if hit by a super effective move", + }, + "LIECHI": { + name: "Liechi Berry", + effect: "Raises Attack if HP is below 25%", + }, + "GANLON": { + name: "Ganlon Berry", + effect: "Raises Defense if HP is below 25%", + }, + "PETAYA": { + name: "Petaya Berry", + effect: "Raises Sp. Atk if HP is below 25%", + }, + "APICOT": { + name: "Apicot Berry", + effect: "Raises Sp. Def if HP is below 25%", + }, + "SALAC": { + name: "Salac Berry", + effect: "Raises Speed if HP is below 25%", + }, + "LANSAT": { + name: "Lansat Berry", + effect: "Raises critical hit ratio if HP is below 25%", + }, + "STARF": { + name: "Starf Berry", + effect: "Sharply raises a random stat if HP is below 25%", + }, + "LEPPA": { + name: "Leppa Berry", + effect: "Restores 10 PP to a move if its PP reaches 0", + }, +} as const; \ No newline at end of file diff --git a/src/locales/fr/config.ts b/src/locales/fr/config.ts index 8de3e186d59..ef8f8bb7538 100644 --- a/src/locales/fr/config.ts +++ b/src/locales/fr/config.ts @@ -18,6 +18,7 @@ import { starterSelectUiHandler } from "./starter-select-ui-handler"; import { titles, trainerClasses, trainerNames } from "./trainers"; import { tutorial } from "./tutorial"; import { weather } from "./weather"; +import { berry } from "./berry"; export const frConfig = { @@ -43,5 +44,6 @@ export const frConfig = { trainerNames: trainerNames, tutorial: tutorial, weather: weather, + berry: berry, } diff --git a/src/locales/it/berry.ts b/src/locales/it/berry.ts new file mode 100644 index 00000000000..8c8bc5ee280 --- /dev/null +++ b/src/locales/it/berry.ts @@ -0,0 +1,48 @@ +import { BerryTranslationEntries } from "#app/plugins/i18n"; + +export const berry: BerryTranslationEntries = { + "SITRUS": { + name: "Sitrus Berry", + effect: "Restores 25% HP if HP is below 50%", + }, + "LUM": { + name: "Lum Berry", + effect: "Cures any non-volatile status condition and confusion", + }, + "ENIGMA": { + name: "Enigma Berry", + effect: "Restores 25% HP if hit by a super effective move", + }, + "LIECHI": { + name: "Liechi Berry", + effect: "Raises Attack if HP is below 25%", + }, + "GANLON": { + name: "Ganlon Berry", + effect: "Raises Defense if HP is below 25%", + }, + "PETAYA": { + name: "Petaya Berry", + effect: "Raises Sp. Atk if HP is below 25%", + }, + "APICOT": { + name: "Apicot Berry", + effect: "Raises Sp. Def if HP is below 25%", + }, + "SALAC": { + name: "Salac Berry", + effect: "Raises Speed if HP is below 25%", + }, + "LANSAT": { + name: "Lansat Berry", + effect: "Raises critical hit ratio if HP is below 25%", + }, + "STARF": { + name: "Starf Berry", + effect: "Sharply raises a random stat if HP is below 25%", + }, + "LEPPA": { + name: "Leppa Berry", + effect: "Restores 10 PP to a move if its PP reaches 0", + }, +} as const; \ No newline at end of file diff --git a/src/locales/it/config.ts b/src/locales/it/config.ts index 6892c9c8cad..3d8d9b0e4b7 100644 --- a/src/locales/it/config.ts +++ b/src/locales/it/config.ts @@ -18,6 +18,7 @@ import { starterSelectUiHandler } from "./starter-select-ui-handler"; import { titles, trainerClasses, trainerNames } from "./trainers"; import { tutorial } from "./tutorial"; import { weather } from "./weather"; +import { berry } from "./berry"; export const itConfig = { @@ -43,4 +44,5 @@ export const itConfig = { trainerNames: trainerNames, tutorial: tutorial, weather: weather, + berry: berry, } diff --git a/src/locales/pt_BR/berry.ts b/src/locales/pt_BR/berry.ts new file mode 100644 index 00000000000..8c8bc5ee280 --- /dev/null +++ b/src/locales/pt_BR/berry.ts @@ -0,0 +1,48 @@ +import { BerryTranslationEntries } from "#app/plugins/i18n"; + +export const berry: BerryTranslationEntries = { + "SITRUS": { + name: "Sitrus Berry", + effect: "Restores 25% HP if HP is below 50%", + }, + "LUM": { + name: "Lum Berry", + effect: "Cures any non-volatile status condition and confusion", + }, + "ENIGMA": { + name: "Enigma Berry", + effect: "Restores 25% HP if hit by a super effective move", + }, + "LIECHI": { + name: "Liechi Berry", + effect: "Raises Attack if HP is below 25%", + }, + "GANLON": { + name: "Ganlon Berry", + effect: "Raises Defense if HP is below 25%", + }, + "PETAYA": { + name: "Petaya Berry", + effect: "Raises Sp. Atk if HP is below 25%", + }, + "APICOT": { + name: "Apicot Berry", + effect: "Raises Sp. Def if HP is below 25%", + }, + "SALAC": { + name: "Salac Berry", + effect: "Raises Speed if HP is below 25%", + }, + "LANSAT": { + name: "Lansat Berry", + effect: "Raises critical hit ratio if HP is below 25%", + }, + "STARF": { + name: "Starf Berry", + effect: "Sharply raises a random stat if HP is below 25%", + }, + "LEPPA": { + name: "Leppa Berry", + effect: "Restores 10 PP to a move if its PP reaches 0", + }, +} as const; \ No newline at end of file diff --git a/src/locales/pt_BR/config.ts b/src/locales/pt_BR/config.ts index af714a36316..157df19a80b 100644 --- a/src/locales/pt_BR/config.ts +++ b/src/locales/pt_BR/config.ts @@ -14,6 +14,7 @@ import { pokemonStat } from "./pokemon-stat"; import { starterSelectUiHandler } from "./starter-select-ui-handler"; import { tutorial } from "./tutorial"; import { weather } from "./weather"; +import { berry } from "./berry"; export const ptBrConfig = { @@ -33,4 +34,5 @@ export const ptBrConfig = { growth: growth, weather: weather, modifierType: modifierType, + berry: berry, } \ No newline at end of file diff --git a/src/locales/zh_CN/berry.ts b/src/locales/zh_CN/berry.ts new file mode 100644 index 00000000000..8c8bc5ee280 --- /dev/null +++ b/src/locales/zh_CN/berry.ts @@ -0,0 +1,48 @@ +import { BerryTranslationEntries } from "#app/plugins/i18n"; + +export const berry: BerryTranslationEntries = { + "SITRUS": { + name: "Sitrus Berry", + effect: "Restores 25% HP if HP is below 50%", + }, + "LUM": { + name: "Lum Berry", + effect: "Cures any non-volatile status condition and confusion", + }, + "ENIGMA": { + name: "Enigma Berry", + effect: "Restores 25% HP if hit by a super effective move", + }, + "LIECHI": { + name: "Liechi Berry", + effect: "Raises Attack if HP is below 25%", + }, + "GANLON": { + name: "Ganlon Berry", + effect: "Raises Defense if HP is below 25%", + }, + "PETAYA": { + name: "Petaya Berry", + effect: "Raises Sp. Atk if HP is below 25%", + }, + "APICOT": { + name: "Apicot Berry", + effect: "Raises Sp. Def if HP is below 25%", + }, + "SALAC": { + name: "Salac Berry", + effect: "Raises Speed if HP is below 25%", + }, + "LANSAT": { + name: "Lansat Berry", + effect: "Raises critical hit ratio if HP is below 25%", + }, + "STARF": { + name: "Starf Berry", + effect: "Sharply raises a random stat if HP is below 25%", + }, + "LEPPA": { + name: "Leppa Berry", + effect: "Restores 10 PP to a move if its PP reaches 0", + }, +} as const; \ No newline at end of file diff --git a/src/locales/zh_CN/config.ts b/src/locales/zh_CN/config.ts index 19afba381b8..69f07a4f1a7 100644 --- a/src/locales/zh_CN/config.ts +++ b/src/locales/zh_CN/config.ts @@ -18,6 +18,7 @@ import { starterSelectUiHandler } from "./starter-select-ui-handler"; import { titles, trainerClasses, trainerNames } from "./trainers"; import { tutorial } from "./tutorial"; import { weather } from "./weather"; +import { berry } from "./berry"; export const zhCnConfig = { @@ -43,4 +44,5 @@ export const zhCnConfig = { trainerNames: trainerNames, tutorial: tutorial, weather: weather, + berry: berry, } diff --git a/src/plugins/i18n.ts b/src/plugins/i18n.ts index 807e1a1b550..30cc4bfcac2 100644 --- a/src/plugins/i18n.ts +++ b/src/plugins/i18n.ts @@ -46,6 +46,15 @@ export interface ModifierTypeTranslationEntries { TeraType: SimpleTranslationEntries, } +export interface BerryTranslationEntry { + name: string, + effect: string +} + +export interface BerryTranslationEntries { + [key: string]: BerryTranslationEntry +} + export interface Localizable { localize(): void; } @@ -139,6 +148,7 @@ declare module 'i18next' { egg: SimpleTranslationEntries; weather: SimpleTranslationEntries; modifierType: ModifierTypeTranslationEntries; + berry: BerryTranslationEntries; }; } }