diff --git a/src/i18n.ts b/src/i18n.ts index a4155e8a89..96481ccfa2 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -2,18 +2,20 @@ import { getRequestConfig } from "next-intl/server" import { Language } from "./lib/types" -export const locales: Language[] = ["en", "ja", "zh", "zh-TW"] +export const locales: Language[] = ["en", "ja", "zh", "zh-TW", "tr"] export const languageNames: Record<(typeof locales)[number], string> = { en: "English", ja: "Japanese", zh: "Chinese (Simplified)", "zh-TW": "Chinese (Traditional)", + tr: "Turkish", } export const nameMap: Record = { en: "English", zh: "简体中文", "zh-TW": "繁體中文", ja: "日本語", + tr: "Turkish", } export const defaultLocale = "en" diff --git a/src/lib/detect-lang.ts b/src/lib/detect-lang.ts index d5e3c92742..1692fa9b76 100644 --- a/src/lib/detect-lang.ts +++ b/src/lib/detect-lang.ts @@ -8,6 +8,7 @@ const _thresholds: Thresholds = { en: 0.8, zh: 0.3, ja: 0.5, + tr: 0.7, } export function detectLanguage( @@ -48,6 +49,7 @@ export function detectLanguage( en: XRegExp("\\p{Latin}", "gi"), zh: XRegExp("\\p{Han}", "gi"), ja: XRegExp("[\\p{Hiragana}\\p{Katakana}]", "gi"), + tr: XRegExp("[\\p{Latin}&&[^\\p{Common}]]", "gi"), } for (const [lang, regex] of Object.entries(regexes)) { diff --git a/src/lib/types.ts b/src/lib/types.ts index 23b3a3fe0a..10ae7bc589 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -1,7 +1,7 @@ import type { CharacterEntity, NoteEntity } from "crossbell" import type { BundledTheme } from "shiki/themes" -export type Language = Readonly<"en" | "zh" | "zh-TW" | "ja"> +export type Language = Readonly<"en" | "zh" | "zh-TW" | "ja" | "tr"> export type Site = { id: string