109 lines
2.2 KiB
TypeScript
109 lines
2.2 KiB
TypeScript
import type { Dictionary } from "./types";
|
|
import { enDictionary } from "./dictionaries/en";
|
|
import { ruDictionary } from "./dictionaries/ru";
|
|
import { nlDictionary } from "./dictionaries/nl";
|
|
import { esDictionary } from "./dictionaries/es";
|
|
|
|
export const locales = [
|
|
"en",
|
|
"ru",
|
|
"es",
|
|
"pt",
|
|
"fr",
|
|
"de",
|
|
"it",
|
|
"zh-CN",
|
|
"zh-TW",
|
|
"ja",
|
|
"ko",
|
|
"hi",
|
|
"ar",
|
|
"tr",
|
|
"pl",
|
|
"uk",
|
|
"nl",
|
|
"sv",
|
|
"no",
|
|
"da",
|
|
"fi",
|
|
"cs",
|
|
"sk",
|
|
"sl",
|
|
"ro",
|
|
"hu",
|
|
"el",
|
|
"he",
|
|
"fa",
|
|
"ur",
|
|
"id",
|
|
"ms",
|
|
"th",
|
|
"vi",
|
|
"fil",
|
|
"bn",
|
|
"ta",
|
|
"te",
|
|
"mr",
|
|
"pa",
|
|
"bg",
|
|
"sr",
|
|
"hr",
|
|
"lt",
|
|
"lv",
|
|
"et",
|
|
"uz",
|
|
"kk",
|
|
"az",
|
|
"ka"
|
|
] as const;
|
|
|
|
export type Locale = (typeof locales)[number];
|
|
|
|
export const fallbackLocale: Locale = "en";
|
|
|
|
export const rtlLocales: Locale[] = ["ar", "fa", "he", "ur"];
|
|
|
|
const localeMeta: Partial<Record<Locale, { title: string; description: string }>> = {
|
|
en: {
|
|
title: "AllAI Studio - Unified Generative AI Workspace",
|
|
description: "Create and orchestrate generative AI workflows for imagery, video, and audio."
|
|
},
|
|
ru: {
|
|
title: "AllAI Studio — Единое пространство для генеративного ИИ",
|
|
description: "Стройте пайплайны для изображений, видео и аудио в одной студии."
|
|
}
|
|
};
|
|
|
|
export const dictionaries: Partial<Record<Locale, Dictionary>> = {
|
|
en: enDictionary,
|
|
ru: ruDictionary,
|
|
nl: nlDictionary,
|
|
es: esDictionary
|
|
};
|
|
|
|
export function resolveLocale(input?: string | null): Locale {
|
|
if (!input) return fallbackLocale;
|
|
const normalized = input.toLowerCase();
|
|
if (locales.includes(normalized as Locale)) {
|
|
return normalized as Locale;
|
|
}
|
|
const base = normalized.split("-")[0] as Locale;
|
|
if (locales.includes(base)) {
|
|
return base;
|
|
}
|
|
return fallbackLocale;
|
|
}
|
|
|
|
export function getLocaleDisplayName(locale: Locale, displayLocale: Locale = fallbackLocale): string {
|
|
try {
|
|
const formatter = new Intl.DisplayNames([displayLocale], { type: "language" });
|
|
return formatter.of(locale) ?? locale.toUpperCase();
|
|
} catch {
|
|
return locale.toUpperCase();
|
|
}
|
|
}
|
|
|
|
export function getMetadataForLocale(locale: Locale) {
|
|
return localeMeta[locale] ?? localeMeta[fallbackLocale]!;
|
|
}
|