xcstrings-cli 1.6.1 → 2.0.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 +28 -27
- package/package.json +2 -2
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
|
+
This will install the `xcs` command globally.
|
|
17
|
+
|
|
16
18
|
2. Initialize xcstrings-cli:
|
|
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,11 @@ 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
|
-
You can use `
|
|
86
|
-
|
|
87
|
+
You can use `xcs --help` or `xcs <sub-command> --help` to see the list of commands and options.
|
|
87
88
|
## Command options
|
|
88
89
|
|
|
89
90
|
* `--help, -h`: `boolean` (Optional)
|
|
@@ -91,7 +92,7 @@ You can use `xcstrings --help` or `xcstrings <sub-command> --help` to see the li
|
|
|
91
92
|
* `--version, -v`: `boolean` (Optional)
|
|
92
93
|
* Show version.
|
|
93
94
|
* `--config`: `string` (Optional)
|
|
94
|
-
* The custom config file path. If not specified,
|
|
95
|
+
* 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
96
|
* `--path`: `string` (Optional)
|
|
96
97
|
* The xcstrings file path. Defaults to `Localizable.xcstrings` in the current directory, or to the first `xcstringsPaths` entry in the config when present.
|
|
97
98
|
* You can also specify the alias you set in the config file. (`xcstringsPaths` entry with `alias` field)
|
|
@@ -123,14 +124,13 @@ You can use `xcstrings --help` or `xcstrings <sub-command> --help` to see the li
|
|
|
123
124
|
* `--key, -k`: `string` (Optional if `languages` is specified)
|
|
124
125
|
* The key of the string to remove. If not specified, xcstrings-cli will remove all strings for the specified languages.
|
|
125
126
|
* `--languages, -l`: `string[]` (Optional if `key` is specified)
|
|
126
|
-
* The languages to remove. If not specified,
|
|
127
|
+
* The languages to remove. If not specified, `xcs` will remove the string for all languages.
|
|
127
128
|
* `--dry-run, -n`: `boolean` (Optional, default: `false`)
|
|
128
|
-
* If set to `true`,
|
|
129
|
+
* If set to `true`, `xcs` will only show what would be removed without actually removing anything.
|
|
129
130
|
|
|
130
131
|
## Config file
|
|
131
132
|
|
|
132
|
-
Put an `xcstrings-cli.json5` or `xcstrings-cli.json` file in the project root, and
|
|
133
|
-
|
|
133
|
+
Put an `xcstrings-cli.json5` or `xcstrings-cli.json` file in the project root, and xcs will use it as the config file.
|
|
134
134
|
```json5
|
|
135
135
|
{
|
|
136
136
|
"xcstringsPaths": [
|
|
@@ -148,16 +148,17 @@ Put an `xcstrings-cli.json5` or `xcstrings-cli.json` file in the project root, a
|
|
|
148
148
|
|
|
149
149
|
These are the options for the config file:
|
|
150
150
|
|
|
151
|
-
* **xcstringsPaths**: `string[] | { alias: string, path: string }[]`
|
|
152
|
-
*
|
|
153
|
-
* If
|
|
151
|
+
* **xcstringsPaths**: `string[] | { alias: string, path: string }[]` (Optional)
|
|
152
|
+
* Paths to xcstrings files used by `xcs`.
|
|
153
|
+
* If only one path is provided, `xcs` will use it as the default xcstrings file.
|
|
154
|
+
* If multiple paths are provided, `xcs` will ask you to select an xcstrings file.a
|
|
154
155
|
* **xcodeprojPaths**: `string[]` (Optional)
|
|
155
156
|
* Paths to Xcode project files used to detect supported languages.
|
|
156
|
-
* If not specified,
|
|
157
|
+
* If not specified, `xcs` will not check the supported languages in your Xcode project.
|
|
157
158
|
* **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
|
|
159
|
+
* How to handle translations for languages that are not included in the `xcs languages` output when adding strings. Options are:
|
|
160
|
+
* `skip`: Only add translations for languages included in the `xcs languages` output. (Default)
|
|
161
|
+
* `include`: Add translations even when they are not recognized by the Xcode project or xcs language list.
|
|
161
162
|
|
|
162
163
|
## LICENSE
|
|
163
164
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xcstrings-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "A command line tool for handling xcstrings files.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"
|
|
7
|
+
"xcs": "./dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"repository": "https://github.com/mshibanami/xcstrings-cli.git",
|
|
10
10
|
"files": [
|