function getLocalizedString()

in js/src/renderButtons.ts [176:205]


function getLocalizedString(locale: string) {
    locale = locale.toLowerCase();

    // Look for the localization, if the language is supported.
    if (locs[locale]) {
        return locs[locale];
    }

    // Special case handling for Chinese, in which certain locales should resolve to Traditional Chinese, and
    // the others should resolve to Simplified Chinese.
    if (locale === 'zh-hk' || locale === 'zh-mo' || locale === 'zh-tw') {
        return locs['zh-hant'];
    }

    // Remove the subscript portion (or the region) portion of the locale, and check to see if the
    // localization exists for the resulting locale.
    locale = locale.substring(0, locale.lastIndexOf('-'));
    if (locs[locale]) {
        return locs[locale];
    }

    // Remove the region portion of the locale, and check to see if the localization exists for the resulting locale.
    locale = locale.substring(0, locale.lastIndexOf('-'));
    if (locs[locale]) {
        return locs[locale];
    }

    // If all else fails, show the string in English.
    return locs['en'];
}