l10n-c 0.2.0 → 0.3.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 +11 -0
- package/package.json +3 -2
- package/skills/l10n-c/SKILL.md +84 -0
package/README.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/l10n-c)
|
|
4
|
+
[](https://www.npmjs.com/package/l10n-c)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
1
7
|
# l10n-c
|
|
2
8
|
|
|
9
|
+
> Formerly published under the working name `i18n-c`; npm reserved that name as too similar to an existing package, so the first release ships as `l10n-c`.
|
|
10
|
+
|
|
3
11
|
Locale editing CLI and bundler-independent core. Requires Node 22.12+; bundles
|
|
4
12
|
target Node 22. Translation strings stay verbatim; public tool messages are English.
|
|
5
13
|
|
|
@@ -16,6 +24,9 @@ npx l10n-c --rename 'ui.old=ui.new'
|
|
|
16
24
|
npx l10n-c --delete 'fr:ui.obsolete'
|
|
17
25
|
```
|
|
18
26
|
|
|
27
|
+
An agent skill ships in `skills/l10n-c/SKILL.md`. Copy that folder into your agent's
|
|
28
|
+
skills directory, such as `.agents/skills/` or `.claude/skills/`.
|
|
29
|
+
|
|
19
30
|
Each locale is a directory, each JSON filename a domain: `messages/en/ui.json`
|
|
20
31
|
contains `{ "ui": { "start": "Start" } }`. Keys flatten to `ui.start`; nested
|
|
21
32
|
arrays use numeric segments. Literal dotted object keys are unsupported.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "l10n-c",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Locale editing CLI and bundler-independent core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"dist",
|
|
19
|
-
"schema.json"
|
|
19
|
+
"schema.json",
|
|
20
|
+
"skills"
|
|
20
21
|
],
|
|
21
22
|
"scripts": {
|
|
22
23
|
"build": "tsup",
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: l10n-c
|
|
3
|
+
description: Search and edit locale files with the l10n-c CLI instead of editing JSON by hand. Use for any translation task in a project with l10n-c installed - finding a string, adding or updating keys, renaming or deleting keys across languages, replacing text, and checking missing, unused, duplicate or misplaced keys.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# l10n-c
|
|
7
|
+
|
|
8
|
+
Use this CLI for locale files. Do not open or edit them directly. Direct edits risk
|
|
9
|
+
JSON syntax errors, keys that drift between languages, and large files in your context.
|
|
10
|
+
|
|
11
|
+
## Before you start
|
|
12
|
+
|
|
13
|
+
- Run commands from the directory that holds `l10n-c.config.json`. The CLI does not
|
|
14
|
+
search parent directories.
|
|
15
|
+
- Without a configuration file, the defaults apply: `public/locales`, base language
|
|
16
|
+
`ko`, source path `src`.
|
|
17
|
+
- Read the configuration when you need `localesDir`, `baseLanguage` or `languageOrder`.
|
|
18
|
+
- Use the language codes that already exist as directories under `localesDir`. A new
|
|
19
|
+
code creates a new language folder, so add one only when asked.
|
|
20
|
+
|
|
21
|
+
## Data model
|
|
22
|
+
|
|
23
|
+
Each language is a directory, and each JSON file in it is a domain. Keys are flattened
|
|
24
|
+
with dots:
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
messages/en/ui.json { "ui": { "start": "Start" } } -> ui.start
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The first key segment names the domain, so `shop.buy` lives in `shop.json`. Array items
|
|
31
|
+
use numeric segments, such as `ui.items.0`. Values written by the tools must be
|
|
32
|
+
strings.
|
|
33
|
+
|
|
34
|
+
## Commands
|
|
35
|
+
|
|
36
|
+
Search before you add a key, so you reuse existing strings and naming.
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
npx l10n-c --search start # keys and values, case insensitive
|
|
40
|
+
npx l10n-c --search start --file ui # limit any operation to one domain
|
|
41
|
+
npx l10n-c --update 'en:ui.start=Start' --update 'fr:ui.start=Démarrer'
|
|
42
|
+
npx l10n-c --publish '{"en":{"ui.start":"Start"},"fr":{"ui.start":"Démarrer"}}'
|
|
43
|
+
npx l10n-c --rename 'ui.old=ui.new' # key or subtree, every language
|
|
44
|
+
npx l10n-c --delete 'ui.obsolete' # key or subtree, every language
|
|
45
|
+
npx l10n-c --delete 'fr:ui.obsolete' # one language only
|
|
46
|
+
npx l10n-c --replace-text 'en:Old=New' # text inside values, one language
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Checks:
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
npx l10n-c --missing # against the configured base language
|
|
53
|
+
npx l10n-c --missing=fr # against another language
|
|
54
|
+
npx l10n-c --unused # heuristic scan of the configured source paths
|
|
55
|
+
npx l10n-c --nest-check # keys in the wrong file
|
|
56
|
+
npx l10n-c --duplicate-check # duplicate keys and repeated values
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Run `npx l10n-c --help` for the full list.
|
|
60
|
+
|
|
61
|
+
## Rules that prevent mistakes
|
|
62
|
+
|
|
63
|
+
- **Read the exit code and the output.** `--rename`, `--delete` and `--replace-text`
|
|
64
|
+
exit 1 when nothing matches. Check the key with `--search` instead of retrying.
|
|
65
|
+
- **A zero exit does not mean a clean check.** `--missing` and repeated values are
|
|
66
|
+
advisory and exit 0, so read the list. Invalid nesting and duplicate keys exit 1.
|
|
67
|
+
- **Watch for `new key ... does not exist in other languages`.** This warning after
|
|
68
|
+
`--update` often means a misspelled key. If you meant to create the key, add the
|
|
69
|
+
other languages too.
|
|
70
|
+
- **`--rename` stays inside one domain.** For a move across domains, run `--update` for
|
|
71
|
+
each language's new key, then `--delete` the old key.
|
|
72
|
+
- **Use `--publish` for multi-line values.** `--update` cannot carry a real newline, and
|
|
73
|
+
a typed `\n` is stored as a literal backslash and `n`. JSON `\n` in `--publish` is a
|
|
74
|
+
real newline.
|
|
75
|
+
- **`--unused` needs review.** Keys built at runtime may not be detected. Treat
|
|
76
|
+
`Potentially Dynamically Constructed Keys` as unknown, and do not delete them on this
|
|
77
|
+
result alone.
|
|
78
|
+
- **Writes across files are sequential.** If one fails partway, earlier files may
|
|
79
|
+
already have changed. Check `git diff` before you retry.
|
|
80
|
+
|
|
81
|
+
## Finish
|
|
82
|
+
|
|
83
|
+
Report what the output said: keys created and updated, entries changed, and anything
|
|
84
|
+
still missing. Then show the locale changes with `git diff`.
|