mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 14:25:00 +00:00
Ajout de commentaires supplémentaires aux motifs
This commit is contained in:
@@ -9,33 +9,33 @@ import { TranslatableString } from "ChillMainAssets/types";
|
||||
* @returns The localized string or null if no translation is available
|
||||
*/
|
||||
export function localizeString(
|
||||
translatableString: TranslatableString | null | undefined,
|
||||
locale?: string,
|
||||
translatableString: TranslatableString | null | undefined,
|
||||
locale?: string,
|
||||
): string {
|
||||
if (!translatableString || Object.keys(translatableString).length === 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const currentLocale = locale || navigator.language.split("-")[0] || "fr";
|
||||
|
||||
if (translatableString[currentLocale]) {
|
||||
return translatableString[currentLocale];
|
||||
}
|
||||
|
||||
// Define fallback locales
|
||||
const fallbackLocales: string[] = ["fr", "en"];
|
||||
|
||||
for (const fallbackLocale of fallbackLocales) {
|
||||
if (translatableString[fallbackLocale]) {
|
||||
return translatableString[fallbackLocale];
|
||||
}
|
||||
}
|
||||
|
||||
// No fallback translation found, use the first available
|
||||
const availableLocales = Object.keys(translatableString);
|
||||
if (availableLocales.length > 0) {
|
||||
return translatableString[availableLocales[0]];
|
||||
}
|
||||
|
||||
if (!translatableString || Object.keys(translatableString).length === 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const currentLocale = locale || navigator.language.split("-")[0] || "fr";
|
||||
|
||||
if (translatableString[currentLocale]) {
|
||||
return translatableString[currentLocale];
|
||||
}
|
||||
|
||||
// Define fallback locales
|
||||
const fallbackLocales: string[] = ["fr", "en"];
|
||||
|
||||
for (const fallbackLocale of fallbackLocales) {
|
||||
if (translatableString[fallbackLocale]) {
|
||||
return translatableString[fallbackLocale];
|
||||
}
|
||||
}
|
||||
|
||||
// No fallback translation found, use the first available
|
||||
const availableLocales = Object.keys(translatableString);
|
||||
if (availableLocales.length > 0) {
|
||||
return translatableString[availableLocales[0]];
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
Reference in New Issue
Block a user