mirror of
https://github.com/sussy-code/smov.git
synced 2025-01-01 16:37:39 +01:00
Add missing languages + add support for scripts (pain)
This commit is contained in:
parent
a4f75a34ab
commit
7155ffce40
3 changed files with 44 additions and 5 deletions
|
@ -1,13 +1,21 @@
|
||||||
import ar from "@/assets/locales/ar.json";
|
import ar from "@/assets/locales/ar.json";
|
||||||
|
import bg from "@/assets/locales/bg.json";
|
||||||
|
import bn from "@/assets/locales/bn.json";
|
||||||
import cs from "@/assets/locales/cs.json";
|
import cs from "@/assets/locales/cs.json";
|
||||||
import de from "@/assets/locales/de.json";
|
import de from "@/assets/locales/de.json";
|
||||||
|
import el from "@/assets/locales/el.json";
|
||||||
import en from "@/assets/locales/en.json";
|
import en from "@/assets/locales/en.json";
|
||||||
import es from "@/assets/locales/es.json";
|
import es from "@/assets/locales/es.json";
|
||||||
import et from "@/assets/locales/et.json";
|
import et from "@/assets/locales/et.json";
|
||||||
|
import fa from "@/assets/locales/fa.json";
|
||||||
import fr from "@/assets/locales/fr.json";
|
import fr from "@/assets/locales/fr.json";
|
||||||
|
import gu from "@/assets/locales/gu.json";
|
||||||
import he from "@/assets/locales/he.json";
|
import he from "@/assets/locales/he.json";
|
||||||
import hi from "@/assets/locales/hi.json";
|
import hi from "@/assets/locales/hi.json";
|
||||||
|
import id from "@/assets/locales/id.json";
|
||||||
import it from "@/assets/locales/it.json";
|
import it from "@/assets/locales/it.json";
|
||||||
|
import ja from "@/assets/locales/ja.json";
|
||||||
|
import ko from "@/assets/locales/ko.json";
|
||||||
import lv from "@/assets/locales/lv.json";
|
import lv from "@/assets/locales/lv.json";
|
||||||
import minion from "@/assets/locales/minion.json";
|
import minion from "@/assets/locales/minion.json";
|
||||||
import ne from "@/assets/locales/ne.json";
|
import ne from "@/assets/locales/ne.json";
|
||||||
|
@ -15,12 +23,16 @@ import nl from "@/assets/locales/nl.json";
|
||||||
import pirate from "@/assets/locales/pirate.json";
|
import pirate from "@/assets/locales/pirate.json";
|
||||||
import pl from "@/assets/locales/pl.json";
|
import pl from "@/assets/locales/pl.json";
|
||||||
import ptbr from "@/assets/locales/pt-BR.json";
|
import ptbr from "@/assets/locales/pt-BR.json";
|
||||||
|
import ru from "@/assets/locales/ru.json";
|
||||||
|
import sl from "@/assets/locales/sl.json";
|
||||||
import sv from "@/assets/locales/sv.json";
|
import sv from "@/assets/locales/sv.json";
|
||||||
|
import ta from "@/assets/locales/ta.json";
|
||||||
import th from "@/assets/locales/th.json";
|
import th from "@/assets/locales/th.json";
|
||||||
import tok from "@/assets/locales/tok.json";
|
import tok from "@/assets/locales/tok.json";
|
||||||
import tr from "@/assets/locales/tr.json";
|
import tr from "@/assets/locales/tr.json";
|
||||||
import uk from "@/assets/locales/uk.json";
|
import uk from "@/assets/locales/uk.json";
|
||||||
import vi from "@/assets/locales/vi.json";
|
import vi from "@/assets/locales/vi.json";
|
||||||
|
import zhhant from "@/assets/locales/zh-Hant.json";
|
||||||
import zh from "@/assets/locales/zh.json";
|
import zh from "@/assets/locales/zh.json";
|
||||||
|
|
||||||
export const locales = {
|
export const locales = {
|
||||||
|
@ -48,5 +60,17 @@ export const locales = {
|
||||||
hi,
|
hi,
|
||||||
"pt-BR": ptbr,
|
"pt-BR": ptbr,
|
||||||
uk,
|
uk,
|
||||||
|
bg,
|
||||||
|
bn,
|
||||||
|
el,
|
||||||
|
fa,
|
||||||
|
gu,
|
||||||
|
id,
|
||||||
|
ja,
|
||||||
|
ko,
|
||||||
|
sl,
|
||||||
|
ta,
|
||||||
|
"zh-HANT": zhhant,
|
||||||
|
ru,
|
||||||
};
|
};
|
||||||
export type Locales = keyof typeof locales;
|
export type Locales = keyof typeof locales;
|
||||||
|
|
|
@ -43,7 +43,7 @@ export function FlagIcon(props: FlagIconProps) {
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
className={classNames(
|
className={classNames(
|
||||||
"!w-8 h-6 rounded overflow-hidden bg-cover bg-center block fi",
|
"!w-8 min-w-8 h-6 rounded overflow-hidden bg-cover bg-center block fi",
|
||||||
backgroundClass,
|
backgroundClass,
|
||||||
countryCode ? `fi-${countryCode}` : undefined,
|
countryCode ? `fi-${countryCode}` : undefined,
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -16,6 +16,8 @@ const countryPriority: Record<string, string> = {
|
||||||
ar: "sa",
|
ar: "sa",
|
||||||
es: "es",
|
es: "es",
|
||||||
zh: "cn",
|
zh: "cn",
|
||||||
|
ko: "kr",
|
||||||
|
ta: "lk",
|
||||||
};
|
};
|
||||||
|
|
||||||
// list of iso639_1 Alpha-2 codes used as default languages
|
// list of iso639_1 Alpha-2 codes used as default languages
|
||||||
|
@ -39,6 +41,17 @@ const defaultLanguageCodes: string[] = [
|
||||||
"ar-SA",
|
"ar-SA",
|
||||||
"es-ES",
|
"es-ES",
|
||||||
"et-EE",
|
"et-EE",
|
||||||
|
"bg-BG",
|
||||||
|
"bn-BD",
|
||||||
|
"el-GR",
|
||||||
|
"fa-IR",
|
||||||
|
"gu-IN",
|
||||||
|
"id-ID",
|
||||||
|
"ja-JP",
|
||||||
|
"ko-KR",
|
||||||
|
"sl-SI",
|
||||||
|
"ta-LK",
|
||||||
|
"ru-RU",
|
||||||
];
|
];
|
||||||
|
|
||||||
export interface LocaleInfo {
|
export interface LocaleInfo {
|
||||||
|
@ -80,7 +93,6 @@ function populateLanguageCode(language: string): string {
|
||||||
*/
|
*/
|
||||||
export function getPrettyLanguageNameFromLocale(locale: string): string | null {
|
export function getPrettyLanguageNameFromLocale(locale: string): string | null {
|
||||||
const tag = getTag(populateLanguageCode(locale), true);
|
const tag = getTag(populateLanguageCode(locale), true);
|
||||||
|
|
||||||
const lang = tag?.language?.Description?.[0] ?? null;
|
const lang = tag?.language?.Description?.[0] ?? null;
|
||||||
if (!lang) return null;
|
if (!lang) return null;
|
||||||
|
|
||||||
|
@ -159,12 +171,15 @@ export function getLocaleInfo(locale: string): LocaleInfo | null {
|
||||||
});
|
});
|
||||||
if (!output) return null;
|
if (!output) return null;
|
||||||
|
|
||||||
|
const extras = [];
|
||||||
|
if (tag.region?.Description) extras.push(tag.region.Description[0]);
|
||||||
|
if (tag.script?.Description) extras.push(tag.script.Description[0]);
|
||||||
|
const extraStringified = extras.map((v) => `(${v})`).join(" ");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
code: tag.parts.langtag ?? realLocale,
|
code: tag.parts.langtag ?? realLocale,
|
||||||
isRtl: output.direction === "RTL",
|
isRtl: output.direction === "RTL",
|
||||||
name:
|
name: output.name[0] + (extraStringified ? ` ${extraStringified}` : ""),
|
||||||
output.name[0] +
|
|
||||||
(tag.region?.Description ? ` (${tag.region.Description[0]})` : ""),
|
|
||||||
nativeName: output.nativeName[0] ?? undefined,
|
nativeName: output.nativeName[0] ?? undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue