Skip to content

Function: useValaxyI18n()

ts
function useValaxyI18n(): object;

Defined in: packages/valaxy/client/composables/locale.ts:84

Experimental

$locale: 开头的 key 会被认为是国际化的 key 会从 locales/ 目录中获取对应的翻译

Returns

$t

ts
$t: (key) => string;

vue-i18n t function

translate $locale:key

Parameters

key

string

Returns

string

$tCategory

ts
$tCategory: (key) => string;

translate category name (auto-lookup category.{key} in locale files)

Parameters

key

string

Returns

string

$tO

ts
$tO: <T>(data?) => string | T;

translate object

{ "zh-CN": "你好", "en": "Hello" }

Type Parameters

T

T = string

Parameters

data?

string | Record<string, T>

Returns

string | T

$tTag

ts
$tTag: (key) => string;

translate tag name (auto-lookup tag.{key} in locale files)

Parameters

key

string

Returns

string

$tTerm

ts
$tTerm: (namespace, key) => string;

translate taxonomy term (auto-lookup {namespace}.{key} in locale files)

Parameters

namespace

TaxonomyNamespace

key

string

Returns

string

En

Translate a taxonomy term.

Resolution order:

  1. $locale: prefix → strip and translate via t()
  2. Locale key {namespace}.{key} exists → translate via t()
  3. Fallback → return the original key as-is

The result is cached by locale + namespace + key to avoid repeated te() / t() lookups in tag clouds and category trees.

Zh

翻译 taxonomy 术语。

解析顺序:

  1. $locale: 前缀 → 去掉前缀后通过 t() 翻译
  2. locale 中存在 {namespace}.{key} → 通过 t() 翻译
  3. 兜底 → 原样返回

结果会按 locale + namespace + key 做轻量缓存, 避免标签云和分类树中重复执行 te() / t()

locale

ts
locale: WritableComputedRef<string, string>;