Plugin Options
root
- Type:
string
- Default:
process.cwd()
Project root directory
localesPaths
- Type:
string[]
TIP
This configuration follows vscode-i18n-ally.localesPaths
Directories for storing i18n resource files, supports multiple directories.
{
"i18n-ally.localesPaths": ["./src/locales"]
}
Or configure in vite.config.ts
:
import { defineConfig } from 'vite'
import { i18nAlly } from 'vite-plugin-i18n-ally'
export default defineConfig({
plugins: [
i18nAlly({
localesPaths: ['./src/locales'],
}),
],
})
pathMatcher
- Type:
string
TIP
This configuration follows vscode-i18n-ally.pathMatcher
Rules for matching i18n resource files. For more rules, see Path Matcher.
{
"i18n-ally.pathMatcher": "{locale}.{ext}"
}
Or configure in vite.config.ts
:
import { defineConfig } from 'vite'
import { i18nAlly } from 'vite-plugin-i18n-ally'
export default defineConfig({
plugins: [
i18nAlly({
pathMatcher: '{locale}.{ext}',
}),
],
})
namespace
- Type:
boolean
- Default:
false
TIP
This configuration follows vscode-i18n-ally.namespace
Enable namespaces. When enabled, the plugin generates corresponding resource files based on namespaces to reduce file size. You also need to modify pathMatcher
to adapt to namespace
.
If you want clear resource classification and faster resource loading, it is recommended to enable this configuration.
{
"i18n-ally.namespace": true,
"i18n-ally.pathMatcher": "{locale}/{namespace}.{ext}"
}
Or configure in vite.config.ts
:
import { defineConfig } from 'vite'
import { i18nAlly } from 'vite-plugin-i18n-ally'
export default defineConfig({
plugins: [
i18nAlly({
namespace: true,
pathMatcher: '{locale}/{namespace}.{ext}',
}),
],
})
parserPlugins
- Type:
ParserPlugin[]
Resource file parser plugins. We have built-in parsers for json
/ json5
/ yaml
/ yml
/ ts
/ js
files, and you can also customize parser plugins.
import { defineConfig } from 'vite'
import { i18nAlly } from 'vite-plugin-i18n-ally'
export default defineConfig({
plugins: [
i18nAlly({
parserPlugins: [
{
ext: 'txt',
parse: (text) => {
// 自行解析文件内容
},
}
],
}),
],
})
useVscodeI18nAllyConfig
- Type:
boolean | { stopAt: string }
- Default:
true
Whether to use vscode-i18n-ally configuration. By default, the plugin automatically searches for vscode-i18n-ally configuration from the root directory upwards.
If you are not using the vscode-i18n-ally plugin, you can disable this configuration and configure plugin options in vite.config
.
import { defineConfig } from 'vite'
import { i18nAlly } from 'vite-plugin-i18n-ally'
export default defineConfig({
plugins: [
i18nAlly({
useVscodeI18nAllyConfig: false,
// 其他插件选项
}),
],
})