signal-desktop/ts/util/mapToSupportLocale.ts

132 lines
1.8 KiB
TypeScript
Raw Normal View History

2021-02-18 16:40:26 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
export type SupportLocaleType =
| 'ar'
| 'de'
| 'en-us'
| 'es'
| 'fr'
| 'it'
| 'ja'
| 'pl'
| 'pt-br'
| 'ru'
| 'sq'
| 'zh-tw';
// See https://source.chromium.org/chromium/chromium/src/+/main:ui/base/l10n/l10n_util.cc
2021-02-18 16:40:26 +00:00
export type ElectronLocaleType =
| 'af'
| 'ar'
| 'bg'
| 'bn'
| 'ca'
| 'cs'
| 'cy'
| 'da'
| 'de'
| 'de-AT'
| 'de-CH'
| 'de-DE'
| 'de-LI'
2021-02-18 16:40:26 +00:00
| 'el'
| 'en'
| 'en-AU'
| 'en-CA'
| 'en-GB'
| 'en-GB-oxendict'
| 'en-IN'
| 'en-NZ'
| 'en-US'
2021-02-18 16:40:26 +00:00
| 'eo'
| 'es'
| 'es-419'
2021-02-18 16:40:26 +00:00
| 'et'
| 'eu'
| 'fa'
| 'fi'
| 'fr'
| 'fr-CA'
| 'fr-CH'
| 'fr-FR'
2021-02-18 16:40:26 +00:00
| 'he'
| 'hi'
| 'hr'
| 'hu'
| 'id'
| 'it'
| 'it-CH'
| 'it-IT'
2021-02-18 16:40:26 +00:00
| 'ja'
| 'km'
| 'kn'
| 'ko'
| 'lt'
| 'mk'
| 'mr'
| 'ms'
| 'nb'
| 'nl'
| 'nn'
| 'no'
| 'pl'
| 'pt-BR'
| 'pt-PT'
2021-02-18 16:40:26 +00:00
| 'ro'
| 'ru'
| 'sk'
| 'sl'
| 'sq'
| 'sr'
| 'sv'
| 'sw'
| 'ta'
| 'te'
| 'th'
| 'tr'
| 'uk'
| 'ur'
| 'vi'
| 'zh-CN'
| 'zh-HK'
| 'zh-TW';
2021-02-18 16:40:26 +00:00
export function mapToSupportLocale(ourLocale: string): SupportLocaleType {
2021-02-18 16:40:26 +00:00
if (ourLocale === 'ar') {
return ourLocale;
}
if (ourLocale === 'de') {
return ourLocale;
}
if (ourLocale === 'es') {
return ourLocale;
}
if (ourLocale === 'fr') {
return ourLocale;
}
if (ourLocale === 'it') {
return ourLocale;
}
if (ourLocale === 'ja') {
return ourLocale;
}
if (ourLocale === 'pl') {
return ourLocale;
}
if (ourLocale === 'pt-BR') {
2021-02-18 16:40:26 +00:00
return 'pt-br';
}
if (ourLocale === 'ru') {
return ourLocale;
}
if (ourLocale === 'sq') {
return ourLocale;
}
if (ourLocale === 'zh-TW') {
2021-02-18 16:40:26 +00:00
return 'zh-tw';
}
return 'en-us';
}