|
1 | 1 | # langcodec-cli (Command Line) |
2 | 2 |
|
3 | | -Universal CLI for converting, inspecting, and merging localization files. |
| 3 | +Universal CLI for converting, inspecting, merging, and editing localization files. |
4 | 4 |
|
5 | 5 | - Formats: Apple `.strings`, `.xcstrings`, Android `strings.xml`, CSV, TSV |
6 | | -- Commands: convert, merge, view, stats, debug |
| 6 | +- Commands: convert, merge, view, stats, debug, edit |
7 | 7 |
|
8 | 8 | ## Install |
9 | 9 |
|
@@ -51,11 +51,50 @@ Shows per-language totals, counts by status, and completion percent (excludes Do |
51 | 51 | langcodec debug -i input.strings --lang en -o output.json |
52 | 52 | ``` |
53 | 53 |
|
| 54 | +### edit |
| 55 | + |
| 56 | +Unified in-place editing (add/update/remove) across one or many files. |
| 57 | + |
| 58 | +Basics: |
| 59 | + |
| 60 | +```sh |
| 61 | +# Add or update a key |
| 62 | +langcodec edit set -i en.strings -k welcome -v "Hello" --status translated --comment "Shown on home" |
| 63 | + |
| 64 | +# Remove a key (omit or empty value) |
| 65 | +langcodec edit set -i en.strings -k welcome |
| 66 | +langcodec edit set -i en.strings -k welcome -v "" |
| 67 | + |
| 68 | +# Multiple files or globs (quote patterns) |
| 69 | +langcodec edit set -i 'locales/**/*.strings' -k app_name -v "My App" |
| 70 | +langcodec edit set -i a.strings -i b.strings -k welcome -v "Hello" |
| 71 | + |
| 72 | +# Preview only |
| 73 | +langcodec edit set -i en.strings -k welcome -v "Hello" --dry-run |
| 74 | + |
| 75 | +# Write to a different file (single input only) |
| 76 | +langcodec edit set -i en.strings -k welcome -v "Hello" -o out.strings |
| 77 | +``` |
| 78 | + |
| 79 | +Options: |
| 80 | + |
| 81 | +- --inputs/-i: One or more input files. Supports glob patterns when quoted. |
| 82 | +- --lang/-l: Language code (required when an input contains multiple languages). |
| 83 | +- --key/-k: Entry key to modify. |
| 84 | +- --value/-v: New value. If omitted or empty, the entry is removed. |
| 85 | +- --comment: Optional translator note. |
| 86 | +- --status: translated|needs_review|new|do_not_translate|stale. |
| 87 | +- --output/-o: Optional output path. Not allowed with multiple inputs. |
| 88 | +- --dry-run: Print what would change and exit without writing. |
| 89 | +- --continue-on-error: Process all inputs; report failures at the end (non-zero exit if any fail). |
| 90 | + |
| 91 | +Supported formats: .strings, .xml (Android), .xcstrings, .csv, .tsv. Custom JSON/YAML/.langcodec edit is currently not enabled. |
| 92 | + |
54 | 93 | ## Notes |
55 | 94 |
|
56 | 95 | - Android plurals `<plurals>` are supported. |
57 | 96 | - Language inference: `en.lproj/Localizable.strings`, `values-es/strings.xml`, base `values/` → `en` by default. |
58 | | -- Globbing: use quotes for patterns in merge (e.g., `'**/*.xml'`). |
| 97 | +- Globbing: use quotes for patterns in merge and edit (e.g., `'**/*.xml'`). |
59 | 98 |
|
60 | 99 | ## License |
61 | 100 |
|
|
0 commit comments