@markuplint/i18n Maintenance
You are maintaining @markuplint/i18n, the internationalization package for markuplint.
Architecture
See README.md for the full API documentation including translator usage, placeholder syntax, and locale formatting.
For detailed maintenance procedures, see docs/maintenance.md (Japanese).
Key Files
| File | Role |
|---|---|
locales/ja.json | Japanese locale dictionary (keywords + sentences + listFormat) |
locales/en.json | English locale dictionary (minimal; only entries needing capitalization or special formatting) |
$schema.json | JSON Schema for locale files (additionalProperties: false) |
src/translator.ts | Core translation logic |
src/types.ts | LocaleSet, ListFormat, Translator types |
Tasks
add-keyword
Add a new keyword used in rule messages.
- •Add to
locales/ja.jsonunderkeywords(alphabetical order, lowercase key)- •Normal keyword:
"tag name": "タグ名" - •Complement keyword (for
:cflag):"c:deprecated": "は非推奨です"
- •Normal keyword:
- •Add to
locales/en.jsonunderkeywordsonly if capitalization or special formatting is needed - •Add to
$schema.jsonunderkeywords.propertiesas{ "type": "string" } - •Test:
yarn test --scope @markuplint/i18n - •Build:
yarn build --scope @markuplint/i18n
Important: $schema.json uses additionalProperties: false. A keyword not defined in the schema will cause validation errors. Always keep the three files in sync.
add-sentence
Add a new sentence template for rule messages.
- •Design the English template as the key
- •Placeholders:
{0},{1},{2}... - •Complement flag:
{0:c}(resolves toc:prefixed keyword in Japanese) - •No-translate mark:
{0*}(skips translation for that placeholder)
- •Placeholders:
- •Add to
locales/ja.jsonundersentences(placeholder order may differ for natural Japanese) - •Add to
$schema.jsonundersentences.propertiesas{ "type": "string" } - •
en.jsondoes not need asentencesentry (the English key itself serves as the template) - •Test:
yarn test --scope @markuplint/i18n
add-language
Add support for a new language.
- •Create
locales/<lang>.jsonusingja.jsonas a template- •
listFormat: Define quote characters and separator for the language - •
keywords: Translate all keywords - •
sentences: Translate all sentence templates
- •
- •Add an export entry in
package.json:json"./locales/<lang>.json": { "import": "./locales/<lang>.json", "require": "./locales/<lang>.json" } - •
$schema.jsonis shared across all languages (no changes needed) - •Add test cases in
src/index.spec.ts - •Test:
yarn test --scope @markuplint/i18n