Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

730 B
Raw Blame
import type { LanguageDetectorModule } from 'i18next'
import { getLocales } from 'expo-localization'

/**
 * App 内没有语言切换入口,语言唯一的来源是设备区域设置,因此检测是**同步**的:
 * 不需要异步 `LanguageDetectorAsyncModule`(lexim 那种「读 store 再回退设备区域」),
 * 也就不需要把语言写回持久化存储。
 */
export function detectLanguage(): string {
  const tag = getLocales()[0]?.languageTag.toLowerCase() ?? 'en-US'
  if (tag.startsWith('zh'))
    return 'zh-CN'
  if (tag.startsWith('ko'))
    return 'ko-KR'
  return 'en-US'
}

export const languageDetector: LanguageDetectorModule = {
  type: 'languageDetector',
  detect: () => detectLanguage(),
}