xcstrings-cli 2.5.1 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -26
- package/dist/index.js +1948 -1878
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ We also provide a Custom GPT that can help you generate translations and output
|
|
|
28
28
|
|
|
29
29
|
```bash
|
|
30
30
|
# Add with key, comment, and default language string
|
|
31
|
-
xcs add --key greeting --comment "A greeting message." --
|
|
31
|
+
xcs add --key greeting --comment "A greeting message." --text "Hello, World."
|
|
32
32
|
|
|
33
33
|
# Add with key, comment, and translations YAML via heredoc
|
|
34
34
|
xcs add \
|
|
@@ -52,6 +52,9 @@ xcs add \
|
|
|
52
52
|
}
|
|
53
53
|
EOF
|
|
54
54
|
|
|
55
|
+
# Start interactive mode to add translations using `$EDITOR` environment variable (e.g. `vim`)
|
|
56
|
+
xcs add -i
|
|
57
|
+
|
|
55
58
|
# Add translations via file
|
|
56
59
|
xcs add \
|
|
57
60
|
--key greeting \
|
|
@@ -153,22 +156,29 @@ You can use `xcs --help` or `xcs <sub-command> --help` to see the list of comman
|
|
|
153
156
|
|
|
154
157
|
## Commands
|
|
155
158
|
|
|
156
|
-
|
|
159
|
+
**Global options:**
|
|
157
160
|
|
|
158
|
-
* `--help, -h`: `boolean` (Optional)
|
|
159
|
-
* Show help.
|
|
160
|
-
* `--version, -v`: `boolean` (Optional)
|
|
161
|
-
* Show version.
|
|
162
161
|
* `--config`: `string` (Optional)
|
|
163
162
|
* The custom config file path. If not specified, `xcs` will look for `xcstrings-cli.json` or `xcstrings-cli.json5` in the current folder or its parent folders until the root.
|
|
163
|
+
* `--help, -h`: `boolean` (Optional)
|
|
164
|
+
* Show help.
|
|
164
165
|
* `--path`: `string` (Optional)
|
|
165
166
|
* The xcstrings file path. Defaults to `Localizable.xcstrings` in the current directory, or to the first `xcstringsPaths` entry in the config when present.
|
|
166
167
|
* You can also specify the alias you set in the config file. (`xcstringsPaths` entry with `alias` field)
|
|
168
|
+
* `--version, -v`: `boolean` (Optional)
|
|
169
|
+
* Show version.
|
|
167
170
|
|
|
168
171
|
### `add` command
|
|
169
172
|
|
|
170
173
|
Adds/updates one or more strings to the xcstrings file.
|
|
171
174
|
|
|
175
|
+
**`add` command options:**
|
|
176
|
+
|
|
177
|
+
* `--comment`: `string` (Optional)
|
|
178
|
+
* The comment for the string to add, intended for translators.
|
|
179
|
+
* `--interactive, -i`: `boolean` (Optional)
|
|
180
|
+
* Start interactive mode to add strings.
|
|
181
|
+
* This is useful when you don't want to record a huge command to your terminal history.
|
|
172
182
|
* `--key, -k`: `string` (Required unless `--strings` contains one or more keys)
|
|
173
183
|
* The key of the string to add.
|
|
174
184
|
* `--language, -l`: `string` (Optional)
|
|
@@ -176,8 +186,6 @@ Adds/updates one or more strings to the xcstrings file.
|
|
|
176
186
|
* Ignored if `--text` is not provided.
|
|
177
187
|
* If not specified, it uses the source language defined as `sourceLanguage` in the xcstrings file.
|
|
178
188
|
* Validation follows `missingLanguagePolicy`: `skip` requires the language to be supported; `include` allows any language.
|
|
179
|
-
* `--text`: `string` (Optional)
|
|
180
|
-
* The string value for the language. If omitted, the key is created without a localization for the default language.
|
|
181
189
|
* `--state`: `string` (Optional, default: `translated`)
|
|
182
190
|
* Values applied to single-key and multi-key adds: `translated`, `needs_review`, `new`, `stale`. If omitted, strings default to `translated`.
|
|
183
191
|
* Multi-key payloads can also set per-language states with `{ state, value }`; string shorthand is treated as `translated`.
|
|
@@ -194,49 +202,58 @@ Adds/updates one or more strings to the xcstrings file.
|
|
|
194
202
|
* `auto`: Auto-detect format based on content.
|
|
195
203
|
* `yaml`: YAML format. (It uses `js-yaml` internally.)
|
|
196
204
|
* `json`: JSON format. (It uses `json5` internally.)
|
|
197
|
-
* `--
|
|
198
|
-
* The
|
|
205
|
+
* `--text`: `string` (Optional)
|
|
206
|
+
* The string value for the language. If omitted, the key is created without a localization for the default language.
|
|
199
207
|
|
|
200
208
|
### `remove` command
|
|
201
209
|
|
|
202
210
|
Removes strings from the xcstrings file based on the specified filter options.
|
|
203
211
|
|
|
212
|
+
**`remove` command options:**
|
|
213
|
+
|
|
214
|
+
* `--dry-run, -n`: `boolean` (Optional, default: `false`)
|
|
215
|
+
* If set to `true`, `xcs` will only show what would be removed without actually removing anything.
|
|
204
216
|
* `--key, -k`: `string` (Optional if `languages` is specified)
|
|
205
217
|
* The key of the string to remove. If not specified, xcstrings-cli will remove all strings for the specified languages.
|
|
206
218
|
* `--languages, -l`: `string[]` (Optional if `key` is specified)
|
|
207
219
|
* The languages to remove. If not specified, `xcs` will remove the string for all languages.
|
|
208
|
-
* `--dry-run, -n`: `boolean` (Optional, default: `false`)
|
|
209
|
-
* If set to `true`, `xcs` will only show what would be removed without actually removing anything.
|
|
210
220
|
|
|
211
221
|
### `strings` command
|
|
212
222
|
|
|
213
223
|
Lists strings in the xcstrings file, with optional filtering and formatting.
|
|
214
224
|
|
|
215
|
-
|
|
216
|
-
|
|
225
|
+
**`strings` commands options:**
|
|
226
|
+
|
|
227
|
+
* `--format`: `string` (Optional)
|
|
228
|
+
* Mustache template for per-localization output. Available variables: `{{language}}`, `{{key}}`, `{{text}}`.
|
|
217
229
|
* `--key`, `--key-glob`: `string` (Optional)
|
|
218
230
|
* Filter keys by glob pattern. This is the default key filter mode.
|
|
219
231
|
* `--key-regex`: `string` (Optional)
|
|
220
232
|
* Filter keys by regular expression.
|
|
221
233
|
* `--key-substring`: `string` (Optional)
|
|
222
234
|
* Filter keys by substring match.
|
|
235
|
+
* `--languages, -l`: `string[]` (Optional)
|
|
236
|
+
* Include only the specified languages.
|
|
223
237
|
* `--text`, `--text-glob`: `string` (Optional)
|
|
224
238
|
* Filter translations by glob pattern. This is the default text filter mode.
|
|
225
239
|
* `--text-regex`: `string` (Optional)
|
|
226
240
|
* Filter translations by regular expression.
|
|
227
241
|
* `--text-substring`: `string` (Optional)
|
|
228
242
|
* Filter translations by substring match.
|
|
229
|
-
* `--format`: `string` (Optional)
|
|
230
|
-
* Mustache template for per-localization output. Available variables: `{{language}}`, `{{key}}`, `{{text}}`.
|
|
231
243
|
|
|
232
244
|
## Config file
|
|
233
245
|
|
|
234
|
-
Put
|
|
246
|
+
Put a config file named `xcstrings-cli` in the project root, using one of the following extensions:
|
|
247
|
+
|
|
248
|
+
- `.json`: JSON format
|
|
249
|
+
- `.json5`: JSON5 format
|
|
250
|
+
- `.yml` `.yaml`: YAML format
|
|
235
251
|
|
|
236
252
|
Here is an example config file in JSON format:
|
|
237
253
|
|
|
238
254
|
```json
|
|
239
255
|
{
|
|
256
|
+
"missingLanguagePolicy": "include",
|
|
240
257
|
"xcstringsPaths": [
|
|
241
258
|
"Shared/L10n/Localizable.xcstrings",
|
|
242
259
|
{
|
|
@@ -246,25 +263,24 @@ Here is an example config file in JSON format:
|
|
|
246
263
|
],
|
|
247
264
|
"xcodeprojPaths": [
|
|
248
265
|
"path/to/your/Project.xcodeproj"
|
|
249
|
-
]
|
|
250
|
-
"missingLanguagePolicy": "include"
|
|
266
|
+
]
|
|
251
267
|
}
|
|
252
268
|
```
|
|
253
269
|
|
|
254
270
|
These are the settings you can specify in the config file:
|
|
255
271
|
|
|
272
|
+
* **missingLanguagePolicy**: `string` (Optional, default: `skip`)
|
|
273
|
+
* How to handle translations for languages that are not included in the `xcs languages` output when adding strings. Options are:
|
|
274
|
+
* `skip`: Only add translations for languages included in the `xcs languages` output. (Default)
|
|
275
|
+
* `include`: Add translations even when they are not recognized by the Xcode project or xcs language list.
|
|
276
|
+
* **xcodeprojPaths**: `string[]` (Optional)
|
|
277
|
+
* Paths to Xcode project files (`.xcodeproj`) used to detect supported languages.
|
|
278
|
+
* If not specified, `xcs` will only check the xcstrings file to detect supported languages.
|
|
256
279
|
* **xcstringsPaths**: `string[] | { alias: string, path: string }[]` (Optional)
|
|
257
280
|
* Paths to xcstrings files used by `xcs`.
|
|
258
281
|
* If only one path is provided, `xcs` will use it as the default xcstrings file.
|
|
259
282
|
* If multiple paths are provided, `xcs` will ask you to select an xcstrings file.
|
|
260
283
|
* You can also specify an alias, and use it with the `--path` option.
|
|
261
|
-
* **xcodeprojPaths**: `string[]` (Optional)
|
|
262
|
-
* Paths to Xcode project files (`.xcodeproj`) used to detect supported languages.
|
|
263
|
-
* If not specified, `xcs` will only check the xcstrings file to detect supported languages.
|
|
264
|
-
* **missingLanguagePolicy**: `string` (Optional, default: `skip`)
|
|
265
|
-
* How to handle translations for languages that are not included in the `xcs languages` output when adding strings. Options are:
|
|
266
|
-
* `skip`: Only add translations for languages included in the `xcs languages` output. (Default)
|
|
267
|
-
* `include`: Add translations even when they are not recognized by the Xcode project or xcs language list.
|
|
268
284
|
|
|
269
285
|
## Practical use cases
|
|
270
286
|
|