mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
docs(i18n): add a developer guide for t, tn, msg and data-i18n
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
13efd411b6
commit
4dcbf7fbfa
5 files changed
+74
-17
No files matched your search
+1
-15
@@ -4,21 +4,7 @@ Shipped languages: **English** (source and fallback) and **Russian** (`ru`).
|
||||
|
||||
## How it works
|
||||
|
||||
The English text is the key. There is no English catalog: the code is the source.
|
||||
|
||||
```js
|
||||
t('Save keys'); // plain text
|
||||
t('Saved to {store}', { store }); // named placeholders
|
||||
tn(count, '{count} camera', '{count} cameras'); // count-dependent text
|
||||
msg('Live Flights'); // text kept in data, translated later by t()
|
||||
```
|
||||
|
||||
```html
|
||||
<span data-i18n>Normal</span>
|
||||
<button title="Pin visual presets" data-i18n-title>…</button>
|
||||
```
|
||||
|
||||
`data-i18n` translates the element's own text (put it on the element that holds the text, not on a parent with children). `data-i18n-title`, `data-i18n-aria-label` and `data-i18n-placeholder` translate that attribute's English value.
|
||||
The English text is the key: code calls `t('Save keys')`, and markup marks elements with `data-i18n`. How developers mark text is in [I18N.md](./I18N.md).
|
||||
|
||||
Every other language is one flat JSON file, `src/i18n/locales/<code>.json`, keyed by the English text:
|
||||
|
||||
|
||||
Reference in new issue
Block a user