Skip to content

Build your personal knowledge base with Trilium Notes

feat(i18n): sort languages alphabetically

Elian Doran4c89a2ac27ba
diff --git a/src/services/i18n.ts b/src/services/i18n.ts
index 4dd8d4519e..24068ce38b 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() {