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
> Exports in `app/composables/`, `app/utils/`, and `server/utils/` are auto-imported by Nuxt. To prevent [knip](https://knip.dev/) from flagging them as unused, add a `@public` JSDoc annotation:
194
+
>
195
+
> ```typescript
196
+
>/**
197
+
> * @public
198
+
> */
199
+
>exportfunction myAutoImportedFunction() {
200
+
>// ...
201
+
> }
202
+
>```
203
+
192
204
### Vue components
193
205
194
206
- Use Composition API with `<scriptsetuplang="ts">`
@@ -208,20 +220,85 @@ const props = defineProps<{
208
220
209
221
Ideally, extract utilities into separate files so they can be unit tested. 🙏
210
222
223
+
## RTL Support
224
+
225
+
We support `right-to-left` languages, we need to make sure that the UI is working correctly in both directions.
226
+
227
+
Simple approach used by most websites of relying on direction set in HTML element does not work because direction for various items, such as timeline, does not always match direction set in HTML.
228
+
229
+
We've added some `UnoCSS` utilities styles to help you with that:
230
+
231
+
- Do not use `left/right` padding and margin: for example `pl-1`. Use `padding-inline-start/end` instead. So `pl-1` should be `ps-1`, `pr-1` should be `pe-1`. The same rules apply to margin.
232
+
- Do not use `rtl-` classes, such as `rtl-left-0`.
233
+
- For icons that should be rotated for RTL, add `class="rtl-flip"`. This can only be used for icons outside of elements with `dir="auto"`.
234
+
- For absolute positioned elements, don't use `left/right`: for example `left-0`. Use `inset-inline-start/end` instead. `UnoCSS` shortcuts are `inset-is` for `inset-inline-start` and `inset-ie` for `inset-inline-end`. Example: `left-0` should be replaced with `inset-is-0`.
235
+
- If you need to change the border radius for an entire left or right side, use `border-inline-start/end`. `UnoCSS` shortcuts are `rounded-is` for left side, `rounded-ie` for right side. Example: `rounded-l-5` should be replaced with `rounded-is-5`.
236
+
- If you need to change the border radius for one corner, use `border-start-end-radius` and similar rules. `UnoCSS` shortcuts are `rounded` + top/bottom as either `-bs` (top) or `-be` (bottom) + left/right as either `-is` (left) or `-ie` (right). Example: `rounded-tl-0` should be replaced with `rounded-bs-is-0`.
237
+
211
238
## Localization (i18n)
212
239
213
240
npmx.dev uses [@nuxtjs/i18n](https://i18n.nuxtjs.org/) for internationalization. We aim to make the UI accessible to users in their preferred language.
214
241
215
242
### Approach
216
243
217
244
- All user-facing strings should use translation keys via `$t()` in templates and script
218
-
- Translation files live in `i18n/locales/` (e.g., `en.json`)
219
-
- We use the `no_prefix` strategy (no `/en/` or `/fr/` in URLs)
245
+
- Translation files live in [`i18n/locales/`](i18n/locales) (e.g., `en-US.json`)
246
+
- We use the `no_prefix` strategy (no `/en-US/` or `/fr-FR/` in URLs)
220
247
- Locale preference is stored in cookies and respected on subsequent visits
221
248
249
+
### Adding a new locale
250
+
251
+
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.
252
+
253
+
The [config/i18n.ts](./config/i18n.ts) configuration file will be used to register the new locale:
254
+
255
+
-`countryLocaleVariants` object will be used to register the country variants
256
+
-`locales` object will be used to link the supported locales (country and single one)
257
+
-`buildLocales` function will build the target locales
258
+
259
+
To add a new locale:
260
+
261
+
1. Create a new JSON file in [`i18n/locales/`](./i18n/locales) with the locale code as the filename (e.g., `uk-UA.json`, `de-DE.json`)
262
+
2. Copy [`en.json`](./i18n/locales/en.json) and translate the strings
263
+
3. Add the locale to the `locales` array in [config/i18n.ts](./config/i18n.ts):
264
+
265
+
```typescript
266
+
{
267
+
code: 'uk-UA', // Must match the filename (without .json)
268
+
file: 'uk-UA.json',
269
+
name: 'Українська', // Native name of the language
270
+
},
271
+
```
272
+
273
+
4. Copy your translation file to `lunaria/files/` for translation tracking:
> This file must be committed. Lunaria uses git history to track translation progress, so the build will fail if this file is missing.
281
+
282
+
5. If the language is `right-to-left`, add `dir: 'rtl'` (see `ar-EG` in config for example)
283
+
6. If the language requires special pluralization rules, add a `pluralRule` callback (see `ar-EG` or `ru-RU` in config for examples)
284
+
285
+
Check [Pluralization rule callback](https://vue-i18n.intlify.dev/guide/essentials/pluralization.html#custom-pluralization) for more info.
286
+
287
+
#### Country variants (advanced)
288
+
289
+
Most languages only need a single locale file. Country variants are only needed when you want to support regional differences (e.g., `es-ES` for Spain vs `es-419` for Latin America).
290
+
291
+
If you need country variants:
292
+
293
+
1. Create a base language file (e.g., `es.json`) with all translations
294
+
2. Create country variant files (e.g., `es-ES.json`, `es-419.json`) with only the differing translations
295
+
3. Register the base language in `locales` and add variants to `countryLocaleVariants`
296
+
297
+
See how `es`, `es-ES`, and `es-419` are configured in [config/i18n.ts](./config/i18n.ts) for a complete example.
298
+
222
299
### Adding translations
223
300
224
-
1. Add your translation key to `i18n/locales/en.json` first (English is the source of truth)
301
+
1. Add your translation key to `i18n/locales/en.json` first (American English is the source of truth)
225
302
2. Use the key in your component:
226
303
227
304
```vue
@@ -267,22 +344,6 @@ We recommend the [i18n-ally](https://marketplace.visualstudio.com/items?itemName
267
344
268
345
The extension is included in our workspace recommendations, so VSCode should prompt you to install it.
269
346
270
-
### Adding a new locale
271
-
272
-
1. Create a new JSON file in `i18n/locales/` (e.g., `fr.json`)
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
<palign="center">
6
6
<ahref="https://npmx.dev/">
7
-
<img width="1090" alt="Screenshot of npmx.dev showing the nuxt package" src="https://github.com/user-attachments/assets/229497a2-8491-461c-aa1d-fba981215340">
7
+
<img width="1090" alt="Screenshot of npmx.dev showing the nuxt package" src="https://github.com/user-attachments/assets/1a2a3205-0227-46dc-b1f9-48f9a65691d3">
0 commit comments