forked from XiaoMo/ChatGPT-Next-Web
Merge pull request #2018 from Yidadaa/bugfix-0617
feat: add nynorsk option
This commit is contained in:
commit
0a2cccfd6e
@ -284,7 +284,8 @@ type DeepPartial<T> = T extends object
|
||||
[P in keyof T]?: DeepPartial<T[P]>;
|
||||
}
|
||||
: T;
|
||||
export type LocaleType = DeepPartial<typeof cn>;
|
||||
export type RequiredLocaleType = typeof cn;
|
||||
|
||||
export type LocaleType = typeof cn;
|
||||
export type PartialLocaleType = DeepPartial<typeof cn>;
|
||||
|
||||
export default cn;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { SubmitKey } from "../store/config";
|
||||
import type { LocaleType } from "./index";
|
||||
import type { PartialLocaleType } from "./index";
|
||||
|
||||
const cs: LocaleType = {
|
||||
const cs: PartialLocaleType = {
|
||||
WIP: "V přípravě...",
|
||||
Error: {
|
||||
Unauthorized:
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { SubmitKey } from "../store/config";
|
||||
import type { LocaleType } from "./index";
|
||||
import type { PartialLocaleType } from "./index";
|
||||
|
||||
const de: LocaleType = {
|
||||
const de: PartialLocaleType = {
|
||||
WIP: "In Bearbeitung...",
|
||||
Error: {
|
||||
Unauthorized:
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { SubmitKey } from "../store/config";
|
||||
import { RequiredLocaleType } from "./index";
|
||||
import { LocaleType } from "./index";
|
||||
|
||||
const en: RequiredLocaleType = {
|
||||
const en: LocaleType = {
|
||||
WIP: "Coming Soon...",
|
||||
Error: {
|
||||
Unauthorized:
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { SubmitKey } from "../store/config";
|
||||
import type { LocaleType } from "./index";
|
||||
import type { PartialLocaleType } from "./index";
|
||||
|
||||
const es: LocaleType = {
|
||||
const es: PartialLocaleType = {
|
||||
WIP: "En construcción...",
|
||||
Error: {
|
||||
Unauthorized:
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { SubmitKey } from "../store/config";
|
||||
import type { LocaleType } from "./index";
|
||||
import type { PartialLocaleType } from "./index";
|
||||
|
||||
const fr: LocaleType = {
|
||||
const fr: PartialLocaleType = {
|
||||
WIP: "Prochainement...",
|
||||
Error: {
|
||||
Unauthorized:
|
||||
|
@ -1,57 +1,71 @@
|
||||
import CN from "./cn";
|
||||
import EN from "./en";
|
||||
import TW from "./tw";
|
||||
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 cn from "./cn";
|
||||
import en from "./en";
|
||||
import tw from "./tw";
|
||||
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 { merge } from "../utils/merge";
|
||||
|
||||
export type { LocaleType, RequiredLocaleType } from "./cn";
|
||||
import type { LocaleType } from "./cn";
|
||||
export type { LocaleType, PartialLocaleType } from "./cn";
|
||||
|
||||
export const AllLangs = [
|
||||
"en",
|
||||
"cn",
|
||||
"tw",
|
||||
"fr",
|
||||
"es",
|
||||
"it",
|
||||
"tr",
|
||||
"jp",
|
||||
"de",
|
||||
"vi",
|
||||
"ru",
|
||||
"cs",
|
||||
"ko",
|
||||
] as const;
|
||||
export type Lang = (typeof AllLangs)[number];
|
||||
const ALL_LANGS = {
|
||||
cn,
|
||||
en,
|
||||
tw,
|
||||
jp,
|
||||
ko,
|
||||
fr,
|
||||
es,
|
||||
it,
|
||||
tr,
|
||||
de,
|
||||
vi,
|
||||
ru,
|
||||
cs,
|
||||
no,
|
||||
};
|
||||
|
||||
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",
|
||||
tw: "繁體中文",
|
||||
jp: "日本語",
|
||||
ko: "한국어",
|
||||
fr: "Français",
|
||||
es: "Español",
|
||||
it: "Italiano",
|
||||
tr: "Türkçe",
|
||||
jp: "日本語",
|
||||
de: "Deutsch",
|
||||
vi: "Tiếng Việt",
|
||||
ru: "Русский",
|
||||
cs: "Čeština",
|
||||
ko: "한국어",
|
||||
no: "Nynorsk",
|
||||
};
|
||||
|
||||
const LANG_KEY = "lang";
|
||||
const DEFAULT_LANG = "en";
|
||||
|
||||
const fallbackLang = en;
|
||||
const targetLang = ALL_LANGS[getLang()] as LocaleType;
|
||||
|
||||
// if target lang missing some fields, it will use fallback lang string
|
||||
merge(fallbackLang, targetLang);
|
||||
|
||||
export default fallbackLang as LocaleType;
|
||||
|
||||
function getItem(key: string) {
|
||||
try {
|
||||
return localStorage.getItem(key);
|
||||
@ -96,26 +110,3 @@ export function changeLang(lang: Lang) {
|
||||
setItem(LANG_KEY, lang);
|
||||
location.reload();
|
||||
}
|
||||
|
||||
const fallbackLang = EN;
|
||||
const targetLang = {
|
||||
en: EN,
|
||||
cn: CN,
|
||||
tw: TW,
|
||||
fr: FR,
|
||||
es: ES,
|
||||
it: IT,
|
||||
tr: TR,
|
||||
jp: JP,
|
||||
de: DE,
|
||||
vi: VI,
|
||||
ru: RU,
|
||||
no: NO,
|
||||
cs: CS,
|
||||
ko: KO,
|
||||
}[getLang()] as typeof CN;
|
||||
|
||||
// if target lang missing some fields, it will use fallback lang string
|
||||
merge(fallbackLang, targetLang);
|
||||
|
||||
export default fallbackLang as typeof CN;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { SubmitKey } from "../store/config";
|
||||
import type { LocaleType } from "./index";
|
||||
import type { PartialLocaleType } from "./index";
|
||||
|
||||
const it: LocaleType = {
|
||||
const it: PartialLocaleType = {
|
||||
WIP: "Work in progress...",
|
||||
Error: {
|
||||
Unauthorized:
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { SubmitKey } from "../store/config";
|
||||
import type { LocaleType } from "./index";
|
||||
import type { PartialLocaleType } from "./index";
|
||||
|
||||
const jp: LocaleType = {
|
||||
const jp: PartialLocaleType = {
|
||||
WIP: "この機能は開発中です",
|
||||
Error: {
|
||||
Unauthorized:
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { SubmitKey } from "../store/config";
|
||||
|
||||
import type { LocaleType } from "./index";
|
||||
import type { PartialLocaleType } from "./index";
|
||||
|
||||
const ko: LocaleType = {
|
||||
const ko: PartialLocaleType = {
|
||||
WIP: "곧 출시 예정...",
|
||||
Error: {
|
||||
Unauthorized: "권한이 없습니다. 설정 페이지에서 액세스 코드를 입력하세요.",
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { SubmitKey } from "../store/config";
|
||||
import type { LocaleType } from "./index";
|
||||
import type { PartialLocaleType } from "./index";
|
||||
|
||||
const no: LocaleType = {
|
||||
const no: PartialLocaleType = {
|
||||
WIP: "Arbeid pågår ...",
|
||||
Error: {
|
||||
Unauthorized: "Du har ikke tilgang. Vennlig oppgi tildelt adgangskode.",
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { SubmitKey } from "../store/config";
|
||||
import type { LocaleType } from "./index";
|
||||
import type { PartialLocaleType } from "./index";
|
||||
|
||||
const ru: LocaleType = {
|
||||
const ru: PartialLocaleType = {
|
||||
WIP: "Скоро...",
|
||||
Error: {
|
||||
Unauthorized:
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { SubmitKey } from "../store/config";
|
||||
import type { LocaleType } from "./index";
|
||||
import type { PartialLocaleType } from "./index";
|
||||
|
||||
const tr: LocaleType = {
|
||||
const tr: PartialLocaleType = {
|
||||
WIP: "Çalışma devam ediyor...",
|
||||
Error: {
|
||||
Unauthorized:
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { SubmitKey } from "../store/config";
|
||||
import type { LocaleType } from "./index";
|
||||
import type { PartialLocaleType } from "./index";
|
||||
|
||||
const tw: LocaleType = {
|
||||
const tw: PartialLocaleType = {
|
||||
WIP: "該功能仍在開發中……",
|
||||
Error: {
|
||||
Unauthorized: "目前您的狀態是未授權,請前往設定頁面輸入授權碼。",
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { SubmitKey } from "../store/config";
|
||||
import type { LocaleType } from "./index";
|
||||
import type { PartialLocaleType } from "./index";
|
||||
|
||||
const vi: LocaleType = {
|
||||
const vi: PartialLocaleType = {
|
||||
WIP: "Sắp ra mắt...",
|
||||
Error: {
|
||||
Unauthorized:
|
||||
|
Loading…
Reference in New Issue
Block a user