Skip to content

Commit 8d6c6b0

Browse files
committed
i18n guide fixes
1 parent 2c3614a commit 8d6c6b0

File tree

1 file changed

+20
-17
lines changed
  • adminforth/documentation/docs/tutorial/05-Plugins

1 file changed

+20
-17
lines changed

adminforth/documentation/docs/tutorial/05-Plugins/10-i18n.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -426,23 +426,9 @@ You can use this module not only to translate Admin area of your application but
426426
This will allow you to reuse the same functionality and AI completion adapters for all your translations. For example in this app we
427427
will consider that we have a Nuxt.js SEO-centric frontend which we want to translate with [vue-i18n](https://vue-i18n.intlify.dev/).
428428
429-
To do it you need to use 2 function from the plugin. First at some step, e.g. CI pipeline you should get all translation strings from your external app (e.g. Nuxt.js frontend) and create an own rest API like `'/feed-nuxt-strings'`, this API might look like this
430-
431-
For extracting 18n messages we use [vue-i18n-extract](https://github.com/Spittal/vue-i18n-extract) package.
432-
You can add extract command to `package.json`:
433-
434-
```json
435-
{
436-
"scripts": {
437-
"i18n:extract": "echo '{}' > i18n-empty.json && vue-i18n-extract report --vueFiles './src/**/*.?(js|vue)' --output ./i18n-messages.json --languageFiles 'i18n-empty.json' --add",
438-
"i18n:feed-to-backoffice": "npm run i18n:extract && curl -X POST -H 'Content-Type: application/json' -d @i18n-messages.json http://adminforth:3000/feed-nuxt-strings"
439-
""
440-
}
441-
}
442-
```
443-
444-
Make sure to replace `adminforth:3000` with AdminForth API URL.
429+
To do it you need to use 2 exposed methods from the plugin: `feedCategoryTranslations` and `getCategoryTranslations`.
445430
431+
First of all, at some step, e.g. CI pipeline you should get all translation strings from your external app and feed them ao an own rest API like `'/feed-nuxt-strings'`, this API might look like this
446432
447433
```ts title="./index.ts"
448434
app.get(`${ADMIN_BASE_URL}/feed-nuxt-strings`,
@@ -473,7 +459,24 @@ Make sure to replace `adminforth:3000` with AdminForth API URL.
473459

474460
```
475461
476-
> 👆 This example method is just a stub, please make sure you not expose it to public or add some simple authorization on it,
462+
For extracting 18n messages we use [vue-i18n-extract](https://github.com/Spittal/vue-i18n-extract) package.
463+
You can add extract command to `package.json`:
464+
465+
```json
466+
{
467+
"scripts": {
468+
"i18n:extract": "echo '{}' > i18n-empty.json && vue-i18n-extract report --vueFiles './src/**/*.?(js|vue)' --output ./i18n-messages.json --languageFiles 'i18n-empty.json' --add",
469+
"i18n:feed-to-backoffice": "npm run i18n:extract && curl -X POST -H 'Content-Type: application/json' -d @i18n-messages.json http://adminforth:3000/feed-nuxt-strings"
470+
""
471+
}
472+
}
473+
```
474+
475+
Make sure to replace `adminforth:3000` with AdminForth API URL. We are assuming it is docker container name in internal docker network.
476+
477+
So in the pipeline you should run `npm run i18n:feed-to-backoffice` to extract messages from your Nuxt.js app and feed them to AdminForth.
478+
479+
> 👆 The example method is just a stub, please make sure you not expose endpoint to public or add some simple authorization on it,
477480
> otherwise someone might flood you with dump translations requests.
478481
479482
Then in your Nuxt.js app you should call this API and store the strings in the same.

0 commit comments

Comments
 (0)