xcstrings-cli 1.6.1 → 2.1.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 +90 -27
- package/dist/index.js +1793 -1368
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# xcstrings-cli
|
|
1
|
+
# xcstrings-cli (`xcs`)
|
|
2
2
|
|
|
3
3
|
[](https://github.com/mshibanami/Docsloth/actions/workflows/test.yml) [](https://badge.fury.io/js/xcstrings-cli) [](https://opensource.org/licenses/MIT)
|
|
4
4
|
|
|
5
|
-
This is a command-line tool designed for working with **
|
|
5
|
+
This is a command-line tool designed for working with **String Catalog** (`.xcstrings`) files, such as adding and removing localized strings. It supports JSON5 and YAML formats for inputting translations.
|
|
6
6
|
|
|
7
|
-
We also provide a Custom GPT that can help you generate translations and output them in the form of an `
|
|
7
|
+
We also provide a Custom GPT that can help you generate translations and output them in the form of an `xcs` command. Check it out here: [xcstrings-cli Helper](https://chatgpt.com/g/g-69365945f8bc8191be3146f880238957-xcstrings-cli-helper). (The configuration is in [helpers/helper-config.md](./helpers/helper-config.md).)
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
@@ -13,12 +13,14 @@ We also provide a Custom GPT that can help you generate translations and output
|
|
|
13
13
|
npm install -g xcstrings-cli
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
This will install the `xcs` command globally.
|
|
17
|
+
|
|
18
|
+
2. Create a configuration file for your project by running:
|
|
17
19
|
```bash
|
|
18
|
-
|
|
20
|
+
xcs init
|
|
19
21
|
```
|
|
20
22
|
|
|
21
|
-
This will ask you some questions and create an `xcstrings-cli.json` file in the current directory.
|
|
23
|
+
This will ask you some questions and create an `xcstrings-cli.json` file in the current directory.
|
|
22
24
|
|
|
23
25
|
## Usage
|
|
24
26
|
|
|
@@ -26,10 +28,10 @@ This will ask you some questions and create an `xcstrings-cli.json` file in the
|
|
|
26
28
|
|
|
27
29
|
```bash
|
|
28
30
|
# Add with key, comment, and default language string
|
|
29
|
-
|
|
31
|
+
xcs add --key greeting --comment "A greeting message." --string "Hello, World."
|
|
30
32
|
|
|
31
33
|
# Add with key, comment, and translations YAML via heredoc
|
|
32
|
-
|
|
34
|
+
xcs add \
|
|
33
35
|
--key greeting \
|
|
34
36
|
--comment "A greeting message." \
|
|
35
37
|
--strings << EOF
|
|
@@ -39,7 +41,7 @@ zh-Hans: 你好,世界。
|
|
|
39
41
|
EOF
|
|
40
42
|
|
|
41
43
|
# Or add translations JSON
|
|
42
|
-
|
|
44
|
+
xcs add \
|
|
43
45
|
--key greeting \
|
|
44
46
|
--comment "A greeting message." \
|
|
45
47
|
--strings << EOF
|
|
@@ -51,26 +53,26 @@ xcstrings add \
|
|
|
51
53
|
EOF
|
|
52
54
|
|
|
53
55
|
# Add translations via file
|
|
54
|
-
|
|
56
|
+
xcs add \
|
|
55
57
|
--key greeting \
|
|
56
58
|
--comment "A greeting message." \
|
|
57
59
|
--strings-format yaml \
|
|
58
60
|
--strings < translations.yaml
|
|
59
61
|
|
|
60
62
|
# Add with only key and comment
|
|
61
|
-
|
|
63
|
+
xcs add --key greeting --comment "A greeting message."
|
|
62
64
|
```
|
|
63
65
|
|
|
64
66
|
**Remove a string:**
|
|
65
67
|
|
|
66
68
|
```bash
|
|
67
|
-
|
|
69
|
+
xcs remove --key greeting
|
|
68
70
|
```
|
|
69
71
|
|
|
70
72
|
**Remove all strings of specific languages:**
|
|
71
73
|
|
|
72
74
|
```bash
|
|
73
|
-
|
|
75
|
+
xcs remove --languages ja zh-Hans
|
|
74
76
|
```
|
|
75
77
|
|
|
76
78
|
**List supported languages:**
|
|
@@ -78,12 +80,54 @@ xcstrings remove --languages ja zh-Hans
|
|
|
78
80
|
If `xcodeprojPaths` is configured, this command lists languages from your Xcode project (knownRegions) and excludes `Base`. If `xcodeprojPaths` is not configured, it lists languages observed in the xcstrings file.
|
|
79
81
|
|
|
80
82
|
```bash
|
|
81
|
-
|
|
83
|
+
xcs languages
|
|
82
84
|
# en ja zh-Hans
|
|
83
85
|
```
|
|
84
86
|
|
|
85
|
-
|
|
87
|
+
**List strings in the xcstrings file:**
|
|
86
88
|
|
|
89
|
+
```bash
|
|
90
|
+
# List all strings
|
|
91
|
+
xcs list
|
|
92
|
+
# helloWorld:
|
|
93
|
+
# en: "Hello, World."
|
|
94
|
+
# ja: "こんにちは、世界。"
|
|
95
|
+
# zh-Hans: "你好,世界。"
|
|
96
|
+
# goodbyeWorld:
|
|
97
|
+
# en: "Goodbye, World."
|
|
98
|
+
# ja: "さようなら、世界。"
|
|
99
|
+
# goodMorning:
|
|
100
|
+
# en: "Good morning."
|
|
101
|
+
# ja: "おはようございます。"
|
|
102
|
+
# ... etc.
|
|
103
|
+
|
|
104
|
+
# List strings filtered by key
|
|
105
|
+
xcs list --key good*
|
|
106
|
+
# goodbyeWorld:
|
|
107
|
+
# ...
|
|
108
|
+
# goodMorning:
|
|
109
|
+
# ...
|
|
110
|
+
|
|
111
|
+
# List strings filtered by language
|
|
112
|
+
xcs list --languages en
|
|
113
|
+
# helloWorld:
|
|
114
|
+
# en: "Hello, World."
|
|
115
|
+
# goodbyeWorld:
|
|
116
|
+
# en: "Goodbye, World."
|
|
117
|
+
# goodMorning:
|
|
118
|
+
# en: "Good morning."
|
|
119
|
+
# ... etc.
|
|
120
|
+
|
|
121
|
+
# List strings with custom format
|
|
122
|
+
xcs list --format "[{{language}}] {{key}} => {{text}}"
|
|
123
|
+
# [en] helloWorld => "Hello, World."
|
|
124
|
+
# [ja] helloWorld => "こんにちは、世界。"
|
|
125
|
+
# [en] goodbyeWorld => "Goodbye, World."
|
|
126
|
+
# [ja] goodbyeWorld => "さようなら、世界。"
|
|
127
|
+
# ... etc.
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
You can use `xcs --help` or `xcs <sub-command> --help` to see the list of commands and options.
|
|
87
131
|
## Command options
|
|
88
132
|
|
|
89
133
|
* `--help, -h`: `boolean` (Optional)
|
|
@@ -91,7 +135,7 @@ You can use `xcstrings --help` or `xcstrings <sub-command> --help` to see the li
|
|
|
91
135
|
* `--version, -v`: `boolean` (Optional)
|
|
92
136
|
* Show version.
|
|
93
137
|
* `--config`: `string` (Optional)
|
|
94
|
-
* The custom config file path. If not specified,
|
|
138
|
+
* 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.
|
|
95
139
|
* `--path`: `string` (Optional)
|
|
96
140
|
* The xcstrings file path. Defaults to `Localizable.xcstrings` in the current directory, or to the first `xcstringsPaths` entry in the config when present.
|
|
97
141
|
* You can also specify the alias you set in the config file. (`xcstringsPaths` entry with `alias` field)
|
|
@@ -123,14 +167,32 @@ You can use `xcstrings --help` or `xcstrings <sub-command> --help` to see the li
|
|
|
123
167
|
* `--key, -k`: `string` (Optional if `languages` is specified)
|
|
124
168
|
* The key of the string to remove. If not specified, xcstrings-cli will remove all strings for the specified languages.
|
|
125
169
|
* `--languages, -l`: `string[]` (Optional if `key` is specified)
|
|
126
|
-
* The languages to remove. If not specified,
|
|
170
|
+
* The languages to remove. If not specified, `xcs` will remove the string for all languages.
|
|
127
171
|
* `--dry-run, -n`: `boolean` (Optional, default: `false`)
|
|
128
|
-
* If set to `true`,
|
|
172
|
+
* If set to `true`, `xcs` will only show what would be removed without actually removing anything.
|
|
173
|
+
|
|
174
|
+
### `list` command options
|
|
175
|
+
|
|
176
|
+
* `--languages, -l`: `string[]` (Optional)
|
|
177
|
+
* Include only the specified languages.
|
|
178
|
+
* `--key`, `--key-glob`: `string` (Optional)
|
|
179
|
+
* Filter keys by glob pattern. This is the default key filter mode.
|
|
180
|
+
* `--key-regex`: `string` (Optional)
|
|
181
|
+
* Filter keys by regular expression.
|
|
182
|
+
* `--key-substring`: `string` (Optional)
|
|
183
|
+
* Filter keys by substring match.
|
|
184
|
+
* `--text`, `--text-glob`: `string` (Optional)
|
|
185
|
+
* Filter translations by glob pattern. This is the default text filter mode.
|
|
186
|
+
* `--text-regex`: `string` (Optional)
|
|
187
|
+
* Filter translations by regular expression.
|
|
188
|
+
* `--text-substring`: `string` (Optional)
|
|
189
|
+
* Filter translations by substring match.
|
|
190
|
+
* `--format`: `string` (Optional)
|
|
191
|
+
* Mustache template for per-localization output. Available variables: `{{language}}`, `{{key}}`, `{{text}}`.
|
|
129
192
|
|
|
130
193
|
## Config file
|
|
131
194
|
|
|
132
|
-
Put an `xcstrings-cli.json5` or `xcstrings-cli.json` file in the project root, and
|
|
133
|
-
|
|
195
|
+
Put an `xcstrings-cli.json5` or `xcstrings-cli.json` file in the project root, and xcs will use it as the config file.
|
|
134
196
|
```json5
|
|
135
197
|
{
|
|
136
198
|
"xcstringsPaths": [
|
|
@@ -148,16 +210,17 @@ Put an `xcstrings-cli.json5` or `xcstrings-cli.json` file in the project root, a
|
|
|
148
210
|
|
|
149
211
|
These are the options for the config file:
|
|
150
212
|
|
|
151
|
-
* **xcstringsPaths**: `string[] | { alias: string, path: string }[]`
|
|
152
|
-
*
|
|
153
|
-
* If
|
|
213
|
+
* **xcstringsPaths**: `string[] | { alias: string, path: string }[]` (Optional)
|
|
214
|
+
* Paths to xcstrings files used by `xcs`.
|
|
215
|
+
* If only one path is provided, `xcs` will use it as the default xcstrings file.
|
|
216
|
+
* If multiple paths are provided, `xcs` will ask you to select an xcstrings file.a
|
|
154
217
|
* **xcodeprojPaths**: `string[]` (Optional)
|
|
155
218
|
* Paths to Xcode project files used to detect supported languages.
|
|
156
|
-
* If not specified,
|
|
219
|
+
* If not specified, `xcs` will not check the supported languages in your Xcode project.
|
|
157
220
|
* **missingLanguagePolicy**: `string` (Optional, default: `skip`)
|
|
158
|
-
* How to handle translations for languages that are not included in the `
|
|
159
|
-
* `skip`: Only add translations for languages included in the `
|
|
160
|
-
* `include`: Add translations even when they are not recognized by the Xcode project or
|
|
221
|
+
* How to handle translations for languages that are not included in the `xcs languages` output when adding strings. Options are:
|
|
222
|
+
* `skip`: Only add translations for languages included in the `xcs languages` output. (Default)
|
|
223
|
+
* `include`: Add translations even when they are not recognized by the Xcode project or xcs language list.
|
|
161
224
|
|
|
162
225
|
## LICENSE
|
|
163
226
|
|