From 0a01b6f0864a4992674fad21d859f943eecc10ef Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Fri, 11 Oct 2024 09:16:36 -0700 Subject: [PATCH] Rename `verifyLang` to `hasAllLocalizedSprite` and update tsdoc --- src/loading-scene.ts | 2 +- src/utils.ts | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/loading-scene.ts b/src/loading-scene.ts index d6512486d0e..632289686f8 100644 --- a/src/loading-scene.ts +++ b/src/loading-scene.ts @@ -230,7 +230,7 @@ export class LoadingScene extends SceneBase { // Get current lang and load the types atlas for it. English will only load types while all other languages will load types and types_ const lang = i18next.resolvedLanguage; if (lang !== "en") { - if (Utils.verifyLang(lang)) { + if (Utils.hasAllLocalizedSprites(lang)) { this.loadAtlas(`statuses_${lang}`, ""); this.loadAtlas(`types_${lang}`, ""); } else { diff --git a/src/utils.ts b/src/utils.ts index ffce290fc0f..ed07aa4ab2d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -466,14 +466,13 @@ export function hslToHex(h: number, s: number, l: number): string { } /** - * This function returns `true` if the current lang is available for some functions. + * This function returns `true` if all localized images used by the game have been added for the given language. + * * If the lang is not in the function, it usually means that lang is going to use the default english version * - * This function is used in: - * - `summary-ui-handler.ts`: If the lang is not available, it'll use `types.json` (english). - * English itself counts as not available + * English itself counts as not available */ -export function verifyLang(lang?: string): boolean { +export function hasAllLocalizedSprites(lang?: string): boolean { // IMPORTANT - ONLY ADD YOUR LANG HERE IF YOU'VE ALREADY ADDED ALL THE NECESSARY IMAGES if (!lang) { lang = i18next.resolvedLanguage; @@ -602,7 +601,7 @@ export function toDmgValue(value: number, minValue: number = 1) { * @returns the localized sprite key */ export function getLocalizedSpriteKey(baseKey: string) { - return `${baseKey}${verifyLang(i18next.resolvedLanguage) ? `_${i18next.resolvedLanguage}` : ""}`; + return `${baseKey}${hasAllLocalizedSprites(i18next.resolvedLanguage) ? `_${i18next.resolvedLanguage}` : ""}`; } /**