i18n: sort languages by name, not by locale code (#2625)

### Change Type

- [x] `patch` — Bug fix

### Release Notes

- Sorts the locale list by locale name, not code.
This commit is contained in:
Mime Čuvalo 2024-01-25 11:26:33 +00:00 committed by GitHub
parent d6e9912d92
commit 4aaeafd916
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 55 additions and 52 deletions

View file

@ -555,9 +555,6 @@ export function isShapeId(id?: string): id is TLShapeId;
// @public (undocumented)
export const LANGUAGES: readonly [{
readonly locale: "ar";
readonly label: "عربي";
}, {
readonly locale: "ca";
readonly label: "Català";
}, {
@ -575,45 +572,18 @@ export const LANGUAGES: readonly [{
}, {
readonly locale: "es";
readonly label: "Español";
}, {
readonly locale: "fa";
readonly label: "فارسی";
}, {
readonly locale: "fi";
readonly label: "Suomi";
}, {
readonly locale: "fr";
readonly label: "Français";
}, {
readonly locale: "gl";
readonly label: "Galego";
}, {
readonly locale: "he";
readonly label: "עברית";
}, {
readonly locale: "it";
readonly label: "Italiano";
}, {
readonly locale: "ja";
readonly label: "日本語";
}, {
readonly locale: "ko-kr";
readonly label: "한국어";
}, {
readonly locale: "ku";
readonly label: "کوردی";
}, {
readonly locale: "hi-in";
readonly label: "हिन्दी";
}, {
readonly locale: "hu";
readonly label: "Magyar";
}, {
readonly locale: "my";
readonly label: "မြန်မာစာ";
}, {
readonly locale: "ne";
readonly label: "नेपाली";
}, {
readonly locale: "no";
readonly label: "Norwegian";
@ -632,15 +602,15 @@ export const LANGUAGES: readonly [{
}, {
readonly locale: "ru";
readonly label: "Russian";
}, {
readonly locale: "fi";
readonly label: "Suomi";
}, {
readonly locale: "sv";
readonly label: "Svenska";
}, {
readonly locale: "te";
readonly label: "తెలుగు";
}, {
readonly locale: "th";
readonly label: "ภาษาไทย";
readonly locale: "vi";
readonly label: "Tiếng Việt";
}, {
readonly locale: "tr";
readonly label: "Türkçe";
@ -648,8 +618,38 @@ export const LANGUAGES: readonly [{
readonly locale: "uk";
readonly label: "Ukrainian";
}, {
readonly locale: "vi";
readonly label: "Tiếng Việt";
readonly locale: "he";
readonly label: "עברית";
}, {
readonly locale: "ar";
readonly label: "عربي";
}, {
readonly locale: "fa";
readonly label: "فارسی";
}, {
readonly locale: "ku";
readonly label: "کوردی";
}, {
readonly locale: "ne";
readonly label: "नेपाली";
}, {
readonly locale: "hi-in";
readonly label: "हिन्दी";
}, {
readonly locale: "te";
readonly label: "తెలుగు";
}, {
readonly locale: "th";
readonly label: "ภาษาไทย";
}, {
readonly locale: "my";
readonly label: "မြန်မာစာ";
}, {
readonly locale: "ko-kr";
readonly label: "한국어";
}, {
readonly locale: "ja";
readonly label: "日本語";
}, {
readonly locale: "zh-cn";
readonly label: "简体中文";

View file

@ -2697,7 +2697,7 @@
},
{
"kind": "Content",
"text": "readonly [{\n readonly locale: \"ar\";\n readonly label: \"عربي\";\n}, {\n readonly locale: \"ca\";\n readonly label: \"Català\";\n}, {\n readonly locale: \"cs\";\n readonly label: \"Čeština\";\n}, {\n readonly locale: \"da\";\n readonly label: \"Danish\";\n}, {\n readonly locale: \"de\";\n readonly label: \"Deutsch\";\n}, {\n readonly locale: \"en\";\n readonly label: \"English\";\n}, {\n readonly locale: \"es\";\n readonly label: \"Español\";\n}, {\n readonly locale: \"fa\";\n readonly label: \"فارسی\";\n}, {\n readonly locale: \"fi\";\n readonly label: \"Suomi\";\n}, {\n readonly locale: \"fr\";\n readonly label: \"Français\";\n}, {\n readonly locale: \"gl\";\n readonly label: \"Galego\";\n}, {\n readonly locale: \"he\";\n readonly label: \"עברית\";\n}, {\n readonly locale: \"it\";\n readonly label: \"Italiano\";\n}, {\n readonly locale: \"ja\";\n readonly label: \"日本語\";\n}, {\n readonly locale: \"ko-kr\";\n readonly label: \"한국어\";\n}, {\n readonly locale: \"ku\";\n readonly label: \"کوردی\";\n}, {\n readonly locale: \"hi-in\";\n readonly label: \"हिन्दी\";\n}, {\n readonly locale: \"hu\";\n readonly label: \"Magyar\";\n}, {\n readonly locale: \"my\";\n readonly label: \"မြန်မာစာ\";\n}, {\n readonly locale: \"ne\";\n readonly label: \"नेपाली\";\n}, {\n readonly locale: \"no\";\n readonly label: \"Norwegian\";\n}, {\n readonly locale: \"pl\";\n readonly label: \"Polski\";\n}, {\n readonly locale: \"pt-br\";\n readonly label: \"Português - Brasil\";\n}, {\n readonly locale: \"pt-pt\";\n readonly label: \"Português - Europeu\";\n}, {\n readonly locale: \"ro\";\n readonly label: \"Română\";\n}, {\n readonly locale: \"ru\";\n readonly label: \"Russian\";\n}, {\n readonly locale: \"sv\";\n readonly label: \"Svenska\";\n}, {\n readonly locale: \"te\";\n readonly label: \"తెలుగు\";\n}, {\n readonly locale: \"th\";\n readonly label: \"ภาษาไทย\";\n}, {\n readonly locale: \"tr\";\n readonly label: \"Türkçe\";\n}, {\n readonly locale: \"uk\";\n readonly label: \"Ukrainian\";\n}, {\n readonly locale: \"vi\";\n readonly label: \"Tiếng Việt\";\n}, {\n readonly locale: \"zh-cn\";\n readonly label: \"简体中文\";\n}, {\n readonly locale: \"zh-tw\";\n readonly label: \"繁體中文 (台灣)\";\n}]"
"text": "readonly [{\n readonly locale: \"ca\";\n readonly label: \"Català\";\n}, {\n readonly locale: \"cs\";\n readonly label: \"Čeština\";\n}, {\n readonly locale: \"da\";\n readonly label: \"Danish\";\n}, {\n readonly locale: \"de\";\n readonly label: \"Deutsch\";\n}, {\n readonly locale: \"en\";\n readonly label: \"English\";\n}, {\n readonly locale: \"es\";\n readonly label: \"Español\";\n}, {\n readonly locale: \"fr\";\n readonly label: \"Français\";\n}, {\n readonly locale: \"gl\";\n readonly label: \"Galego\";\n}, {\n readonly locale: \"it\";\n readonly label: \"Italiano\";\n}, {\n readonly locale: \"hu\";\n readonly label: \"Magyar\";\n}, {\n readonly locale: \"no\";\n readonly label: \"Norwegian\";\n}, {\n readonly locale: \"pl\";\n readonly label: \"Polski\";\n}, {\n readonly locale: \"pt-br\";\n readonly label: \"Português - Brasil\";\n}, {\n readonly locale: \"pt-pt\";\n readonly label: \"Português - Europeu\";\n}, {\n readonly locale: \"ro\";\n readonly label: \"Română\";\n}, {\n readonly locale: \"ru\";\n readonly label: \"Russian\";\n}, {\n readonly locale: \"fi\";\n readonly label: \"Suomi\";\n}, {\n readonly locale: \"sv\";\n readonly label: \"Svenska\";\n}, {\n readonly locale: \"vi\";\n readonly label: \"Tiếng Việt\";\n}, {\n readonly locale: \"tr\";\n readonly label: \"Türkçe\";\n}, {\n readonly locale: \"uk\";\n readonly label: \"Ukrainian\";\n}, {\n readonly locale: \"he\";\n readonly label: \"עברית\";\n}, {\n readonly locale: \"ar\";\n readonly label: \"عربي\";\n}, {\n readonly locale: \"fa\";\n readonly label: \"فارسی\";\n}, {\n readonly locale: \"ku\";\n readonly label: \"کوردی\";\n}, {\n readonly locale: \"ne\";\n readonly label: \"नेपाली\";\n}, {\n readonly locale: \"hi-in\";\n readonly label: \"हिन्दी\";\n}, {\n readonly locale: \"te\";\n readonly label: \"తెలుగు\";\n}, {\n readonly locale: \"th\";\n readonly label: \"ภาษาไทย\";\n}, {\n readonly locale: \"my\";\n readonly label: \"မြန်မာစာ\";\n}, {\n readonly locale: \"ko-kr\";\n readonly label: \"한국어\";\n}, {\n readonly locale: \"ja\";\n readonly label: \"日本語\";\n}, {\n readonly locale: \"zh-cn\";\n readonly label: \"简体中文\";\n}, {\n readonly locale: \"zh-tw\";\n readonly label: \"繁體中文 (台灣)\";\n}]"
}
],
"fileUrlPath": "packages/tlschema/src/translations/languages.ts",

View file

@ -3,38 +3,38 @@
/** @public */
export const LANGUAGES = [
{ locale: 'ar', label: 'عربي' },
{ locale: 'ca', label: 'Català' },
{ locale: 'cs', label: 'Čeština' },
{ locale: 'da', label: 'Danish' },
{ locale: 'de', label: 'Deutsch' },
{ locale: 'en', label: 'English' },
{ locale: 'es', label: 'Español' },
{ locale: 'fa', label: 'فارسی' },
{ locale: 'fi', label: 'Suomi' },
{ locale: 'fr', label: 'Français' },
{ locale: 'gl', label: 'Galego' },
{ locale: 'he', label: 'עברית' },
{ locale: 'it', label: 'Italiano' },
{ locale: 'ja', label: '日本語' },
{ locale: 'ko-kr', label: '한국어' },
{ locale: 'ku', label: 'کوردی' },
{ locale: 'hi-in', label: 'हिन्दी' },
{ locale: 'hu', label: 'Magyar' },
{ locale: 'my', label: 'မြန်မာစာ' },
{ locale: 'ne', label: 'नेपाली' },
{ locale: 'no', label: 'Norwegian' },
{ locale: 'pl', label: 'Polski' },
{ locale: 'pt-br', label: 'Português - Brasil' },
{ locale: 'pt-pt', label: 'Português - Europeu' },
{ locale: 'ro', label: 'Română' },
{ locale: 'ru', label: 'Russian' },
{ locale: 'fi', label: 'Suomi' },
{ locale: 'sv', label: 'Svenska' },
{ locale: 'te', label: 'తెలుగు' },
{ locale: 'th', label: 'ภาษาไทย' },
{ locale: 'vi', label: 'Tiếng Việt' },
{ locale: 'tr', label: 'Türkçe' },
{ locale: 'uk', label: 'Ukrainian' },
{ locale: 'vi', label: 'Tiếng Việt' },
{ locale: 'he', label: 'עברית' },
{ locale: 'ar', label: 'عربي' },
{ locale: 'fa', label: 'فارسی' },
{ locale: 'ku', label: 'کوردی' },
{ locale: 'ne', label: 'नेपाली' },
{ locale: 'hi-in', label: 'हिन्दी' },
{ locale: 'te', label: 'తెలుగు' },
{ locale: 'th', label: 'ภาษาไทย' },
{ locale: 'my', label: 'မြန်မာစာ' },
{ locale: 'ko-kr', label: '한국어' },
{ locale: 'ja', label: '日本語' },
{ locale: 'zh-cn', label: '简体中文' },
{ locale: 'zh-tw', label: '繁體中文 (台灣)' },
] as const

View file

@ -215,9 +215,12 @@ async function copyTranslations() {
// languages.ts
const languagesSource = await readJsonIfExists(join(sourceFolderPath, 'languages.json'))!
type Language = { label: string; locale: string }
const languagesFile = `
/** @public */
export const LANGUAGES = ${JSON.stringify(languagesSource)} as const
export const LANGUAGES = ${JSON.stringify(
languagesSource.sort((a: Language, b: Language) => a.label.localeCompare(b.label))
)} as const
`
const schemaPath = join(REPO_ROOT, 'packages', 'tlschema', 'src', 'translations')
const schemaLanguagesFilePath = join(schemaPath, 'languages.ts')