Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,25 @@ Thank you for helping improve Dimly!
## Localization Workflow

- Duplicate `messages.json` from an existing locale when starting a new translation so structure and keys stay aligned. Place the copy under `_locales/<lang>/messages.json`, replacing `<lang>` with the Chrome locale code (for example, `es` or `pt-BR`).
- Retain placeholder tokens (e.g., `$SITE$`, `$PERCENT$`) exactly as they appear in the source file—only translate the surrounding text.
- After translating, run the localization sanity checks to catch missing keys or formatting issues:
- Retain placeholder tokens exactly as they appear in the source file—only translate the surrounding text. Both Chrome-style
tokens (such as `$SITE$` or `$PERCENT$`) and ICU placeholders (for example `{count}`) must remain unchanged.
- Run the localization sanity checks to catch missing keys, malformed ICU segments, or placeholder mismatches:
```
npm run test:locales
npm run lint:locales
```
- Spot-check the new locale in Chrome by launching with the language flag, for example: `chrome --lang=<code>`.
- When you open a pull request with new translations, tag a fluent speaker or request verification from the localization reviewers so strings can be double-checked before merging.

### Placeholder validation rule

- `npm run lint:locales` parses every `_locales/*/messages.json` file and the UI source (`src/` and templates) to ensure placeholders are valid.
- The rule fails when:
- ICU syntax cannot be parsed.
- Chrome-style placeholder metadata (`placeholders` sections) are missing or out of sync with the tokens referenced in `message` strings.
- Source usage (for example, `getMessage('key', [value])`) expects a different number or set of placeholders than the translations provide.
- Locales disagree on the placeholder set for a key.
- Run this command before committing so CI stays green.

---

## Code Style
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
"private": true,
"type": "module",
"scripts": {
"test": "node --test"
"lint:locales": "node scripts/validate-locales.mjs",
"test": "npm run lint:locales && node --test"
},
"devDependencies": {
"@babel/parser": "^7.25.0",
"@formatjs/icu-messageformat-parser": "^2.6.0"
}
}
Loading