config.ts - 国际化配置

config.ts - 国际化配置

概述

定义国际化相关的常量和配置,包括支持的语言列表、默认语言、RTL 语言等。

常量定义

LOCALE_COOKIE

export const LOCALE_COOKIE = "NEXT_LOCALE";

存储用户语言偏好的 Cookie 名称。

supportedLocales

export const supportedLocales = [
  "en", "tr", "es", "zh", "ja", "ar", "pt", "fr", 
  "it", "de", "nl", "ko", "ru", "he", "el", "fa", "az"
];

应用程序支持的所有语言代码列表。

defaultLocale

export const defaultLocale = "en";

当无法检测用户语言偏好时使用的默认语言。

rtlLocales

export const rtlLocales = ["ar", "he", "fa"];

需要从右到左(RTL)书写的语言列表。这些语言需要特殊的布局处理。

函数

isRtlLocale

export function isRtlLocale(locale: string): boolean

检查指定语言是否为 RTL 语言。

参数:

  • locale: 语言代码

返回值:

  • boolean: 是否为 RTL 语言

示例:

isRtlLocale("ar");  // true
isRtlLocale("en");  // false

getSupportedLocales

export function getSupportedLocales(): string[]

获取支持的语言列表。

getDefaultLocale

export function getDefaultLocale(): string

获取默认语言代码。

← 返回目录