mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-25 08:16:04 +00:00
[Refactor][Localization] Better handling for StatusEffect.NONE
with i18n (#4405)
* remove: `StatusEffect.NONE` from displaying any messages even thougn this case will never occur, by code definition it should be covered * remove: obsolete `statusEffect:none.` translation keys * fix: status-effect test * chore: undo overrides commit (whops)
This commit is contained in:
parent
254ffcf6d6
commit
9af89414b9
@ -44,6 +44,10 @@ function getStatusEffectMessageKey(statusEffect: StatusEffect | undefined): stri
|
||||
}
|
||||
|
||||
export function getStatusEffectObtainText(statusEffect: StatusEffect | undefined, pokemonNameWithAffix: string, sourceText?: string): string {
|
||||
if (statusEffect === StatusEffect.NONE) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (!sourceText) {
|
||||
const i18nKey = `${getStatusEffectMessageKey(statusEffect)}.obtain`as ParseKeys;
|
||||
return i18next.t(i18nKey, { pokemonNameWithAffix: pokemonNameWithAffix });
|
||||
@ -53,21 +57,33 @@ export function getStatusEffectObtainText(statusEffect: StatusEffect | undefined
|
||||
}
|
||||
|
||||
export function getStatusEffectActivationText(statusEffect: StatusEffect, pokemonNameWithAffix: string): string {
|
||||
if (statusEffect === StatusEffect.NONE) {
|
||||
return "";
|
||||
}
|
||||
const i18nKey = `${getStatusEffectMessageKey(statusEffect)}.activation` as ParseKeys;
|
||||
return i18next.t(i18nKey, { pokemonNameWithAffix: pokemonNameWithAffix });
|
||||
}
|
||||
|
||||
export function getStatusEffectOverlapText(statusEffect: StatusEffect, pokemonNameWithAffix: string): string {
|
||||
if (statusEffect === StatusEffect.NONE) {
|
||||
return "";
|
||||
}
|
||||
const i18nKey = `${getStatusEffectMessageKey(statusEffect)}.overlap` as ParseKeys;
|
||||
return i18next.t(i18nKey, { pokemonNameWithAffix: pokemonNameWithAffix });
|
||||
}
|
||||
|
||||
export function getStatusEffectHealText(statusEffect: StatusEffect, pokemonNameWithAffix: string): string {
|
||||
if (statusEffect === StatusEffect.NONE) {
|
||||
return "";
|
||||
}
|
||||
const i18nKey = `${getStatusEffectMessageKey(statusEffect)}.heal` as ParseKeys;
|
||||
return i18next.t(i18nKey, { pokemonNameWithAffix: pokemonNameWithAffix });
|
||||
}
|
||||
|
||||
export function getStatusEffectDescriptor(statusEffect: StatusEffect): string {
|
||||
if (statusEffect === StatusEffect.NONE) {
|
||||
return "";
|
||||
}
|
||||
const i18nKey = `${getStatusEffectMessageKey(statusEffect)}.description` as ParseKeys;
|
||||
return i18next.t(i18nKey);
|
||||
}
|
||||
|
@ -1,12 +1,6 @@
|
||||
{
|
||||
"none": {
|
||||
"name": "None",
|
||||
"description": "",
|
||||
"obtain": "",
|
||||
"obtainSource": "",
|
||||
"activation": "",
|
||||
"overlap": "",
|
||||
"heal": ""
|
||||
"name": "None"
|
||||
},
|
||||
"poison": {
|
||||
"name": "Gift",
|
||||
|
@ -1,12 +1,6 @@
|
||||
{
|
||||
"none": {
|
||||
"name": "None",
|
||||
"description": "",
|
||||
"obtain": "",
|
||||
"obtainSource": "",
|
||||
"activation": "",
|
||||
"overlap": "",
|
||||
"heal": ""
|
||||
"name": "None"
|
||||
},
|
||||
"poison": {
|
||||
"name": "Poison",
|
||||
|
@ -1,12 +1,6 @@
|
||||
{
|
||||
"none": {
|
||||
"name": "Ninguno",
|
||||
"description": "",
|
||||
"obtain": "",
|
||||
"obtainSource": "",
|
||||
"activation": "",
|
||||
"overlap": "",
|
||||
"heal": ""
|
||||
"name": "Ninguno"
|
||||
},
|
||||
"poison": {
|
||||
"name": "Envenenamiento",
|
||||
|
@ -1,12 +1,6 @@
|
||||
{
|
||||
"none": {
|
||||
"name": "Aucun",
|
||||
"description": "",
|
||||
"obtain": "",
|
||||
"obtainSource": "",
|
||||
"activation": "",
|
||||
"overlap": "",
|
||||
"heal": ""
|
||||
"name": "Aucun"
|
||||
},
|
||||
"poison": {
|
||||
"name": "Empoisonnement",
|
||||
|
@ -1,11 +1,5 @@
|
||||
{
|
||||
"none": {
|
||||
"name": "None",
|
||||
"description": "",
|
||||
"obtain": "",
|
||||
"obtainSource": "",
|
||||
"activation": "",
|
||||
"overlap": "",
|
||||
"heal": ""
|
||||
"name": "None"
|
||||
}
|
||||
}
|
@ -1,12 +1,6 @@
|
||||
{
|
||||
"none": {
|
||||
"name": "なし",
|
||||
"description": "",
|
||||
"obtain": "",
|
||||
"obtainSource": "",
|
||||
"activation": "",
|
||||
"overlap": "",
|
||||
"heal": ""
|
||||
"name": "なし"
|
||||
},
|
||||
"poison": {
|
||||
"name": "どく",
|
||||
|
@ -1,12 +1,6 @@
|
||||
{
|
||||
"none": {
|
||||
"name": "없음",
|
||||
"description": "",
|
||||
"obtain": "",
|
||||
"obtainSource": "",
|
||||
"activation": "",
|
||||
"overlap": "",
|
||||
"heal": ""
|
||||
"name": "없음"
|
||||
},
|
||||
"poison": {
|
||||
"name": "독",
|
||||
|
@ -1,12 +1,6 @@
|
||||
{
|
||||
"none": {
|
||||
"name": "Nenhum",
|
||||
"description": "",
|
||||
"obtain": "",
|
||||
"obtainSource": "",
|
||||
"activation": "",
|
||||
"overlap": "",
|
||||
"heal": ""
|
||||
"name": "Nenhum"
|
||||
},
|
||||
"poison": {
|
||||
"name": "Envenenamento",
|
||||
|
@ -1,12 +1,6 @@
|
||||
{
|
||||
"none": {
|
||||
"name": "无",
|
||||
"description": "",
|
||||
"obtain": "",
|
||||
"obtainSource": "",
|
||||
"activation": "",
|
||||
"overlap": "",
|
||||
"heal": ""
|
||||
"name": "无"
|
||||
},
|
||||
"poison": {
|
||||
"name": "中毒",
|
||||
|
@ -1,12 +1,6 @@
|
||||
{
|
||||
"none": {
|
||||
"name": "無",
|
||||
"description": "",
|
||||
"obtain": "",
|
||||
"obtainSource": "",
|
||||
"activation": "",
|
||||
"overlap": "",
|
||||
"heal": ""
|
||||
"name": "無"
|
||||
},
|
||||
"poison": {
|
||||
"name": "中毒",
|
||||
|
@ -18,44 +18,45 @@ describe("status-effect", () => {
|
||||
mockI18next();
|
||||
|
||||
const text = getStatusEffectObtainText(statusEffect, pokemonName);
|
||||
expect(text).toBe("statusEffect:none.obtain");
|
||||
console.log("text:", text);
|
||||
expect(text).toBe("");
|
||||
|
||||
const emptySourceText = getStatusEffectObtainText(statusEffect, pokemonName, "");
|
||||
expect(emptySourceText).toBe("statusEffect:none.obtain");
|
||||
expect(emptySourceText).toBe("");
|
||||
});
|
||||
|
||||
it("should return the source-obtain text", () => {
|
||||
mockI18next();
|
||||
|
||||
const text = getStatusEffectObtainText(statusEffect, pokemonName, sourceText);
|
||||
expect(text).toBe("statusEffect:none.obtainSource");
|
||||
expect(text).toBe("");
|
||||
|
||||
const emptySourceText = getStatusEffectObtainText(statusEffect, pokemonName, "");
|
||||
expect(emptySourceText).not.toBe("statusEffect:none.obtainSource");
|
||||
expect(emptySourceText).toBe("");
|
||||
});
|
||||
|
||||
it("should return the activation text", () => {
|
||||
mockI18next();
|
||||
const text = getStatusEffectActivationText(statusEffect, pokemonName);
|
||||
expect(text).toBe("statusEffect:none.activation");
|
||||
expect(text).toBe("");
|
||||
});
|
||||
|
||||
it("should return the overlap text", () => {
|
||||
mockI18next();
|
||||
const text = getStatusEffectOverlapText(statusEffect, pokemonName);
|
||||
expect(text).toBe("statusEffect:none.overlap");
|
||||
expect(text).toBe("");
|
||||
});
|
||||
|
||||
it("should return the heal text", () => {
|
||||
mockI18next();
|
||||
const text = getStatusEffectHealText(statusEffect, pokemonName);
|
||||
expect(text).toBe("statusEffect:none.heal");
|
||||
expect(text).toBe("");
|
||||
});
|
||||
|
||||
it("should return the descriptor", () => {
|
||||
mockI18next();
|
||||
const text = getStatusEffectDescriptor(statusEffect);
|
||||
expect(text).toBe("statusEffect:none.description");
|
||||
expect(text).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user