xcstrings-cli 1.5.0 → 1.6.1

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.
Files changed (3) hide show
  1. package/README.md +21 -11
  2. package/dist/index.js +5 -5
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -2,16 +2,9 @@
2
2
 
3
3
  [![Test](https://github.com/mshibanami/Docsloth/actions/workflows/test.yml/badge.svg)](https://github.com/mshibanami/Docsloth/actions/workflows/test.yml) [![npm version](https://badge.fury.io/js/xcstrings-cli.svg)](https://badge.fury.io/js/xcstrings-cli) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
4
 
5
- This is a command-line tool designed for working with **xcstrings** files, we follow these principles:
5
+ This is a command-line tool designed for working with **xcstrings** files, such as adding and removing localized strings. It supports JSON5 and YAML formats for inputting translations.
6
6
 
7
- - **Preserve Xcode’s formatting**: It avoids making unnecessary changes to `xcstrings` files generated by Xcode, including indentation, spacing, and ordering.
8
- - **No automatic translation**: It does not translate any content in your existing `xcstrings` files.
9
- - **AI-friendly workflow**: It makes it easy to import translations generated by AI services, such as ChatGPT, into your `xcstrings` files.
10
-
11
- ## AI Translation Support
12
-
13
- We also provide a Custom GPT that can help you generate translations and output them in the form of an `xcstrings` command.
14
- Check it out here: [xcstrings-cli Helper](https://chatgpt.com/g/g-69365945f8bc8191be3146f880238957-xcstrings-cli-helper).
7
+ We also provide a Custom GPT that can help you generate translations and output them in the form of an `xcstrings` 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).)
15
8
 
16
9
  ## Installation
17
10
 
@@ -35,7 +28,17 @@ This will ask you some questions and create an `xcstrings-cli.json` file in the
35
28
  # Add with key, comment, and default language string
36
29
  xcstrings add --key greeting --comment "A greeting message." --string "Hello, World."
37
30
 
38
- # Add with key, comment, and translations JSON
31
+ # Add with key, comment, and translations YAML via heredoc
32
+ xcstrings add \
33
+ --key greeting \
34
+ --comment "A greeting message." \
35
+ --strings << EOF
36
+ en: Hello, World.
37
+ ja: こんにちは、世界。
38
+ zh-Hans: 你好,世界。
39
+ EOF
40
+
41
+ # Or add translations JSON
39
42
  xcstrings add \
40
43
  --key greeting \
41
44
  --comment "A greeting message." \
@@ -47,6 +50,13 @@ xcstrings add \
47
50
  }
48
51
  EOF
49
52
 
53
+ # Add translations via file
54
+ xcstrings add \
55
+ --key greeting \
56
+ --comment "A greeting message." \
57
+ --strings-format yaml \
58
+ --strings < translations.yaml
59
+
50
60
  # Add with only key and comment
51
61
  xcstrings add --key greeting --comment "A greeting message."
52
62
  ```
@@ -103,8 +113,8 @@ You can use `xcstrings --help` or `xcstrings <sub-command> --help` to see the li
103
113
  * `--strings-format`: `string` (Optional, default: `auto`)
104
114
  * The format of the data provided with `--strings`. Options are:
105
115
  * `auto`: Auto-detect format based on content.
106
- * `json`: JSON format. (It uses `json5` internally.)
107
116
  * `yaml`: YAML format. (It uses `js-yaml` internally.)
117
+ * `json`: JSON format. (It uses `json5` internally.)
108
118
  * `--comment`: `string` (Optional)
109
119
  * The comment for the string to add, intended for translators.
110
120
 
package/dist/index.js CHANGED
@@ -1963,16 +1963,16 @@ const ue = (e, n) => {
1963
1963
  }
1964
1964
  const r = [];
1965
1965
  try {
1966
- return ue(Le.parse(i), "json");
1966
+ return ue(mn.load(i), "yaml");
1967
1967
  } catch (o) {
1968
- r.push(`json error: ${fe(o)}`);
1968
+ r.push(`yaml error: ${fe(o)}`);
1969
1969
  }
1970
1970
  try {
1971
- return ue(mn.load(i), "yaml");
1971
+ return ue(Le.parse(i), "json");
1972
1972
  } catch (o) {
1973
- r.push(`yaml error: ${fe(o)}`);
1973
+ r.push(`json error: ${fe(o)}`);
1974
1974
  }
1975
- throw new Error(`Failed to parse --strings input. Provide valid JSON or YAML, or specify --strings-format. ${r.join(" | ")}`);
1975
+ throw new Error(`Failed to parse --strings input. Provide valid YAML or JSON, or specify --strings-format. ${r.join(" | ")}`);
1976
1976
  };
1977
1977
  async function si() {
1978
1978
  return new Promise((e) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xcstrings-cli",
3
- "version": "1.5.0",
3
+ "version": "1.6.1",
4
4
  "description": "A command line tool for handling xcstrings files.",
5
5
  "type": "module",
6
6
  "bin": {