Loading...
Loading...
Compare original and translation side by side
*.yamlbuilt.jstypes.tsnpx intl*.yamlbuilt.jstypes.tsnpx intlnpx intl hola # init dictionaries (default: src/lib/intl/)
npx intl hola -p ./custom/path # init at custom path
npx intl add key.path "Value" "context" # add new key (errors if exists), context optional
npx intl add key.path "Value" --debug # optional: print OpenAI request before API call
npx intl set key.path "Updated value" # update existing key
npx intl set key.path "Value" --debug # same (--debug on add/set)
npx intl set "mount/key.path" "Value" # set in mount
npx intl const key.path "Same everywhere" # same value across all locales (no translation)
npx intl unit items.count "item" # pluralized entry (auto-generates plural forms)
npx intl move old.key new.key # rename key/branch
npx intl del key.path # delete key/branch
npx intl create es # new locale (BCP 47 tag, auto-translates)
npx intl destroy es # delete locale
npx intl mount foo ./any/path # create mount
npx intl unmount foo # remove mount (keeps files)
npx intl context "Project description" # set project-wide translation guidance
npx intl context --clear # clear project context
npx intl genders true # enable gender-aware translations
npx intl genders false # disable
npx intl sync en # re-translate all from source (EXPENSIVE — avoid)
npx intl sync en key.path # re-translate specific key
npx intl build # rebuild JS/TS from YAMLnpx intl hola # 初始化字典(默认路径:src/lib/intl/)
npx intl hola -p ./custom/path # 在自定义路径初始化
npx intl add key.path "Value" "context" # 添加新键(若已存在则报错),context为可选参数
npx intl add key.path "Value" --debug # 可选:在调用API前打印OpenAI请求信息
npx intl set key.path "Updated value" # 更新已有键值
npx intl set key.path "Value" --debug # 同上(add/set命令均支持--debug参数)
npx intl set "mount/key.path" "Value" # 在挂载目录中设置键值
npx intl const key.path "Same everywhere" # 为所有语言设置相同值(不进行翻译)
npx intl unit items.count "item" # 添加复数条目(自动生成复数形式)
npx intl move old.key new.key # 重命名键/分支
npx intl del key.path # 删除键/分支
npx intl create es # 创建新语言(需符合BCP 47规范,自动翻译)
npx intl destroy es # 删除语言
npx intl mount foo ./any/path # 创建挂载
npx intl unmount foo # 移除挂载(保留文件)
npx intl context "Project description" # 设置项目级翻译指导上下文
npx intl context --clear # 清除项目上下文
npx intl genders true # 启用性别感知翻译
npx intl genders false # 禁用性别感知翻译
npx intl sync en # 从源语言重新翻译所有内容(成本高,尽量避免)
npx intl sync en key.path # 重新翻译指定键
npx intl build # 从YAML文件重新生成JS/TS文件native: English
example:
hello: "Hello world"{$dict.example.hello}native: English
example:
hello: "Hello world"{$dict.example.hello}!jsnpx intl set greeting "Hello, {name}!" # {name} → function param
npx intl set joined "[names] joined {groupName}" # [names] → Intl.ListFormat!jsintl setnpx intl set greeting '!js (count) => `${count || "No"} item${count === 1 ? "" : "s"}`'{$dict.greeting(user.name)}!jsnpx intl set greeting "Hello, {name}!" # {name} → 函数参数
npx intl set joined "[names] joined {groupName}" # [names] → Intl.ListFormatintl set!jsnpx intl set greeting '!js (count) => `${count || "No"} item${count === 1 ? "" : "s"}`'{$dict.greeting(user.name)}npx intl unitIntl.PluralRulesnpx intl unit items.count "item"items:
count:
- one: item
other: items{$dict.items.count(count)}fewmanynpx intl unitIntl.PluralRulesnpx intl unit items.count "item"items:
count:
- one: item
other: items{$dict.items.count(count)}fewmanynpx intl genders truegender: 'he' | 'she' | 'none'npx intl genders truegender: 'he' | 'she' | 'none'npx intl mount admin ./src/features/admin/intl
npx intl set "admin/dashboard.title" "Admin Dashboard"{mount}/npx intl mount admin ./src/features/admin/intl
npx intl set "admin/dashboard.title" "Admin Dashboard"{mount}/<script lang="ts">
import { dict, locale } from '$lib/intl'
</script>
<h1>{$dict.example.hello}</h1><script lang="ts">
import { dict } from './intl'
</script>
<h1>{$dict.dashboard.title}</h1>intl/index.tsimport { derived } from 'svelte/store'
import { locale } from '$lib/intl'
import { dictionaries } from './built.js'
import type { Locale, Dictionary } from './types'
const dict = derived(locale, ($locale) => dictionaries[$locale])
export { dict, dictionaries, locale }
export type { Locale, Dictionary }<script lang="ts">
import { dict, locale } from '$lib/intl'
</script>
<h1>{$dict.example.hello}</h1><script lang="ts">
import { dict } from './intl'
</script>
<h1>{$dict.dashboard.title}</h1>intl/index.tsimport { derived } from 'svelte/store'
import { locale } from '$lib/intl'
import { dictionaries } from './built.js'
import type { Locale, Dictionary } from './types'
const dict = derived(locale, ($locale) => dictionaries[$locale])
export { dict, dictionaries, locale }
export type { Locale, Dictionary }npx intl set app.welcome "Welcome" "greeting shown on homepage"
npx intl context "B2B SaaS for enterprise users"context.yamlnpx intl set app.welcome "Welcome" "greeting shown on homepage"
npx intl context "B2B SaaS for enterprise users"context.yamlnpx intl set/unit/constnpx intl builddict$dict.key.pathnpx intl set/unit/constnpx intl builddict$dict.key.pathnpx intl syncen-USespt-BRnpx intl syncen-USespt-BR