template_0205

This commit is contained in:
Sofio
2026-02-05 13:16:05 +08:00
commit d93e4d9c9f
197 changed files with 52810 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
import i18n from "i18next"
import type { TOptions } from "i18next"
import { TxKeyPath } from "."
/**
* Translates text.
* @param {TxKeyPath} key - The i18n key.
* @param {TOptions} options - The i18n options.
* @returns {string} - The translated text.
* @example
* Translations:
*
* ```en.ts
* {
* "hello": "Hello, {{name}}!"
* }
* ```
*
* Usage:
* ```ts
* import { translate } from "./i18n"
*
* translate("hello", { name: "world" })
* // => "Hello world!"
* ```
*/
export function translate(key: TxKeyPath, options?: TOptions): string {
if (i18n.isInitialized) {
return i18n.t(key, options)
}
return key
}