You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: support localePattern option for locale structured with directory (#270)
* feat: support `localePattern` option for locale structured with directory
* fix: support string value
* Replace judgment of localeKey with common method
Co-authored-by: Yosuke Ota <[email protected]>
@@ -71,15 +79,25 @@ See [the rule list](../rules/)
71
79
### `settings['vue-i18n']`
72
80
73
81
-`localeDir` ... You can specify a string or an object or an array.
82
+
74
83
- String option ... A glob for specifying files that store localization messages of project.
75
84
- Object option
76
85
-`pattern` (`string`) ... A glob for specifying files that store localization messages of project.
77
-
-`localeKey` (`'file' | 'key'`) ... Specifies how to determine the locale for localization messages.
86
+
-`localeKey` (`'file' | 'path' | 'key'`) ... Specifies how to determine the locale for localization messages.
78
87
-`'file'` ... Determine the locale name from the filename. The resource file should only contain messages for that locale. Use this option if you use `vue-cli-plugin-i18n`. This option is also used when String option is specified.
88
+
-`'path'` ... Determine the locale name from the path. In this case, the locale must be had structured with your rule on the path. It can be captured with the regular expression named capture. The resource file should only contain messages for that locale.
79
89
-`'key'` ... Determine the locale name from the root key name of the file contents. The value of that key should only contain messages for that locale. Used when the resource file is in the format given to the `messages` option of the `VueI18n` constructor option.
80
-
- Array option ... An array of String option and Object option. Useful if you have multiple locale directories.
90
+
-`localePattern` ... Specifies how to determine pattern the locale for localization messages. This option means, when `localeKey` is `'path'`, you will need to capture the locale using a regular expression. You need to use the locale capture as a named capture `?<locale>`, so it’s be able to capture from the path of the locale resources. If you omit it, it will be captured from the resource path with the same regular expression pattern as `vue-cli-plugin-i18n`.
91
+
92
+
- Array option ... An array of String option and Object option. Useful if you have multiple locale directories.
81
93
-`messageSyntaxVersion` (Optional) ... Specify the version of `vue-i18n` you are using. If not specified, the message will be parsed twice. Also, some rules require this setting.
82
94
95
+
::: warn NOTE
96
+
97
+
The `localePattern` options does not support SFC i18n custom blocks (`src` attribute), only for resources of files to import when specified in VueI18n's `messages` options (VueI18n v9 and later, `messages` specified in `createI18n`) for resources of files to import.
98
+
99
+
:::
100
+
83
101
### Running ESLint from command line
84
102
85
103
If you want to run `eslint` from command line, make sure you include the `.vue`, `.json`, `.json5`, `.yaml` and `.yml` extension using [the `--ext` option](https://eslint.org/docs/user-guide/configuring#specifying-file-extensions-to-lint) or a glob pattern because ESLint targets only `.js` files by default.
Copy file name to clipboardExpand all lines: lib/types/settings.ts
+12-2
Original file line number
Diff line number
Diff line change
@@ -2,10 +2,12 @@
2
2
* How to determine the locale for localization messages.
3
3
* - `'file'` ... Determine the locale name from the filename. The resource file should only contain messages for that locale.
4
4
* Use this option if you use `vue-cli-plugin-i18n`. This method is also used when String option is specified.
5
-
* - `'key'` ... Determine the locale name from the root key name of the file contents. The value of that key should only contain messages for that locale.
5
+
* - `'path'` ... Determine the locale name from the path of resource. In this case, the locale must be had structured with your rule on the path.
6
+
* It can be captured with the regular expression named capture. The resource file should only contain messages for that locale.
7
+
* - `'key'` ... Determine the locale name from the root key name of the file contents. The value of that key should only contain messages for that locale.
6
8
* Used when the resource file is in the format given to the `messages` option of the `VueI18n` constructor option.
0 commit comments