Locales for Voucher names + Voucher rewards (#1137)

* Update voucher.ts

* Update vouchers-ui-handler.ts

* Update i18n.ts

* Update config.ts

* Update config.ts

* Update config.ts

* Update config.ts

* Update config.ts

* Update config.ts

* Update config.ts

* Add files via upload

* Add files via upload

* Add files via upload

* Add files via upload

* Add files via upload

* Add files via upload

* Add files via upload
This commit is contained in:
Lugiad 2024-05-20 00:25:52 +02:00 committed by GitHub
parent 13f2cafe5e
commit 7216990d87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 118 additions and 19 deletions

View File

@ -20,6 +20,7 @@ import { tutorial } from "./tutorial";
import { weather } from "./weather"; import { weather } from "./weather";
import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { battleMessageUiHandler } from "./battle-message-ui-handler";
import { berry } from "./berry"; import { berry } from "./berry";
import { voucher } from "./voucher";
export const deConfig = { export const deConfig = {
ability: ability, ability: ability,
@ -46,4 +47,5 @@ export const deConfig = {
weather: weather, weather: weather,
battleMessageUiHandler: battleMessageUiHandler, battleMessageUiHandler: battleMessageUiHandler,
berry: berry, berry: berry,
voucher: voucher,
} }

11
src/locales/de/voucher.ts Normal file
View File

@ -0,0 +1,11 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const voucher: SimpleTranslationEntries = {
"vouchers": "Vouchers",
"eggVoucher": "Egg Voucher",
"eggVoucherPlus": "Egg Voucher Plus",
"eggVoucherPremium": "Egg Voucher Premium",
"eggVoucherGold": "Egg Voucher Gold",
"locked": "Locked",
"defeatTrainer": "Defeat {{trainerName}}"
} as const;

View File

@ -20,6 +20,7 @@ import { tutorial } from "./tutorial";
import { weather } from "./weather"; import { weather } from "./weather";
import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { battleMessageUiHandler } from "./battle-message-ui-handler";
import { berry } from "./berry"; import { berry } from "./berry";
import { voucher } from "./voucher";
export const enConfig = { export const enConfig = {
ability: ability, ability: ability,
@ -46,4 +47,5 @@ export const enConfig = {
weather: weather, weather: weather,
battleMessageUiHandler: battleMessageUiHandler, battleMessageUiHandler: battleMessageUiHandler,
berry: berry, berry: berry,
voucher: voucher,
} }

11
src/locales/en/voucher.ts Normal file
View File

@ -0,0 +1,11 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const voucher: SimpleTranslationEntries = {
"vouchers": "Vouchers",
"eggVoucher": "Egg Voucher",
"eggVoucherPlus": "Egg Voucher Plus",
"eggVoucherPremium": "Egg Voucher Premium",
"eggVoucherGold": "Egg Voucher Gold",
"locked": "Locked",
"defeatTrainer": "Defeat {{trainerName}}"
} as const;

View File

@ -20,6 +20,7 @@ import { tutorial } from "./tutorial";
import { weather } from "./weather"; import { weather } from "./weather";
import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { battleMessageUiHandler } from "./battle-message-ui-handler";
import { berry } from "./berry"; import { berry } from "./berry";
import { voucher } from "./voucher";
export const esConfig = { export const esConfig = {
ability: ability, ability: ability,
@ -46,4 +47,5 @@ export const esConfig = {
weather: weather, weather: weather,
battleMessageUiHandler: battleMessageUiHandler, battleMessageUiHandler: battleMessageUiHandler,
berry: berry, berry: berry,
voucher: voucher,
} }

11
src/locales/es/voucher.ts Normal file
View File

@ -0,0 +1,11 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const voucher: SimpleTranslationEntries = {
"vouchers": "Vouchers",
"eggVoucher": "Egg Voucher",
"eggVoucherPlus": "Egg Voucher Plus",
"eggVoucherPremium": "Egg Voucher Premium",
"eggVoucherGold": "Egg Voucher Gold",
"locked": "Locked",
"defeatTrainer": "Defeat {{trainerName}}"
} as const;

View File

@ -20,6 +20,7 @@ import { tutorial } from "./tutorial";
import { weather } from "./weather"; import { weather } from "./weather";
import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { battleMessageUiHandler } from "./battle-message-ui-handler";
import { berry } from "./berry"; import { berry } from "./berry";
import { voucher } from "./voucher";
export const frConfig = { export const frConfig = {
ability: ability, ability: ability,
@ -46,4 +47,5 @@ export const frConfig = {
weather: weather, weather: weather,
battleMessageUiHandler: battleMessageUiHandler, battleMessageUiHandler: battleMessageUiHandler,
berry: berry, berry: berry,
voucher: voucher,
} }

11
src/locales/fr/voucher.ts Normal file
View File

@ -0,0 +1,11 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const voucher: SimpleTranslationEntries = {
"vouchers": "Coupons",
"eggVoucher": "Coupon Œuf",
"eggVoucherPlus": "Coupon Œuf +",
"eggVoucherPremium": "Coupon Œuf Premium",
"eggVoucherGold": "Coupon Œuf Or",
"locked": "Verrouillé",
"defeatTrainer": "Vaincre {{trainerName}}"
} as const;

View File

@ -20,6 +20,7 @@ import { tutorial } from "./tutorial";
import { weather } from "./weather"; import { weather } from "./weather";
import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { battleMessageUiHandler } from "./battle-message-ui-handler";
import { berry } from "./berry"; import { berry } from "./berry";
import { voucher } from "./voucher";
export const itConfig = { export const itConfig = {
ability: ability, ability: ability,
@ -46,4 +47,5 @@ export const itConfig = {
weather: weather, weather: weather,
battleMessageUiHandler: battleMessageUiHandler, battleMessageUiHandler: battleMessageUiHandler,
berry: berry, berry: berry,
voucher: voucher,
} }

11
src/locales/it/voucher.ts Normal file
View File

@ -0,0 +1,11 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const voucher: SimpleTranslationEntries = {
"vouchers": "Vouchers",
"eggVoucher": "Egg Voucher",
"eggVoucherPlus": "Egg Voucher Plus",
"eggVoucherPremium": "Egg Voucher Premium",
"eggVoucherGold": "Egg Voucher Gold",
"locked": "Locked",
"defeatTrainer": "Defeat {{trainerName}}"
} as const;

View File

@ -19,6 +19,7 @@ import { titles, trainerClasses, trainerNames } from "./trainers";
import { tutorial } from "./tutorial"; import { tutorial } from "./tutorial";
import { weather } from "./weather"; import { weather } from "./weather";
import { berry } from "./berry"; import { berry } from "./berry";
import { voucher } from "./voucher";
export const ptBrConfig = { export const ptBrConfig = {
@ -45,4 +46,5 @@ export const ptBrConfig = {
weather: weather, weather: weather,
modifierType: modifierType, modifierType: modifierType,
berry: berry, berry: berry,
voucher: voucher,
} }

View File

@ -0,0 +1,11 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const voucher: SimpleTranslationEntries = {
"vouchers": "Vouchers",
"eggVoucher": "Egg Voucher",
"eggVoucherPlus": "Egg Voucher Plus",
"eggVoucherPremium": "Egg Voucher Premium",
"eggVoucherGold": "Egg Voucher Gold",
"locked": "Locked",
"defeatTrainer": "Defeat {{trainerName}}"
} as const;

View File

@ -20,6 +20,7 @@ import { tutorial } from "./tutorial";
import { weather } from "./weather"; import { weather } from "./weather";
import { battleMessageUiHandler } from "./battle-message-ui-handler"; import { battleMessageUiHandler } from "./battle-message-ui-handler";
import { berry } from "./berry"; import { berry } from "./berry";
import { voucher } from "./voucher";
export const zhCnConfig = { export const zhCnConfig = {
@ -47,4 +48,5 @@ export const zhCnConfig = {
weather: weather, weather: weather,
battleMessageUiHandler: battleMessageUiHandler, battleMessageUiHandler: battleMessageUiHandler,
berry: berry, berry: berry,
voucher: voucher,
} }

View File

@ -0,0 +1,11 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const voucher: SimpleTranslationEntries = {
"vouchers": "Vouchers",
"eggVoucher": "Egg Voucher",
"eggVoucherPlus": "Egg Voucher Plus",
"eggVoucherPremium": "Egg Voucher Premium",
"eggVoucherGold": "Egg Voucher Gold",
"locked": "Locked",
"defeatTrainer": "Defeat {{trainerName}}"
} as const;

View File

@ -153,6 +153,7 @@ declare module 'i18next' {
modifierType: ModifierTypeTranslationEntries; modifierType: ModifierTypeTranslationEntries;
battleMessageUiHandler: SimpleTranslationEntries; battleMessageUiHandler: SimpleTranslationEntries;
berry: BerryTranslationEntries; berry: BerryTranslationEntries;
voucher: SimpleTranslationEntries;
}; };
} }
} }

View File

@ -2,6 +2,7 @@ import BattleScene from "../battle-scene";
import { TrainerType } from "../data/enums/trainer-type"; import { TrainerType } from "../data/enums/trainer-type";
import { ModifierTier } from "../modifier/modifier-tier"; import { ModifierTier } from "../modifier/modifier-tier";
import { Achv, AchvTier, achvs } from "./achv"; import { Achv, AchvTier, achvs } from "./achv";
import i18next from '../plugins/i18n';
export enum VoucherType { export enum VoucherType {
REGULAR, REGULAR,
@ -52,13 +53,13 @@ export class Voucher {
export function getVoucherTypeName(voucherType: VoucherType): string { export function getVoucherTypeName(voucherType: VoucherType): string {
switch (voucherType) { switch (voucherType) {
case VoucherType.REGULAR: case VoucherType.REGULAR:
return 'Egg Voucher'; return i18next.t("voucher:eggVoucher");
case VoucherType.PLUS: case VoucherType.PLUS:
return 'Egg Voucher Plus'; return i18next.t("voucher:eggVoucherPlus");
case VoucherType.PREMIUM: case VoucherType.PREMIUM:
return 'Egg Voucher Premium'; return i18next.t("voucher:eggVoucherPremium");
case VoucherType.GOLDEN: case VoucherType.GOLDEN:
return 'Egg Voucher Gold'; return i18next.t("voucher:eggVoucherGold");
} }
} }
@ -75,9 +76,8 @@ export function getVoucherTypeIcon(voucherType: VoucherType): string {
} }
} }
export interface Vouchers { export interface Vouchers {
[key: string]: Voucher [key: string]: Voucher;
} }
export const vouchers: Vouchers = {}; export const vouchers: Vouchers = {};
@ -87,6 +87,8 @@ const voucherAchvs: Achv[] = [ achvs.CLASSIC_VICTORY ];
{ {
(function() { (function() {
import('../data/trainer-config').then(tc => { import('../data/trainer-config').then(tc => {
const trainerConfigs = tc.trainerConfigs;
for (let achv of voucherAchvs) { for (let achv of voucherAchvs) {
const voucherType = achv.score >= 150 const voucherType = achv.score >= 150
? VoucherType.GOLDEN ? VoucherType.GOLDEN
@ -98,7 +100,6 @@ const voucherAchvs: Achv[] = [ achvs.CLASSIC_VICTORY ];
vouchers[achv.id] = new Voucher(voucherType, achv.description); vouchers[achv.id] = new Voucher(voucherType, achv.description);
} }
const trainerConfigs = tc.trainerConfigs;
const bossTrainerTypes = Object.keys(trainerConfigs) const bossTrainerTypes = Object.keys(trainerConfigs)
.filter(tt => trainerConfigs[tt].isBoss && trainerConfigs[tt].getDerivedType() !== TrainerType.RIVAL); .filter(tt => trainerConfigs[tt].isBoss && trainerConfigs[tt].getDerivedType() !== TrainerType.RIVAL);
@ -107,12 +108,17 @@ const voucherAchvs: Achv[] = [ achvs.CLASSIC_VICTORY ];
? VoucherType.PLUS ? VoucherType.PLUS
: VoucherType.PREMIUM; : VoucherType.PREMIUM;
const key = TrainerType[trainerType]; const key = TrainerType[trainerType];
vouchers[key] = new Voucher(voucherType, `Defeat ${trainerConfigs[trainerType].name}`); const trainerName = trainerConfigs[trainerType].name;
vouchers[key] = new Voucher(
voucherType,
i18next.t("voucher:defeatTrainer", { trainerName })
);
} }
const voucherKeys = Object.keys(vouchers); const voucherKeys = Object.keys(vouchers);
for (let k of voucherKeys) for (let k of voucherKeys) {
vouchers[k].id = k; vouchers[k].id = k;
}
}); });
})(); })();
} }

View File

@ -5,6 +5,7 @@ import { TextStyle, addTextObject } from "./text";
import { Mode } from "./ui"; import { Mode } from "./ui";
import { addWindow } from "./ui-theme"; import { addWindow } from "./ui-theme";
import {Button} from "../enums/buttons"; import {Button} from "../enums/buttons";
import i18next from '../plugins/i18n';
const itemRows = 4; const itemRows = 4;
const itemCols = 17; const itemCols = 17;
@ -40,7 +41,7 @@ export default class VouchersUiHandler extends MessageUiHandler {
const headerBg = addWindow(this.scene, 0, 0, (this.scene.game.canvas.width / 6) - 2, 24); const headerBg = addWindow(this.scene, 0, 0, (this.scene.game.canvas.width / 6) - 2, 24);
headerBg.setOrigin(0, 0); headerBg.setOrigin(0, 0);
const headerText = addTextObject(this.scene, 0, 0, 'Vouchers', TextStyle.SETTINGS_LABEL); const headerText = addTextObject(this.scene, 0, 0, i18next.t("voucher:vouchers"), TextStyle.SETTINGS_LABEL);
headerText.setOrigin(0, 0); headerText.setOrigin(0, 0);
headerText.setPositionRelative(headerBg, 8, 4); headerText.setPositionRelative(headerBg, 8, 4);
@ -127,7 +128,7 @@ export default class VouchersUiHandler extends MessageUiHandler {
this.titleText.setText(getVoucherTypeName(voucher.voucherType)); this.titleText.setText(getVoucherTypeName(voucher.voucherType));
this.showText(voucher.description); this.showText(voucher.description);
this.unlockText.setText(unlocked ? new Date(voucherUnlocks[voucher.id]).toLocaleDateString() : 'Locked'); this.unlockText.setText(unlocked ? new Date(voucherUnlocks[voucher.id]).toLocaleDateString() : i18next.t("voucher:locked"));
} }
processInput(button: Button): boolean { processInput(button: Button): boolean {