|
1
|
# React + TypeScript + Vite |
|
2
|
|
|
3
|
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. |
|
4
|
|
|
5
|
Currently, two official plugins are available: |
|
6
|
|
|
7
|
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh |
|
8
|
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh |
|
9
|
|
|
10
|
## Expanding the ESLint configuration |
|
11
|
|
|
12
|
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: |
|
13
|
|
|
14
|
- Configure the top-level `parserOptions` property like this: |
|
15
|
|
|
16
|
```js |
|
17
|
export default { |
|
18
|
// other rules... |
|
19
|
parserOptions: { |
|
20
|
ecmaVersion: 'latest', |
|
21
|
sourceType: 'module', |
|
22
|
project: ['./tsconfig.json', './tsconfig.node.json'], |
|
23
|
tsconfigRootDir: __dirname, |
|
24
|
}, |
|
25
|
} |
|
26
|
``` |
|
27
|
|
|
28
|
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` |
|
29
|
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` |
|
30
|
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list |
|
31
|
|
|
32
|
## Translations |
|
33
|
|
|
34
|
Translation files live in `src/i18n/translations`. `en.json` is the source of truth, and every other `<locale>.json` file is translated from it. |
|
35
|
|
|
36
|
### Find missing translations |
|
37
|
|
|
38
|
```bash |
|
39
|
yarn i18n:sync missing |
|
40
|
``` |
|
41
|
|
|
42
|
Prints the number of strings in `en.json` that each locale is missing. Plural keys are expanded to the plural forms each locale uses, as defined in `src/i18n/plural-config.json`. |
|
43
|
|
|
44
|
Pass `--output` to also write the missing strings to a JSON file: |
|
45
|
|
|
46
|
```bash |
|
47
|
yarn i18n:sync missing --output missing.json |
|
48
|
``` |
|
49
|
|
|
50
|
The file is keyed by locale. Each entry has the number of missing strings (`count`), the locale's plural forms (`pluralForms`), and the missing keys nested as in `en.json` with their English text as values (`missing`). |
|
51
|
|
|
52
|
### Apply translations |
|
53
|
|
|
54
|
```bash |
|
55
|
yarn i18n:sync apply --input <directory> |
|
56
|
``` |
|
57
|
|
|
58
|
Merges translated strings into the locale files. The directory must contain JSON files named `<locale>.json`, or `<locale>.<anything>.json` to split a locale across several files (for example, `de.part-1.json`). Each file uses the same nested shape as `missing` in the `missing` output, with translated values. |
|
59
|
|
|
60
|
New keys are inserted next to their neighbors in `en.json`, and existing keys keep their order. A translation is skipped with a warning if: |
|
61
|
|
|
62
|
- Its key doesn't exist in `en.json`, or is a plural form the locale doesn't use. |
|
63
|
- The locale already has a translation for the key. Existing translations are never overwritten. |
|
64
|
- It's empty or not a string. |
|
65
|
- Its `{{placeholders}}` or `<0>` tags don't match the English text. Plural forms may add or drop `{{count}}`. |
|
66
|
|
|
67
|
### Automated sync |
|
68
|
|
|
69
|
The [Admin i18n Sync](../../../.github/workflows/admin-i18n-sync.yml) workflow runs daily. It finds missing translations, translates them with Claude, and opens a PR on the `chore/admin-i18n-sync-translations` branch. It skips runs while a previous sync PR is still open. |