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

@ -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')