Skip to content

Commit

Permalink
feat(lang): add turkish language
Browse files Browse the repository at this point in the history
  • Loading branch information
OsmanTunahan committed Oct 30, 2024
1 parent cf7dc4c commit e774ec8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> = {
en: "English",
zh: "简体中文",
"zh-TW": "繁體中文",
ja: "日本語",
tr: "Turkish",
}
export const defaultLocale = "en"

Expand Down
2 changes: 2 additions & 0 deletions src/lib/detect-lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const _thresholds: Thresholds = {
en: 0.8,
zh: 0.3,
ja: 0.5,
tr: 0.7,
}

export function detectLanguage(
Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/types.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit e774ec8

Please sign in to comment.