feat(i18n): sort languages alphabetically

This commit is contained in:
Elian Doran 2025-03-04 20:51:22 +02:00
parent 951f4c4921
commit 4c89a2ac27
No known key found for this signature in database

View File

@ -13,23 +13,7 @@ export interface Locale {
rtl?: boolean;
}
export async function initializeTranslations() {
const resourceDir = getResourceDir();
// Initialize translations
await i18next.use(Backend).init({
lng: getCurrentLanguage(),
fallbackLng: "en",
ns: "server",
backend: {
loadPath: join(resourceDir, "translations/{{lng}}/{{ns}}.json")
}
});
}
export function getLocales(): Locale[] {
// TODO: Currently hardcoded, needs to read the list of available languages.
return [
const LOCALES: Locale[] = [
{
id: "en",
name: "English"
@ -84,7 +68,24 @@ export function getLocales(): Locale[] {
name: "فارسی",
rtl: true
}
];
].sort((a, b) => a.name.localeCompare(b.name));
export async function initializeTranslations() {
const resourceDir = getResourceDir();
// Initialize translations
await i18next.use(Backend).init({
lng: getCurrentLanguage(),
fallbackLng: "en",
ns: "server",
backend: {
loadPath: join(resourceDir, "translations/{{lng}}/{{ns}}.json")
}
});
}
export function getLocales(): Locale[] {
return LOCALES;
}
function getCurrentLanguage() {