项目设置位于 project.inlang/settings.json 中。本文档介绍所有可用的设置项。
核心设置
type ProjectSettings = {
$schema?: string;
baseLocale: string;
locales: string[];
modules?: string[];
experimental?: Record<string, true>;
};
baseLocale
必填。 项目的基础语言区域。其他所有翻译都以该语言区域为基础。
{
"baseLocale": "en"
}
必须是有效的 BCP-47 语言标签。
locales
必填。 项目中所有可用的语言区域,包括基础语言区域。
{
"baseLocale": "en",
"locales": ["en", "de", "fr", "es"]
}
- 必须包含
baseLocale - 每个语言区域都必须是有效的 BCP-47 语言标签
- 不允许重复
modules
插件模块的 URI。插件为 inlang 提供针对不同 i18n 格式的导入/导出功能。
{
"modules": [
"https://cdn.jsdelivr.net/npm/@inlang/plugin-i18next@6.1.4/dist/index.js",
"./local-plugin.js"
]
}
- 必须是有效的 URI (RFC 3986)
- 必须以
.js结尾 - 可以是绝对路径 (CDN) 或相对路径
- 请锁定支持当前 SDK 导入/导出 API 的插件版本。i18next 需使用
@inlang/plugin-i18next@6或更高版本。
experimental
用于启用实验性功能。键为功能名称,值必须为 true。
{
"experimental": {
"newFeature": true
}
}
插件设置
每个插件自行定义其设置 schema。插件设置以 plugin.<plugin-id> 为前缀。
{
"plugin.inlang.i18next": {
"pathPattern": "./locales/{locale}.json"
}
}
各插件的可用设置请参阅其在插件市场中的页面。
示例
{
"$schema": "https://inlang.com/schema/project-settings",
"baseLocale": "en",
"locales": ["en", "de", "fr", "es"],
"modules": [
"https://cdn.jsdelivr.net/npm/@inlang/plugin-i18next@6.1.4/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/plugin-t-function-matcher@3/dist/index.js"
],
"plugin.inlang.i18next": {
"pathPattern": {
"common": "./locales/{locale}/common.json",
"errors": "./locales/{locale}/errors.json"
},
"variableReferencePattern": ["{{", "}}"]
}
}
已弃用的设置
以下设置已弃用,将在 SDK v3 中移除:
| 设置 | 替代方式 |
|---|---|
sourceLanguageTag | 改用 baseLocale |
languageTags | 改用 locales |
路径中的 {languageTag} | 改用 {locale} |