You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`pnpm i18n:check [locale]`| Compares `en.json` with other locale files. Shows missing and extra keys. Optionally filter output by locale (e.g. `pnpm i18n:check ja-JP`). |
391
+
|`pnpm i18n:check:fix [locale]`| Same as check, but adds missing keys to other locales with English placeholders. |
392
+
|`pnpm i18n:report`| Audits translation keys against code usage in `.vue` and `.ts` files. Reports missing keys (used in code but not in locale), unused keys (in locale but not in code), and dynamic keys. |
393
+
|`pnpm i18n:report:fix`| Removes unused keys from `en.json` and all other locale files. |
394
+
381
395
### Adding a new locale
382
396
383
397
We are using localization using country variants (ISO-6391) via [multiple translation files](https://i18n.nuxtjs.org/docs/guide/lazy-load-translations#multiple-files-lazy-loading) to avoid repeating every key per country.
We track the current progress of translations with [Lunaria](https://lunaria.dev/) on this site: https://i18n.npmx.dev/
422
436
If you see any outdated translations in your language, feel free to update the keys to match the English version.
423
437
424
-
In order to make sure you have everything up-to-date, you can run:
425
-
426
-
```bash
427
-
pnpm i18n:check <country-code>
428
-
```
429
-
430
-
For example to check if all Japanese translation keys are up-to-date, run:
431
-
432
-
```bash
433
-
pnpm i18n:check ja-JP
434
-
```
435
-
436
-
To automatically add missing keys with English placeholders, use `--fix`:
437
-
438
-
```bash
439
-
pnpm i18n:check:fix fr-FR
440
-
```
441
-
442
-
This will add missing keys with `"EN TEXT TO REPLACE: {english text}"` as placeholder values, making it easier to see what needs translation.
438
+
Use `pnpm i18n:check` and `pnpm i18n:check:fix` to verify and fix your locale (see [i18n commands](#i18n-commands) above for details).
443
439
444
440
#### Country variants (advanced)
445
441
@@ -527,6 +523,32 @@ See how `es`, `es-ES`, and `es-419` are configured in [config/i18n.ts](./config/
527
523
- Use `common.*` for shared strings (loading, retry, close, etc.)
528
524
- Use component-specific prefixes: `package.card.*`, `settings.*`, `nav.*`
529
525
- Do not use dashes (`-`) in translation keys; always use underscore (`_`): e.g., `privacy_policy` instead of `privacy-policy`
526
+
-**Always use static string literals as translation keys.** Our i18n scripts (`pnpm i18n:report`) rely on static analysis to detect unused and missing keys. Dynamic keys cannot be analyzed and will be flagged as errors.
527
+
528
+
**Bad:**
529
+
530
+
```vue
531
+
<!-- Template literal -->
532
+
<p>{{ $t(`package.tabs.${tab}`) }}</p>
533
+
534
+
<!-- Variable -->
535
+
<p>{{ $t(myKey) }}</p>
536
+
```
537
+
538
+
**Good:**
539
+
540
+
```typescript
541
+
const { t } =useI18n()
542
+
543
+
const tabLabels =computed(() => ({
544
+
readme: t('package.tabs.readme'),
545
+
versions: t('package.tabs.versions'),
546
+
}))
547
+
```
548
+
549
+
```vue
550
+
<p>{{ tabLabels[tab] }}</p>
551
+
```
530
552
531
553
### Using i18n-ally (recommended)
532
554
@@ -598,6 +620,40 @@ A coverage test in `test/unit/a11y-component-coverage.spec.ts` ensures all compo
598
620
> [!IMPORTANT]
599
621
> Just because axe-core doesn't find any obvious issues, it does not mean a component is accessible. Please do additional checks and use best practices.
600
622
623
+
### Lighthouse accessibility tests
624
+
625
+
In addition to component-level axe audits, the project runs full-page accessibility audits using [Lighthouse CI](https://github.com/GoogleChrome/lighthouse-ci). These test the rendered pages in both light and dark mode against Lighthouse's accessibility category, requiring a perfect score.
626
+
627
+
#### How it works
628
+
629
+
1. The project is built in test mode (`pnpm build:test`), which activates server-side fixture mocking
630
+
2. Lighthouse CI starts a preview server and audits three URLs: `/`, `/search?q=nuxt`, and `/package/nuxt`
631
+
3. A Puppeteer setup script (`lighthouse-setup.cjs`) runs before each audit to set the color mode and intercept client-side API requests using the same fixtures as the E2E tests
This requires Chrome or Chromium to be installed. The script will auto-detect common installation paths. Results are printed to the terminal and saved in `.lighthouseci/`.
> Want automatic redirects? Try the [npmx-replace browser extension](https://github.com/tylersayshi/npmx-replace-extension).
119
+
> Want automatic redirects? Try the [npmx-replace browser extension](https://github.com/tylersayshi/npmx-replace-extension) (Chrome only for now).
120
120
121
121
#### Not yet supported
122
122
@@ -150,7 +150,7 @@ We welcome contributions – please do feel free to explore the project and
150
150
151
151
## Related projects
152
152
153
-
-[npmx-replace-extension](https://github.com/tylersayshi/npmx-replace-extension)– Browser extension to redirect npmjs.com to npmx.dev
153
+
-[npmx-replace-extension](https://github.com/tylersayshi/npmx-replace-extension)– Browser extension to redirect npmjs.com to npmx.dev (Chrome only for now)
154
154
-[JSR](https://jsr.io/)– The open-source package registry for modern JavaScript and TypeScript
155
155
-[npm-userscript](https://github.com/bluwy/npm-userscript)– Browser userscript with various improvements and fixes for npmjs.com
156
156
-[npm-alt](https://npm.willow.sh/)– An alternative npm package browser
0 commit comments