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: README.md
+13-4Lines changed: 13 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,7 @@ Why AdminForth:
27
27
* Define express APIs and call them from your components and pages
28
28
* Use various modern back-office-must-have plugins like audit log, files/image upload, TOTP 2FA, I18N, Copilot-style AI writing and image generation
29
29
30
+
30
31
## Project initialisation
31
32
32
33
```
@@ -56,27 +57,35 @@ npx adminforth create-app
56
57
57
58
# For developers
58
59
59
-
```
60
+
The most convenient way to add new features or fixes is using `dev-demo`. It imports the source code of the repository and plugins so you can edit them and see changes on the fly.
61
+
62
+
Fork repo, pull it and do next:
63
+
64
+
65
+
```sh
60
66
cd adminforth
61
67
npm ci
62
68
npm run build
63
69
64
-
65
70
# this will install all official plugins and link adminforth package, if plugin installed it will git pull and npm ci
66
71
npm run install-plugins
67
72
68
73
# same for official adapters
69
74
npm run install-adapters
75
+
```
70
76
71
-
# this is dev demo for development
77
+
To run dev demo:
78
+
```sh
72
79
cd dev-demo
73
80
cp .env.sample .env
74
81
npm ci
75
82
npm run migrate
76
83
npm start
77
84
```
78
85
79
-
Add some columns to a database. Open .prisma file, modify it, and run:
86
+
## Adding columns to a database in dev-demo
87
+
88
+
Open `.prisma` file, modify it, and run:
80
89
81
90
```
82
91
npm run namemigration -- --name desctiption_of_changes
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