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
Copy file name to clipboardExpand all lines: adminforth/documentation/docs/tutorial/05-Plugins/10-i18n.md
+80-27Lines changed: 80 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,7 @@ model translations {
40
40
// we need both indexes on en_string+category and separately on category
41
41
@@index([en_string, category])
42
42
@@index([category])
43
+
@@index([completedLangs])
43
44
}
44
45
```
45
46
@@ -454,7 +455,7 @@ import { admin } from '../index';
454
455
455
456
You can use this module not only to translate admin area of your application but also to translate other parts like SEO-facing or user-facing services.
456
457
This will allow you to reuse the same functionality and AI completion adapters for all your translations and manage them in one place.
457
-
For example in this app we will consider translating a Nuxt.js SEO-centric frontend which we want to translate with [vue-i18n](https://vue-i18n.intlify.dev/).
458
+
For example in this app we will consider translating a Nuxt.js SEO-centric frontend which we want to translate with [nuxt i18n](https://i18n.nuxtjs.org/).
458
459
459
460
To do it you need to use 2 exposed methods from the plugin: `feedCategoryTranslations` and `getCategoryTranslations`.
460
461
@@ -478,7 +479,7 @@ First of all, at some step, e.g. CI pipeline you should get all translation stri
"i18n:feed-to-local-backoffice": "npm run i18n:extract && curl -X POST -H 'Content-Type: application/json' -d @i18n-messages.json http://localhost:3000/feed-nuxt-strings"
500
501
}
501
502
}
502
503
```
503
504
504
-
Make sure to replace `adminforth:3000` with AdminForth API URL. We are assuming it is docker container name in internal docker network.
505
+
> For plain non-nuxt apps `--vueFiles'./?(pages|components)/**/*.?(js|vue)'` should be replaced with `--vueFiles'./src/**/*.?(js|vue)'`
505
506
506
-
So in the pipeline you should run `npmruni18n:feed-to-backoffice` to extract messages from your Nuxt.js app and feed them to AdminForth.
507
+
Make sure to replace `localhost:3000` with AdminForth API URL.
507
508
508
-
> 👆 The example method is just a stub, please make sure you not expose endpoint to public or add some simple authorization on it,
509
-
> otherwise someone might flood you with dump translations requests.
510
-
511
-
Then in your Nuxt.js app you should call this API and store the strings in the same.
509
+
So locally you can run `npmruni18n:feed-to-local-backoffice` to extract messages from your Nuxt.js app and feed them to AdminForth.
512
510
513
511
Next part. When we will need translations on the nuxt instance, we should use [vue-i18n's lazy loading feature](https://vue-i18n.intlify.dev/guide/advanced/lazy):
console.error('Translations or language data are missing.');
529
525
}
530
526
```
531
527
532
-
See [vue-i18n's lazy loading feature](https://vue-i18n.intlify.dev/guide/advanced/lazy) to understand where better to call `loadLocaleMessages` function.
0 commit comments