l10n-c 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +71 -2
- package/dist/chunk-4IIOFJ45.js +622 -0
- package/dist/chunk-4IIOFJ45.js.map +1 -0
- package/dist/cli.cjs +1401 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +795 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +666 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +48 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -4
- package/schema.json +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Blosharper
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,72 @@
|
|
|
1
|
-
#
|
|
1
|
+
# l10n-c
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Locale editing CLI and bundler-independent core. Requires Node 22.12+; bundles
|
|
4
|
+
target Node 22. Translation strings stay verbatim; public tool messages are English.
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
npm install --save-dev l10n-c
|
|
8
|
+
npx l10n-c --help
|
|
9
|
+
npx l10n-c --search start
|
|
10
|
+
npx l10n-c --missing
|
|
11
|
+
npx l10n-c --nest-check
|
|
12
|
+
npx l10n-c --duplicate-check
|
|
13
|
+
npx l10n-c --unused
|
|
14
|
+
npx l10n-c --update 'en:ui.start=Start'
|
|
15
|
+
npx l10n-c --rename 'ui.old=ui.new'
|
|
16
|
+
npx l10n-c --delete 'fr:ui.obsolete'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Each locale is a directory, each JSON filename a domain: `messages/en/ui.json`
|
|
20
|
+
contains `{ "ui": { "start": "Start" } }`. Keys flatten to `ui.start`; nested
|
|
21
|
+
arrays use numeric segments. Literal dotted object keys are unsupported.
|
|
22
|
+
`--file ui`/`--domain ui.json` filters a domain. Mutations accept string values.
|
|
23
|
+
Cross-domain rename refuses with both domain names; use `--update` for each
|
|
24
|
+
language's target key, then `--delete` the old key. Same-domain subtrees work.
|
|
25
|
+
Game-only restructure and convert-to-tw commands are excluded.
|
|
26
|
+
|
|
27
|
+
Place `l10n-c.config.json` in the working directory; no upward search or TS loader:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"$schema": "./node_modules/l10n-c/schema.json",
|
|
32
|
+
"localesDir": "messages",
|
|
33
|
+
"baseLanguage": "en",
|
|
34
|
+
"sourcePaths": ["src", "index.html"],
|
|
35
|
+
"sourceIgnore": ["node_modules", ".git", "dist"],
|
|
36
|
+
"mirrors": [],
|
|
37
|
+
"allowedRoots": {},
|
|
38
|
+
"referencePrefixes": [],
|
|
39
|
+
"languageOrder": ["en", "fr"]
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Paths resolve from the configuration root. Defaults are `public/locales`, base
|
|
44
|
+
`ko`, source `src`, no mirrors, allowed-root overrides or extra reference prefixes.
|
|
45
|
+
`allowedRoots: { "ui": ["ui", "speech"] }` permits legacy roots within one file.
|
|
46
|
+
`referencePrefixes: ["ui."]` recognizes implicit source references when scanning
|
|
47
|
+
unused keys. Mirrors receive formatted changed files; primary files remain the
|
|
48
|
+
read source. Cross-file writes are sequential and may partially complete on errors.
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { createI18n, type I18nConfig } from 'l10n-c'
|
|
52
|
+
const options: I18nConfig = { localesDir: 'messages', baseLanguage: 'en' }
|
|
53
|
+
const editor = await createI18n(options, process.cwd())
|
|
54
|
+
await editor.saveLocale('en', { 'ui.start': 'Start' })
|
|
55
|
+
const flat = await editor.getLocales('ui')
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Locale iteration is deterministic: configured base first, remaining locale codes
|
|
59
|
+
in codepoint order, domain files by filename. Translation key order within each
|
|
60
|
+
file is retained. This is an intentional difference from the source tool's
|
|
61
|
+
runtime/filesystem order.
|
|
62
|
+
|
|
63
|
+
The core imports no Vite runtime. ESM and CommonJS exports, TypeScript declarations,
|
|
64
|
+
and `l10n-c/schema.json` are included. Pair with `vite-plugin-l10n-c` for the editor.
|
|
65
|
+
|
|
66
|
+
Missing keys and duplicate values are advisory (exit 0); invalid nesting, duplicate
|
|
67
|
+
keys, invalid input and mutation failures exit 1. Unused checks are heuristic:
|
|
68
|
+
code literals cover subtrees, comments only exact keys, templates flag potential
|
|
69
|
+
dynamic keys. Malformed read inputs may be skipped/reported, so checks are not a
|
|
70
|
+
complete JSON integrity gate. No tool rewrites application source.
|
|
71
|
+
|
|
72
|
+
[Full documentation](https://github.com/Blosharper/l10n-c#readme). MIT license included.
|