@afeefa/vue-app 0.0.60 → 0.0.61
Sign up to get free protection for your applications and to get access to all the features.
- package/.afeefa/package/release/version.txt +1 -1
- package/package.json +1 -1
- package/src-admin/bootstrap.js +8 -1
- package/src-admin/components/pages/CreatePage.vue +1 -2
- package/src-admin/components/pages/EditPage.vue +1 -2
- package/src-admin/components/pages/ListPage.vue +2 -4
- package/src-admin/models/Model.js +5 -0
- package/src-admin/plugins/translation/TranslationPlugin.js +20 -0
- package/src-admin/services/TranslationService.js +35 -0
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.61
|
package/package.json
CHANGED
package/src-admin/bootstrap.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import './config/event-bus'
|
2
2
|
import './config/components'
|
3
3
|
|
4
|
+
import { translationPlugin } from '@a-admin/plugins/translation/TranslationPlugin'
|
4
5
|
import { apiResourcesPlugin } from '@a-vue/plugins/api-resources/ApiResourcesPlugin'
|
5
6
|
import { hasOptionsPlugin } from '@a-vue/plugins/has-options/HasOptionsPlugin'
|
6
7
|
import { timeout } from '@a-vue/utils/timeout'
|
@@ -12,10 +13,11 @@ import vuetify from './config/vuetify'
|
|
12
13
|
|
13
14
|
Vue.use(apiResourcesPlugin)
|
14
15
|
Vue.use(hasOptionsPlugin)
|
16
|
+
Vue.use(translationPlugin)
|
15
17
|
|
16
18
|
Vue.config.productionTip = false
|
17
19
|
|
18
|
-
export async function bootstrap ({ apis, models, routing, authService, app, components }) {
|
20
|
+
export async function bootstrap ({ apis, models, routing, authService, getTranslations, app, components }) {
|
19
21
|
apiResourcesPlugin.register(models, apis)
|
20
22
|
|
21
23
|
appConfig.authService = authService
|
@@ -35,6 +37,11 @@ export async function bootstrap ({ apis, models, routing, authService, app, comp
|
|
35
37
|
const router = await routeConfigPlugin.getRouter()
|
36
38
|
await apiResourcesPlugin.schemasLoaded()
|
37
39
|
|
40
|
+
if (getTranslations) {
|
41
|
+
const translations = await getTranslations(apiResourcesPlugin.apiResources)
|
42
|
+
translationPlugin.setTranslations(translations.models)
|
43
|
+
}
|
44
|
+
|
38
45
|
if (authService) {
|
39
46
|
authService.initApp(router)
|
40
47
|
}
|
@@ -85,8 +85,7 @@ export default class CreatePage extends Mixins(EditPageMixin) {
|
|
85
85
|
return this.title
|
86
86
|
}
|
87
87
|
|
88
|
-
|
89
|
-
return type.t('TITLE_NEW')
|
88
|
+
return this.$t('Admin.Types', this.ModelClass.type, null, 'TITLE_NEW', 'de')
|
90
89
|
}
|
91
90
|
|
92
91
|
get _listLink () {
|
@@ -118,8 +118,7 @@ export default class EditPage extends Mixins(EditPageMixin) {
|
|
118
118
|
return this.title
|
119
119
|
}
|
120
120
|
|
121
|
-
|
122
|
-
return type.t('TITLE_EMPTY')
|
121
|
+
return this.$t('Admin.Types', this.ModelClass.type, null, 'TITLE_EMPTY', 'de')
|
123
122
|
}
|
124
123
|
|
125
124
|
get _listLink () {
|
@@ -37,8 +37,7 @@ export default class ListPage extends Vue {
|
|
37
37
|
return this.title
|
38
38
|
}
|
39
39
|
|
40
|
-
|
41
|
-
return type.t('TITLE_PLURAL')
|
40
|
+
return this.$t('Admin.Types', this.Model.type, null, 'TITLE_PLURAL', 'de')
|
42
41
|
}
|
43
42
|
|
44
43
|
get _newTitle () {
|
@@ -46,8 +45,7 @@ export default class ListPage extends Vue {
|
|
46
45
|
return this.newTitle
|
47
46
|
}
|
48
47
|
|
49
|
-
|
50
|
-
return type.t('TITLE_SINGULAR')
|
48
|
+
return this.$t('Admin.Types', this.Model.type, null, 'TITLE_SINGULAR', 'de')
|
51
49
|
}
|
52
50
|
|
53
51
|
get _newLink () {
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { translationService } from '@a-admin/services/TranslationService'
|
1
2
|
import { Model as ApiResourcesModel, apiResources } from '@afeefa/api-resources-client'
|
2
3
|
import { mdiAlphaMCircle } from '@mdi/js'
|
3
4
|
|
@@ -39,6 +40,10 @@ export class Model extends ApiResourcesModel {
|
|
39
40
|
color: 'blue lighten-2'
|
40
41
|
}
|
41
42
|
|
43
|
+
static translate (realm, objectType, objectId, key, lang) {
|
44
|
+
return translationService.translate(realm, objectType, objectId, key, lang)
|
45
|
+
}
|
46
|
+
|
42
47
|
getLink (action = 'detail') {
|
43
48
|
return {
|
44
49
|
name: `${this.constructor.routeName}.${action}`,
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { translationService } from '../../services/TranslationService'
|
2
|
+
|
3
|
+
class TranslationPlugin {
|
4
|
+
setTranslations (translations) {
|
5
|
+
translationService
|
6
|
+
.setTranslations(translations)
|
7
|
+
}
|
8
|
+
|
9
|
+
install (Vue) {
|
10
|
+
Vue.mixin({
|
11
|
+
created () {
|
12
|
+
this.$t = (realm, objectId, objectType, key, lang) => {
|
13
|
+
return translationService.translate(realm, objectId, objectType, key, lang)
|
14
|
+
}
|
15
|
+
}
|
16
|
+
})
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
export const translationPlugin = new TranslationPlugin()
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class TranslationService {
|
2
|
+
translations = {}
|
3
|
+
|
4
|
+
setTranslations (translations) {
|
5
|
+
translations.forEach(t => {
|
6
|
+
const key = JSON.stringify([
|
7
|
+
t.realm,
|
8
|
+
t.object_type,
|
9
|
+
t.object_id,
|
10
|
+
t.key,
|
11
|
+
t.lang
|
12
|
+
])
|
13
|
+
this.translations[key] = t.value
|
14
|
+
})
|
15
|
+
}
|
16
|
+
|
17
|
+
translate (realm, objectType, objectId, key, lang) {
|
18
|
+
const tKey = JSON.stringify([
|
19
|
+
realm,
|
20
|
+
objectType,
|
21
|
+
objectId,
|
22
|
+
key,
|
23
|
+
lang
|
24
|
+
])
|
25
|
+
|
26
|
+
if (!this.translations[tKey]) {
|
27
|
+
console.warn(`No translation found for ${tKey}`)
|
28
|
+
return `${key}:${lang}`
|
29
|
+
}
|
30
|
+
|
31
|
+
return this.translations[tKey]
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
export const translationService = new TranslationService()
|