Skip to content

Commit b28017f

Browse files
committed
Tweak docs
1 parent c63adc5 commit b28017f

3 files changed

Lines changed: 36 additions & 28 deletions

File tree

README.md

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -157,22 +157,26 @@ You can use `xcs --help` or `xcs <sub-command> --help` to see the list of comman
157157

158158
## Commands
159159

160-
### Global options
160+
**Global options:**
161161

162-
* `--help, -h`: `boolean` (Optional)
163-
* Show help.
164-
* `--version, -v`: `boolean` (Optional)
165-
* Show version.
166162
* `--config`: `string` (Optional)
167163
* 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.
164+
* `--help, -h`: `boolean` (Optional)
165+
* Show help.
168166
* `--path`: `string` (Optional)
169167
* The xcstrings file path. Defaults to `Localizable.xcstrings` in the current directory, or to the first `xcstringsPaths` entry in the config when present.
170168
* You can also specify the alias you set in the config file. (`xcstringsPaths` entry with `alias` field)
169+
* `--version, -v`: `boolean` (Optional)
170+
* Show version.
171171

172172
### `add` command
173173

174174
Adds/updates one or more strings to the xcstrings file.
175175

176+
**`add` command options:**
177+
178+
* `--comment`: `string` (Optional)
179+
* The comment for the string to add, intended for translators.
176180
* `--interactive, -i`: `boolean` (Optional)
177181
* Start interactive mode to add strings.
178182
* This is useful when you don't want to record a huge command to your terminal history.
@@ -183,8 +187,6 @@ Adds/updates one or more strings to the xcstrings file.
183187
* Ignored if `--text` is not provided.
184188
* If not specified, it uses the source language defined as `sourceLanguage` in the xcstrings file.
185189
* Validation follows `missingLanguagePolicy`: `skip` requires the language to be supported; `include` allows any language.
186-
* `--text`: `string` (Optional)
187-
* The string value for the language. If omitted, the key is created without a localization for the default language.
188190
* `--state`: `string` (Optional, default: `translated`)
189191
* Values applied to single-key and multi-key adds: `translated`, `needs_review`, `new`, `stale`. If omitted, strings default to `translated`.
190192
* Multi-key payloads can also set per-language states with `{ state, value }`; string shorthand is treated as `translated`.
@@ -201,40 +203,44 @@ Adds/updates one or more strings to the xcstrings file.
201203
* `auto`: Auto-detect format based on content.
202204
* `yaml`: YAML format. (It uses `js-yaml` internally.)
203205
* `json`: JSON format. (It uses `json5` internally.)
204-
* `--comment`: `string` (Optional)
205-
* The comment for the string to add, intended for translators.
206+
* `--text`: `string` (Optional)
207+
* The string value for the language. If omitted, the key is created without a localization for the default language.
206208
207209
### `remove` command
208210
209211
Removes strings from the xcstrings file based on the specified filter options.
210212
213+
**`remove` command options:**
214+
215+
* `--dry-run, -n`: `boolean` (Optional, default: `false`)
216+
* If set to `true`, `xcs` will only show what would be removed without actually removing anything.
211217
* `--key, -k`: `string` (Optional if `languages` is specified)
212218
* The key of the string to remove. If not specified, xcstrings-cli will remove all strings for the specified languages.
213219
* `--languages, -l`: `string[]` (Optional if `key` is specified)
214220
* The languages to remove. If not specified, `xcs` will remove the string for all languages.
215-
* `--dry-run, -n`: `boolean` (Optional, default: `false`)
216-
* If set to `true`, `xcs` will only show what would be removed without actually removing anything.
217221
218222
### `strings` command
219223
220224
Lists strings in the xcstrings file, with optional filtering and formatting.
221225
222-
* `--languages, -l`: `string[]` (Optional)
223-
* Include only the specified languages.
226+
**`strings` commands options:**
227+
228+
* `--format`: `string` (Optional)
229+
* Mustache template for per-localization output. Available variables: `{{language}}`, `{{key}}`, `{{text}}`.
224230
* `--key`, `--key-glob`: `string` (Optional)
225231
* Filter keys by glob pattern. This is the default key filter mode.
226232
* `--key-regex`: `string` (Optional)
227233
* Filter keys by regular expression.
228234
* `--key-substring`: `string` (Optional)
229235
* Filter keys by substring match.
236+
* `--languages, -l`: `string[]` (Optional)
237+
* Include only the specified languages.
230238
* `--text`, `--text-glob`: `string` (Optional)
231239
* Filter translations by glob pattern. This is the default text filter mode.
232240
* `--text-regex`: `string` (Optional)
233241
* Filter translations by regular expression.
234242
* `--text-substring`: `string` (Optional)
235243
* Filter translations by substring match.
236-
* `--format`: `string` (Optional)
237-
* Mustache template for per-localization output. Available variables: `{{language}}`, `{{key}}`, `{{text}}`.
238244
239245
## Config file
240246
@@ -244,6 +250,7 @@ Here is an example config file in JSON format:
244250
245251
```json
246252
{
253+
"missingLanguagePolicy": "include",
247254
"xcstringsPaths": [
248255
"Shared/L10n/Localizable.xcstrings",
249256
{
@@ -253,25 +260,24 @@ Here is an example config file in JSON format:
253260
],
254261
"xcodeprojPaths": [
255262
"path/to/your/Project.xcodeproj"
256-
],
257-
"missingLanguagePolicy": "include"
263+
]
258264
}
259265
```
260266
261267
These are the settings you can specify in the config file:
262268
269+
* **missingLanguagePolicy**: `string` (Optional, default: `skip`)
270+
* How to handle translations for languages that are not included in the `xcs languages` output when adding strings. Options are:
271+
* `skip`: Only add translations for languages included in the `xcs languages` output. (Default)
272+
* `include`: Add translations even when they are not recognized by the Xcode project or xcs language list.
273+
* **xcodeprojPaths**: `string[]` (Optional)
274+
* Paths to Xcode project files (`.xcodeproj`) used to detect supported languages.
275+
* If not specified, `xcs` will only check the xcstrings file to detect supported languages.
263276
* **xcstringsPaths**: `string[] | { alias: string, path: string }[]` (Optional)
264277
* Paths to xcstrings files used by `xcs`.
265278
* If only one path is provided, `xcs` will use it as the default xcstrings file.
266279
* If multiple paths are provided, `xcs` will ask you to select an xcstrings file.
267280
* You can also specify an alias, and use it with the `--path` option.
268-
* **xcodeprojPaths**: `string[]` (Optional)
269-
* Paths to Xcode project files (`.xcodeproj`) used to detect supported languages.
270-
* If not specified, `xcs` will only check the xcstrings file to detect supported languages.
271-
* **missingLanguagePolicy**: `string` (Optional, default: `skip`)
272-
* How to handle translations for languages that are not included in the `xcs languages` output when adding strings. Options are:
273-
* `skip`: Only add translations for languages included in the `xcs languages` output. (Default)
274-
* `include`: Add translations even when they are not recognized by the Xcode project or xcs language list.
275281
276282
## Practical use cases
277283

src/commands/init.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,18 @@ export async function init(): Promise<void> {
152152
const xcodeprojArray = selectedXcodeproj.map((p) => ` "${p}"`).join(',\n');
153153

154154
const config = `{
155+
// Behavior for handling missing languages when adding strings.
156+
missingLanguagePolicy: "skip",
157+
155158
// Paths to .xcstrings files to manage. Specify relative or absolute paths.
156159
xcstringsPaths: [
157160
${xcstringsArray}
158161
],
162+
159163
// Paths to .xcodeproj directories. Used for discovering supported languages.
160164
xcodeprojPaths: [
161165
${xcodeprojArray}
162-
],
163-
// Behavior for handling missing languages when adding strings.
164-
missingLanguagePolicy: "skip",
166+
]
165167
}
166168
`;
167169

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ yargs(hideBin(process.argv))
2424
})
2525
.option('path', {
2626
type: 'string',
27-
describe: 'Path to xcstrings file',
27+
describe: 'Path or alias to xcstrings file',
2828
default: defaultPath
2929
})
3030
.middleware(async (argv) => {

0 commit comments

Comments
 (0)