glotfile 0.5.4 → 0.6.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/dist/server/cli.js +976 -45
- package/dist/server/server.js +924 -43
- package/dist/ui/assets/{index-BGtqXjLQ.js → index-Vn-AfOXc.js} +13 -5
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
- package/skill/SKILL.md +6 -1
- package/skill/references/cli-reference.md +6 -0
- package/skill/references/workflows.md +27 -1
package/dist/ui/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Glotfile</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-Vn-AfOXc.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-BrgUMyDW.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/package.json
CHANGED
package/skill/SKILL.md
CHANGED
|
@@ -23,6 +23,11 @@ To make a change:
|
|
|
23
23
|
2. Run `glotfile export` to regenerate the locale files.
|
|
24
24
|
3. Commit both the state file and the regenerated outputs.
|
|
25
25
|
|
|
26
|
+
**Exception — Angular (`angular-xliff`):** source strings live in the code and
|
|
27
|
+
`ng extract-i18n` generates `messages.xlf`; glotfile owns only the translations. New
|
|
28
|
+
keys cannot be added in glotfile (trans-unit ids are content hashes) — see "Angular
|
|
29
|
+
projects" in `references/workflows.md` for the extract → import → translate → export loop.
|
|
30
|
+
|
|
26
31
|
## Before you touch anything: discover the project's actual config
|
|
27
32
|
|
|
28
33
|
Do not assume the locales, providers, or output formats — read them. They live in the
|
|
@@ -44,7 +49,7 @@ unless asked.
|
|
|
44
49
|
| Translate missing strings | `glotfile translate` (only fills empties; `--all` re-translates everything). |
|
|
45
50
|
| Write locale files | `glotfile export` |
|
|
46
51
|
| Find problems | `glotfile lint` (catalog issues) / `glotfile check` (lint + exports up to date) |
|
|
47
|
-
| Bootstrap from existing locale files | `glotfile import --format <adapter>` — see `references/workflows.md`. |
|
|
52
|
+
| Bootstrap from existing locale files | `glotfile import --format <adapter>` (or bare `glotfile import` to auto-detect) — see `references/workflows.md`. Every export adapter is importable. |
|
|
48
53
|
| Remove dead keys | `glotfile prune --unused` / `--empty-source` (dry-run unless `--write`). |
|
|
49
54
|
| Enforce term translations | Glossary — see `references/workflows.md`. |
|
|
50
55
|
|
|
@@ -53,6 +53,12 @@ without re-exporting. Exits non-zero on any error.
|
|
|
53
53
|
`glotfile import --format <name> [--source <dir>] [--source-locale <code>] [--locales <list>] [--cldr] [--force]`
|
|
54
54
|
— create `glotfile.json` from a project's existing locale files. See
|
|
55
55
|
`references/workflows.md` for the onboarding flow.
|
|
56
|
+
|
|
57
|
+
Every export adapter is also importable. Auto-detect caveats: an iOS project with both
|
|
58
|
+
`.strings` and `.stringsdict` auto-detects as `apple-strings` (use an explicit
|
|
59
|
+
`--format apple-stringsdict` for the plural table — it builds a separate catalog);
|
|
60
|
+
flat i18next `<lng>.json` files look like vue-i18n, so they need an explicit
|
|
61
|
+
`--format i18next-json` (the `public/locales/<lng>/<ns>.json` layout auto-detects).
|
|
56
62
|
- `--source <dir>` — directory to import from (default: the state file's directory).
|
|
57
63
|
- `--source-locale <code>` — which locale is the source of truth.
|
|
58
64
|
- `--cldr` — expand CLDR plural forms.
|
|
@@ -40,7 +40,9 @@ Never edit a translation in an exported file to "fix" it — fix it in the state
|
|
|
40
40
|
|
|
41
41
|
1. Identify the existing format and pick the matching adapter (e.g. a Laravel app with
|
|
42
42
|
`resources/lang/{locale}/` → `laravel-php`; a Flutter app with `app_{locale}.arb` →
|
|
43
|
-
`flutter-arb`
|
|
43
|
+
`flutter-arb`; an Angular app with `messages.xlf` → `angular-xliff`; a Rails app
|
|
44
|
+
with `config/locales/*.yml` → `rails-yaml`). Every export adapter is importable;
|
|
45
|
+
a bare `glotfile import` auto-detects the layout.
|
|
44
46
|
2. `glotfile import --format <adapter> --source <dir> --source-locale <code>` — this reads
|
|
45
47
|
the existing files and writes a `glotfile.json`. Add `--cldr` if plurals use CLDR
|
|
46
48
|
forms; `--force` to overwrite an existing state file.
|
|
@@ -49,6 +51,30 @@ Never edit a translation in an exported file to "fix" it — fix it in the state
|
|
|
49
51
|
4. `glotfile scan` then `glotfile build-context` (optional) to enrich keys with usage
|
|
50
52
|
context before translating.
|
|
51
53
|
|
|
54
|
+
## Angular projects (angular-xliff) — the source flow is inverted
|
|
55
|
+
|
|
56
|
+
In Angular i18n the **code is the source of truth for source strings**: `ng extract-i18n`
|
|
57
|
+
generates `messages.xlf` (trans-unit ids are content hashes), so you cannot add a key by
|
|
58
|
+
editing glotfile — add the string in the template/`$localize` and re-extract. Glotfile
|
|
59
|
+
owns the *translations*, not the source catalog:
|
|
60
|
+
|
|
61
|
+
1. Mark strings in code (`i18n`/`i18n-<attr>` attributes, `$localize` tagged templates).
|
|
62
|
+
2. `ng extract-i18n` (check `angular.json`/package scripts for the configured output
|
|
63
|
+
path) to regenerate `messages.xlf`.
|
|
64
|
+
3. `glotfile import --format angular-xliff --force` to pull the new source strings in.
|
|
65
|
+
Existing translations survive: they're read back from `messages.<locale>.xlf`, and
|
|
66
|
+
exported `state="new"` placeholder targets are ignored, not treated as translations.
|
|
67
|
+
⚠️ `--force` rebuilds `glotfile.json`, so glossary entries, key context, and config
|
|
68
|
+
edits made since the last import are lost — re-apply them (or commit first and diff).
|
|
69
|
+
4. `glotfile translate` to fill the missing locales, then `glotfile export`. Export
|
|
70
|
+
writes only `messages.<locale>.xlf` files (`skipSourceLocale`); it never touches
|
|
71
|
+
`messages.xlf` — that file belongs to the Angular extractor.
|
|
72
|
+
|
|
73
|
+
Markup placeholders (`<x id="START_TAG_STRONG"/>` …) appear in glotfile values as
|
|
74
|
+
`{START_TAG_STRONG}`-style tokens with their original attributes kept in the key's
|
|
75
|
+
`placeholders` metadata; keep the tokens intact in translations and export reproduces
|
|
76
|
+
the exact `<x/>` elements.
|
|
77
|
+
|
|
52
78
|
## Populate the glossary
|
|
53
79
|
|
|
54
80
|
The glossary constrains how particular terms are translated across the catalog; the lint
|