xcstrings-cli 1.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/.changeset/README.md +8 -0
- package/.changeset/config.json +11 -0
- package/.github/workflows/release.yml +56 -0
- package/.markdownlint.json +3 -0
- package/.prettierrc +7 -0
- package/LICENSE +19 -0
- package/README.md +120 -0
- package/dist/index.js +659 -0
- package/package.json +51 -0
- package/src/commands/_shared.ts +63 -0
- package/src/commands/add.ts +38 -0
- package/src/commands/index.ts +5 -0
- package/src/commands/init.ts +159 -0
- package/src/commands/languages.ts +43 -0
- package/src/commands/remove.ts +9 -0
- package/src/index.ts +126 -0
- package/src/utils/cli.ts +60 -0
- package/src/utils/config.ts +32 -0
- package/src/utils/logger.ts +7 -0
- package/tests/cli.heredoc.test.ts +44 -0
- package/tests/cli.stdin.test.ts +61 -0
- package/tests/cli.unknown.test.ts +24 -0
- package/tests/commands.test.ts +38 -0
- package/tests/config.test.ts +54 -0
- package/tests/fixtures/manual-comment-3langs.xcstrings +32 -0
- package/tests/fixtures/no-strings.xcstrings +5 -0
- package/tests/fixtures/test.xcodeproj/project.pbxproj +86 -0
- package/tests/formatting.test.ts +72 -0
- package/tests/languages.test.ts +21 -0
- package/tests/utils/resources.ts +4 -0
- package/tests/utils/testFileHelper.ts +30 -0
- package/tsconfig.json +19 -0
- package/vite.config.ts +32 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Changesets
|
|
2
|
+
|
|
3
|
+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
|
|
4
|
+
with multi-package repos, or single-package repos to help you version and publish your code. You can
|
|
5
|
+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
|
|
6
|
+
|
|
7
|
+
We have a quick list of common questions to get you started engaging with this project in
|
|
8
|
+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://unpkg.com/@changesets/config@3.1.2/schema.json",
|
|
3
|
+
"changelog": "@changesets/cli/changelog",
|
|
4
|
+
"commit": false,
|
|
5
|
+
"fixed": [],
|
|
6
|
+
"linked": [],
|
|
7
|
+
"access": "public",
|
|
8
|
+
"baseBranch": "main",
|
|
9
|
+
"updateInternalDependencies": "patch",
|
|
10
|
+
"ignore": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
push:
|
|
6
|
+
branches:
|
|
7
|
+
- main
|
|
8
|
+
|
|
9
|
+
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
contents: write
|
|
13
|
+
pull-requests: write
|
|
14
|
+
id-token: write
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
release:
|
|
18
|
+
name: Release
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
steps:
|
|
21
|
+
- name: Checkout repository
|
|
22
|
+
uses: actions/checkout@v4
|
|
23
|
+
with:
|
|
24
|
+
fetch-depth: 0
|
|
25
|
+
|
|
26
|
+
- name: Setup pnpm
|
|
27
|
+
uses: pnpm/action-setup@v4
|
|
28
|
+
with:
|
|
29
|
+
version: 10
|
|
30
|
+
|
|
31
|
+
- name: Setup Node.js
|
|
32
|
+
uses: actions/setup-node@v4
|
|
33
|
+
with:
|
|
34
|
+
node-version: 20
|
|
35
|
+
cache: "pnpm"
|
|
36
|
+
registry-url: "https://registry.npmjs.org"
|
|
37
|
+
|
|
38
|
+
- name: Upgrade npm (for OIDC)
|
|
39
|
+
run: npm install -g npm@latest
|
|
40
|
+
|
|
41
|
+
- name: Install dependencies
|
|
42
|
+
run: pnpm install --frozen-lockfile
|
|
43
|
+
|
|
44
|
+
- name: Build packages
|
|
45
|
+
run: pnpm build
|
|
46
|
+
|
|
47
|
+
- name: Create Release Pull Request or Publish
|
|
48
|
+
id: changesets
|
|
49
|
+
uses: changesets/action@v1
|
|
50
|
+
with:
|
|
51
|
+
version: pnpm changeset version
|
|
52
|
+
publish: pnpm release
|
|
53
|
+
title: "chore: version packages"
|
|
54
|
+
commit: "chore: version packages"
|
|
55
|
+
env:
|
|
56
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
package/.prettierrc
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2025 Manabu Nakazawa (https://github.com/mshibanami)
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# xcstrings-cli
|
|
2
|
+
|
|
3
|
+
A command-line tool designed for working with **xcstrings** files.
|
|
4
|
+
|
|
5
|
+
## Guiding Principles
|
|
6
|
+
|
|
7
|
+
This tool is built with the following goals in mind:
|
|
8
|
+
|
|
9
|
+
- **Preserve Xcode’s formatting**: It avoids making unnecessary changes to `xcstrings` files generated by Xcode, including indentation, spacing, and ordering.
|
|
10
|
+
- **No automatic translation**: It does not translate any content in your existing `xcstrings` files. The tool’s purpose is to help you manage and manipulate the files.
|
|
11
|
+
- **AI-friendly workflow**: It is designed to make it easy to import translations generated by AI services now and in the future.
|
|
12
|
+
|
|
13
|
+
## AI Translation Support
|
|
14
|
+
|
|
15
|
+
We also provide a Custom GPT that can help you generate translations and output them in the form of an `xcstrings` command.
|
|
16
|
+
Check it out here: [xcstrings-cli Helper](https://chatgpt.com/g/g-69365945f8bc8191be3146f880238957-xcstrings-cli-helper).
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
1. Install xcstrings-cli using npm:
|
|
21
|
+
```bash
|
|
22
|
+
npm install -g xcstrings-cli
|
|
23
|
+
# or
|
|
24
|
+
yarn global add xcstrings-cli
|
|
25
|
+
# or
|
|
26
|
+
pnpm global add xcstrings-cli
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
2. Initialize xcstrings-cli
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
xcstrings init
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
This will ask you some questions and create a `xcstrings-cli.json` file in the current directory.
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
**Add a string:**
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
xcstrings add \
|
|
43
|
+
--key greeting \
|
|
44
|
+
--comment "Hello, World" \
|
|
45
|
+
--strings << EOF
|
|
46
|
+
{
|
|
47
|
+
"ja": "こんにちは、世界.",
|
|
48
|
+
"en": "Hello, World.",
|
|
49
|
+
"zh-Hans": "你好,世界."
|
|
50
|
+
}
|
|
51
|
+
EOF
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Remove a string:**
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
xcstrings remove --key greeting
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
List supported languages:**
|
|
61
|
+
|
|
62
|
+
This command lists all languages by checking xcstrings files and your Xcode project settings (`.pbxproj` specified in the config files as `xcodeprojPaths`).
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
xcstrings languages
|
|
66
|
+
# en ja zh-Hans
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
You can use `xcstrings --help` or `xcstrings <sub-command> --help` to see the list of commands and options.
|
|
70
|
+
|
|
71
|
+
## Command options
|
|
72
|
+
|
|
73
|
+
- `--help, -h`: `boolean` (Optional)
|
|
74
|
+
- Show help.
|
|
75
|
+
- `--version, -v`: `boolean` (Optional)
|
|
76
|
+
- Show version.
|
|
77
|
+
- `--config`: `string` (Optional)
|
|
78
|
+
- The custom config file path. If not specified, xcstrings-cli will look for `xcstrings-cli.json` or `xcstrings-cli.json5` in the current folder or its parent folders until the root.
|
|
79
|
+
|
|
80
|
+
### `add` command options
|
|
81
|
+
|
|
82
|
+
- `--strings, -s`: `string | string[] | { [key: string]: string }` (Required)
|
|
83
|
+
- The strings to add/remove.
|
|
84
|
+
- If only one string is provided, xcstrings-cli will use it as a default string.
|
|
85
|
+
- `--comment, -c`: `string` (Optional)
|
|
86
|
+
- The comment of the string to add for translators.
|
|
87
|
+
- `--extractionState, -e`: `string` (Optional, default: `manual`)
|
|
88
|
+
- The extraction state of the string to add. `translated` or `manual`.
|
|
89
|
+
- `--help`: `boolean` (Optional)
|
|
90
|
+
- Show help.
|
|
91
|
+
|
|
92
|
+
## Config file
|
|
93
|
+
|
|
94
|
+
Put a `xcstrings-cli.json5` or `xcstrings-cli.json` file in the project root, then xcstrings-cli will use it as a config file.
|
|
95
|
+
|
|
96
|
+
```json5
|
|
97
|
+
{
|
|
98
|
+
"xcstringsPaths": [
|
|
99
|
+
"Shared/L10n/Localizable.xcstrings",
|
|
100
|
+
{
|
|
101
|
+
"alias": "utils",
|
|
102
|
+
"path": "packages/Utils/Sources/Utils/Resources/Localizable.xcstrings"
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
"xcodeprojPaths": [
|
|
106
|
+
"path/to/your/Project.xcodeproj"
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
These are the options for the config file:
|
|
112
|
+
|
|
113
|
+
- xcstringsPaths: `string[] | { alias: string, path: string }[]`
|
|
114
|
+
- The path to the xcstrings file.
|
|
115
|
+
- If only one path is provided, xcstrings-cli will use it as a default xcstrings file.
|
|
116
|
+
- If multiple paths are provided, xcstrings-cli will ask you to select a xcstrings file.
|
|
117
|
+
|
|
118
|
+
## LICENSE
|
|
119
|
+
|
|
120
|
+
MIT
|