From 4c89a2ac27ba17ae0a27a60dd92e96d96afd7d24 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Tue, 4 Mar 2025 20:51:22 +0200 Subject: [PATCH] feat(i18n): sort languages alphabetically --- src/services/i18n.ts | 115 ++++++++++++++++++++++--------------------- 1 file changed, 58 insertions(+), 57 deletions(-) diff --git a/src/services/i18n.ts b/src/services/i18n.ts index 4dd8d4519..24068ce38 100644 --- a/src/services/i18n.ts +++ b/src/services/i18n.ts @@ -13,6 +13,63 @@ export interface Locale { rtl?: boolean; } +const LOCALES: Locale[] = [ + { + id: "en", + name: "English" + }, + { + id: "de", + name: "Deutsch" + }, + { + id: "es", + name: "Español" + }, + { + id: "fr", + name: "Français" + }, + { + id: "cn", + name: "简体中文" + }, + { + id: "tw", + name: "繁體中文" + }, + { + id: "ro", + name: "Română" + }, + + /* + * Right to left languages + * + * Currently they are only for setting the language of text notes. + */ + { // Arabic + id: "ar", + name: "اَلْعَرَبِيَّةُ", + rtl: true + }, + { // Hebrew + id: "he", + name: "עברית", + rtl: true + }, + { // Kurdish + id: "ku", + name: "کوردی", + rtl: true + }, + { // Persian + id: "fa", + name: "فارسی", + rtl: true + } +].sort((a, b) => a.name.localeCompare(b.name)); + export async function initializeTranslations() { const resourceDir = getResourceDir(); @@ -28,63 +85,7 @@ export async function initializeTranslations() { } export function getLocales(): Locale[] { - // TODO: Currently hardcoded, needs to read the list of available languages. - return [ - { - id: "en", - name: "English" - }, - { - id: "de", - name: "Deutsch" - }, - { - id: "es", - name: "Español" - }, - { - id: "fr", - name: "Français" - }, - { - id: "cn", - name: "简体中文" - }, - { - id: "tw", - name: "繁體中文" - }, - { - id: "ro", - name: "Română" - }, - - /* - * Right to left languages - * - * Currently they are only for setting the language of text notes. - */ - { // Arabic - id: "ar", - name: "اَلْعَرَبِيَّةُ", - rtl: true - }, - { // Hebrew - id: "he", - name: "עברית", - rtl: true - }, - { // Kurdish - id: "ku", - name: "کوردی", - rtl: true - }, - { // Persian - id: "fa", - name: "فارسی", - rtl: true - } - ]; + return LOCALES; } function getCurrentLanguage() {