You've already forked tf2wikipricing
fix: localization dictionary not handling mixed case
This commit is contained in:
@@ -1,35 +1,35 @@
|
|||||||
import { logDebug, logError } from "./log";
|
import { logDebug, logError } from "./log";
|
||||||
|
|
||||||
const localizations: Record<string, object> = {
|
const localizations: Record<string, object> = {
|
||||||
'en': require('../../strings/en'), // English
|
|
||||||
'es': require('../../strings/es'), // Spanish
|
|
||||||
'ja': require('../../strings/ja'), // Japanese
|
|
||||||
'it': require('../../strings/it'), // Italian
|
|
||||||
'ar': require('../../strings/ar'), // Arabic
|
'ar': require('../../strings/ar'), // Arabic
|
||||||
'cs': require('../../strings/cs'), // Czech
|
'cs': require('../../strings/cs'), // Czech
|
||||||
'da': require('../../strings/da'), // Danish
|
'da': require('../../strings/da'), // Danish
|
||||||
'de': require('../../strings/de'), // German
|
'nl': require('../../strings/nl'), // Dutch
|
||||||
'fi': require('../../strings/fi'), // Finnish
|
'fi': require('../../strings/fi'), // Finnish
|
||||||
'fr': require('../../strings/fr'), // French
|
'fr': require('../../strings/fr'), // French
|
||||||
|
'en': require('../../strings/en'), // English
|
||||||
'hu': require('../../strings/hu'), // Hungarian
|
'hu': require('../../strings/hu'), // Hungarian
|
||||||
|
'it': require('../../strings/it'), // Italian
|
||||||
|
'ja': require('../../strings/ja'), // Japanese
|
||||||
|
'de': require('../../strings/de'), // German
|
||||||
'ko': require('../../strings/ko'), // Korean
|
'ko': require('../../strings/ko'), // Korean
|
||||||
'nl': require('../../strings/nl'), // Dutch
|
|
||||||
'no': require('../../strings/no'), // Norwegian Bokmål
|
'no': require('../../strings/no'), // Norwegian Bokmål
|
||||||
'pl': require('../../strings/pl'), // Polish
|
'pl': require('../../strings/pl'), // Polish
|
||||||
'pt': require('../../strings/pt'), // Portuguese
|
'pt': require('../../strings/pt'), // Portuguese
|
||||||
'pt-BR': require('../../strings/pt-BR'), // Brazilian Portuguese
|
'pt-br': require('../../strings/pt-BR'), // Brazilian Portuguese
|
||||||
'ro': require('../../strings/ro'), // Romanian
|
'ro': require('../../strings/ro'), // Romanian
|
||||||
|
'zh-hans': require('../../strings/zh-Hans'), // Simplified Chinese
|
||||||
'ru': require('../../strings/ru'), // Russian
|
'ru': require('../../strings/ru'), // Russian
|
||||||
|
'es': require('../../strings/es'), // Spanish
|
||||||
'sv': require('../../strings/sv'), // Swedish
|
'sv': require('../../strings/sv'), // Swedish
|
||||||
|
'zh-hant': require('../../strings/zh-Hant'), // Traditional Chinese
|
||||||
'tr': require('../../strings/tr'), // Turkish
|
'tr': require('../../strings/tr'), // Turkish
|
||||||
'zh-Hans': require('../../strings/zh-Hans'), // Simplified Chinese
|
|
||||||
'zh-Hant': require('../../strings/zh-Hant'), // Traditional Chinese
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function $T(s: string, locale?: Intl.LocalesArgument): string {
|
export function $T(s: string, locale?: Intl.LocalesArgument): string {
|
||||||
const code = locale ? locale.toString() : extractLocaleFromURL(document.URL)
|
const code = locale ? locale.toString() : extractLocaleFromURL(document.URL)
|
||||||
if (code in localizations) {
|
if (code in localizations) {
|
||||||
const translation = localizations[code] as Record<string, string>;
|
const translation = localizations[code.toLowerCase()] as Record<string, string>;
|
||||||
const result = translation[s] ?? s;
|
const result = translation[s] ?? s;
|
||||||
logDebug(`Translating "${s}" to locale "${code}": ${result}`);
|
logDebug(`Translating "${s}" to locale "${code}": ${result}`);
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user