@mapomodule/i18n 2.0.0-beta.2 → 2.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -40
- package/dist/module.d.ts.map +1 -1
- package/dist/module.json +1 -1
- package/dist/runtime/locales/mapo.en.json +8 -2
- package/dist/runtime/locales/mapo.it.json +8 -2
- package/package.json +2 -2
- package/src/module.ts +4 -0
- package/src/runtime/locales/mapo.en.json +8 -2
- package/src/runtime/locales/mapo.it.json +8 -2
package/README.md
CHANGED
|
@@ -1,62 +1,68 @@
|
|
|
1
1
|
# @mapomodule/i18n
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The internationalization module of Mapo. It installs [`@nuxtjs/i18n`](https://i18n.nuxtjs.org) v10 with defaults suited to an admin interface and registers the English and Italian catalogs that every Mapo component reads, under the `mapo.*` key namespace.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Installed by the meta-package [`mapomodule`](https://www.npmjs.com/package/mapomodule), which configures it under `mapo.i18n`, and by `@mapomodule/uikit` and `@mapomodule/form` when the app does not register it. On its own it reads the `mapoI18n` key:
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @mapomodule/i18n@next
|
|
11
|
+
```
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Mapo v2 is published on the `next` dist-tag while it is in beta.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
i18n: {
|
|
21
|
-
defaultLocale: "it",
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
```
|
|
15
|
+
## Defaults
|
|
16
|
+
|
|
17
|
+
- `no_prefix` strategy, `en` and `it` locales, `en` as default and fallback locale.
|
|
18
|
+
- Browser language detection on the first visit, remembered in the `i18n_redirected` cookie.
|
|
19
|
+
- When the app registers `@nuxtjs/i18n` itself, its configuration wins and this module only adds the Mapo catalogs.
|
|
26
20
|
|
|
27
|
-
|
|
21
|
+
## Options
|
|
22
|
+
|
|
23
|
+
| Option | Default | Description |
|
|
24
|
+
| ----------------------- | ------------- | ------------------------------------------------------------------------ |
|
|
25
|
+
| `defaultLocale` | `"en"` | Default UI locale, also the fallback for missing keys |
|
|
26
|
+
| `locales` | `en` and `it` | The available locales. A list you pass replaces the built-in one |
|
|
27
|
+
| `detectBrowserLanguage` | `true` | Detect the browser language on the first visit and keep it in a cookie |
|
|
28
|
+
| `i18n` | — | Extra options forwarded verbatim to `@nuxtjs/i18n`; they win over Mapo's |
|
|
29
|
+
|
|
30
|
+
A locale without a Mapo catalog (`fr`, …) shows the Mapo strings in the default locale.
|
|
31
|
+
|
|
32
|
+
## Overriding a Mapo string
|
|
33
|
+
|
|
34
|
+
Ship a locale file with the same key and register it through `locales`; your messages are merged on top of the Mapo catalogs:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
// i18n/locales/en.json
|
|
38
|
+
{ "mapo": { "listTable": { "noItems": "Nothing here yet" } } }
|
|
39
|
+
```
|
|
28
40
|
|
|
29
41
|
```ts
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
defaultLocale: "en",
|
|
42
|
+
// nuxt.config.ts
|
|
43
|
+
mapo: {
|
|
44
|
+
i18n: {
|
|
34
45
|
locales: [
|
|
35
|
-
{ code: "en", language: "en-US", name: "English" },
|
|
36
|
-
{ code: "it", language: "it-IT", name: "Italiano" },
|
|
37
|
-
// Bring your own language — Mapo strings fall back to defaultLocale
|
|
38
|
-
{ code: "fr", language: "fr-FR", name: "Français", file: "fr.json" },
|
|
46
|
+
{ code: "en", language: "en-US", name: "English", file: "en.json" },
|
|
47
|
+
{ code: "it", language: "it-IT", name: "Italiano", file: "it.json" },
|
|
39
48
|
],
|
|
40
49
|
},
|
|
41
|
-
}
|
|
50
|
+
},
|
|
42
51
|
```
|
|
43
52
|
|
|
44
|
-
##
|
|
53
|
+
## Translating outside components
|
|
45
54
|
|
|
46
|
-
|
|
55
|
+
`useMapoT()` is auto-imported. It returns the app's `t` function for code where `useI18n()` is not available: Pinia store actions, composables called outside `setup`, imperative snackbar and confirm messages.
|
|
47
56
|
|
|
48
|
-
|
|
49
|
-
// i18n/locales/en.json
|
|
50
|
-
{
|
|
51
|
-
"mapo": { "listHead": { "addNew": "New entry" } },
|
|
52
|
-
"myApp": { "customTitle": "My dashboard" }
|
|
53
|
-
}
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## Typed keys
|
|
57
|
+
## Types
|
|
57
58
|
|
|
58
59
|
```ts
|
|
59
60
|
import type { MapoI18nKey, MapoMessages } from "@mapomodule/i18n/types";
|
|
60
61
|
```
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
The `mapomodule/types` aggregator does not include them: declare `@mapomodule/i18n` in your app's dependencies to import them.
|
|
64
|
+
|
|
65
|
+
## Documentation
|
|
66
|
+
|
|
67
|
+
- [@mapomodule/i18n](https://lotrekagency.github.io/mapo-new/modules/i18n)
|
|
68
|
+
- [How-to: translate the admin interface](https://lotrekagency.github.io/mapo-new/howto/i18n)
|
package/dist/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAK/C;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC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EAAE,OAAO,CAAC,CAAC;CAChC;AAOD;;;;;;;;;;;;;GAaG;;AACH,wBA6GyC"}
|
package/dist/module.json
CHANGED
|
@@ -88,7 +88,8 @@
|
|
|
88
88
|
},
|
|
89
89
|
"form": {
|
|
90
90
|
"required": "This field is required.",
|
|
91
|
-
"tabErrors": "This tab contains errors"
|
|
91
|
+
"tabErrors": "This tab contains errors",
|
|
92
|
+
"defaultTab": "General"
|
|
92
93
|
},
|
|
93
94
|
"fksField": {
|
|
94
95
|
"searchSelect": "Search and select...",
|
|
@@ -175,8 +176,13 @@
|
|
|
175
176
|
"dragToReorder": "Drag to reorder",
|
|
176
177
|
"clearToReorder": "Clear search & sorting to reorder",
|
|
177
178
|
"noItems": "No items found",
|
|
179
|
+
"noResults": "No results",
|
|
178
180
|
"totalItems": "{total} items",
|
|
179
|
-
"perPage": "{n} / page"
|
|
181
|
+
"perPage": "{n} / page",
|
|
182
|
+
"allRows": "All",
|
|
183
|
+
"sortAscending": "Sort by {column}, ascending",
|
|
184
|
+
"sortDescending": "Sort by {column}, descending",
|
|
185
|
+
"clearSorting": "Remove sorting by {column}"
|
|
180
186
|
},
|
|
181
187
|
"menuManager": {
|
|
182
188
|
"menu": "Menu",
|
|
@@ -88,7 +88,8 @@
|
|
|
88
88
|
},
|
|
89
89
|
"form": {
|
|
90
90
|
"required": "Questo campo è obbligatorio.",
|
|
91
|
-
"tabErrors": "Questa scheda contiene errori"
|
|
91
|
+
"tabErrors": "Questa scheda contiene errori",
|
|
92
|
+
"defaultTab": "Generale"
|
|
92
93
|
},
|
|
93
94
|
"fksField": {
|
|
94
95
|
"searchSelect": "Cerca e seleziona...",
|
|
@@ -175,8 +176,13 @@
|
|
|
175
176
|
"dragToReorder": "Trascina per riordinare",
|
|
176
177
|
"clearToReorder": "Svuota ricerca e ordinamento per riordinare",
|
|
177
178
|
"noItems": "Nessun elemento trovato",
|
|
179
|
+
"noResults": "Nessun risultato",
|
|
178
180
|
"totalItems": "{total} elementi",
|
|
179
|
-
"perPage": "{n} / pagina"
|
|
181
|
+
"perPage": "{n} / pagina",
|
|
182
|
+
"allRows": "Tutti",
|
|
183
|
+
"sortAscending": "Ordina per {column}, crescente",
|
|
184
|
+
"sortDescending": "Ordina per {column}, decrescente",
|
|
185
|
+
"clearSorting": "Togli l'ordinamento per {column}"
|
|
180
186
|
},
|
|
181
187
|
"menuManager": {
|
|
182
188
|
"menu": "Menu",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapomodule/i18n",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.3",
|
|
4
4
|
"description": "Mapo i18n wrapper: @nuxtjs/i18n v9 + base translations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"lint": "eslint src"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@nuxtjs/i18n": "^10.
|
|
48
|
+
"@nuxtjs/i18n": "^10.6.0",
|
|
49
49
|
"defu": "^6.1.4"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
package/src/module.ts
CHANGED
|
@@ -137,6 +137,10 @@ export default defineNuxtModule<MapoI18nOptions>({
|
|
|
137
137
|
// Generated vue-i18n config: `fallbackLocale` follows `defaultLocale` so
|
|
138
138
|
// locales without Mapo catalogs (e.g. a consumer-added "fr") still render
|
|
139
139
|
// Mapo strings instead of raw keys.
|
|
140
|
+
// It lives in the build dir, hence @nuxtjs/i18n >= 10.6 in package.json:
|
|
141
|
+
// older versions accept its HMR updates by the path relative to the build
|
|
142
|
+
// dir, here a bare "mapo-i18n.config.mjs" that Vite cannot resolve, and the
|
|
143
|
+
// dev server answers 500 on every page.
|
|
140
144
|
const vueI18nConfig = addTemplate({
|
|
141
145
|
filename: "mapo-i18n.config.mjs",
|
|
142
146
|
write: true,
|
|
@@ -88,7 +88,8 @@
|
|
|
88
88
|
},
|
|
89
89
|
"form": {
|
|
90
90
|
"required": "This field is required.",
|
|
91
|
-
"tabErrors": "This tab contains errors"
|
|
91
|
+
"tabErrors": "This tab contains errors",
|
|
92
|
+
"defaultTab": "General"
|
|
92
93
|
},
|
|
93
94
|
"fksField": {
|
|
94
95
|
"searchSelect": "Search and select...",
|
|
@@ -175,8 +176,13 @@
|
|
|
175
176
|
"dragToReorder": "Drag to reorder",
|
|
176
177
|
"clearToReorder": "Clear search & sorting to reorder",
|
|
177
178
|
"noItems": "No items found",
|
|
179
|
+
"noResults": "No results",
|
|
178
180
|
"totalItems": "{total} items",
|
|
179
|
-
"perPage": "{n} / page"
|
|
181
|
+
"perPage": "{n} / page",
|
|
182
|
+
"allRows": "All",
|
|
183
|
+
"sortAscending": "Sort by {column}, ascending",
|
|
184
|
+
"sortDescending": "Sort by {column}, descending",
|
|
185
|
+
"clearSorting": "Remove sorting by {column}"
|
|
180
186
|
},
|
|
181
187
|
"menuManager": {
|
|
182
188
|
"menu": "Menu",
|
|
@@ -88,7 +88,8 @@
|
|
|
88
88
|
},
|
|
89
89
|
"form": {
|
|
90
90
|
"required": "Questo campo è obbligatorio.",
|
|
91
|
-
"tabErrors": "Questa scheda contiene errori"
|
|
91
|
+
"tabErrors": "Questa scheda contiene errori",
|
|
92
|
+
"defaultTab": "Generale"
|
|
92
93
|
},
|
|
93
94
|
"fksField": {
|
|
94
95
|
"searchSelect": "Cerca e seleziona...",
|
|
@@ -175,8 +176,13 @@
|
|
|
175
176
|
"dragToReorder": "Trascina per riordinare",
|
|
176
177
|
"clearToReorder": "Svuota ricerca e ordinamento per riordinare",
|
|
177
178
|
"noItems": "Nessun elemento trovato",
|
|
179
|
+
"noResults": "Nessun risultato",
|
|
178
180
|
"totalItems": "{total} elementi",
|
|
179
|
-
"perPage": "{n} / pagina"
|
|
181
|
+
"perPage": "{n} / pagina",
|
|
182
|
+
"allRows": "Tutti",
|
|
183
|
+
"sortAscending": "Ordina per {column}, crescente",
|
|
184
|
+
"sortDescending": "Ordina per {column}, decrescente",
|
|
185
|
+
"clearSorting": "Togli l'ordinamento per {column}"
|
|
180
186
|
},
|
|
181
187
|
"menuManager": {
|
|
182
188
|
"menu": "Menu",
|