thay doi ui chebichat

This commit is contained in:
quangdn-ght
2025-06-25 14:57:12 +07:00
parent e3fc9eef8f
commit cdeb27891b
29 changed files with 621 additions and 1129 deletions

View File

@@ -1,23 +1,6 @@
import cn from "./cn";
import en from "./en";
import pt from "./pt";
import tw from "./tw";
import da from "./da";
import id from "./id";
import fr from "./fr";
import es from "./es";
import it from "./it";
import tr from "./tr";
import jp from "./jp";
import de from "./de";
import vi from "./vi";
import ru from "./ru";
import no from "./no";
import cs from "./cs";
import ko from "./ko";
import ar from "./ar";
import bn from "./bn";
import sk from "./sk";
import { merge } from "../utils/merge";
import { safeLocalStorage } from "@/app/utils";
@@ -29,24 +12,7 @@ const localStorage = safeLocalStorage();
const ALL_LANGS = {
cn,
en,
tw,
pt,
da,
jp,
ko,
id,
fr,
es,
it,
tr,
de,
vi,
ru,
cs,
no,
ar,
bn,
sk,
};
export type Lang = keyof typeof ALL_LANGS;
@@ -54,34 +20,19 @@ export type Lang = keyof typeof ALL_LANGS;
export const AllLangs = Object.keys(ALL_LANGS) as Lang[];
export const ALL_LANG_OPTIONS: Record<Lang, string> = {
cn: "简体中文",
en: "English",
pt: "Português",
tw: "繁體中文",
da: "Dansk",
jp: "日本語",
ko: "한국어",
id: "Indonesia",
fr: "Français",
es: "Español",
it: "Italiano",
tr: "Türkçe",
de: "Deutsch",
vi: "Tiếng Việt",
ru: "Русский",
cs: "Čeština",
no: "Nynorsk",
ar: "العربية",
bn: "বাংলা",
sk: "Slovensky",
en: "English",
cn: "简体中文",
};
const LANG_KEY = "lang";
const DEFAULT_LANG = "en";
const DEFAULT_LANG = "vi";
const fallbackLang = en;
const targetLang = ALL_LANGS[getLang()] as LocaleType;
// console.log("Current language:", targetLang);
// if target lang missing some fields, it will use fallback lang string
merge(fallbackLang, targetLang);
@@ -98,7 +49,12 @@ function setItem(key: string, value: string) {
function getLanguage() {
try {
const locale = new Intl.Locale(navigator.language).maximize();
const region = locale?.region?.toLowerCase();
let region = locale?.region?.toLowerCase();
region = "vn"; // Force to use Vietnam region for now
// console.log("Detected locale:", locale.language, region);
// 1. check region code in ALL_LANGS
if (AllLangs.includes(region as Lang)) {
return region as Lang;
@@ -120,7 +76,12 @@ export function getLang(): Lang {
return savedLang as Lang;
}
return getLanguage();
// const lang = getLanguage();
const lang = "vi"; // Force to use Vietnamese for now
// console.log("Detected language:", lang);
return lang;
}
export function changeLang(lang: Lang) {
@@ -138,28 +99,12 @@ export function getISOLang() {
return isoLangString[lang] ?? lang;
}
const DEFAULT_STT_LANG = "zh-CN";
const DEFAULT_STT_LANG = "vi-VN";
export const STT_LANG_MAP: Record<Lang, string> = {
cn: "zh-CN",
en: "en-US",
pt: "pt-BR",
tw: "zh-TW",
da: "da-DK",
jp: "ja-JP",
ko: "ko-KR",
id: "id-ID",
fr: "fr-FR",
es: "es-ES",
it: "it-IT",
tr: "tr-TR",
de: "de-DE",
vi: "vi-VN",
ru: "ru-RU",
cs: "cs-CZ",
no: "no-NO",
ar: "ar-SA",
bn: "bn-BD",
sk: "sk-SK",
};
export function getSTTLang(): string {