@afeefa/vue-app 0.0.277 → 0.0.278

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.
@@ -1 +1 @@
1
- 0.0.277
1
+ 0.0.278
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afeefa/vue-app",
3
- "version": "0.0.277",
3
+ "version": "0.0.278",
4
4
  "description": "",
5
5
  "author": "Afeefa Kollektiv <kollektiv@afeefa.de>",
6
6
  "license": "MIT",
@@ -1,6 +1,7 @@
1
1
  import './config/components'
2
2
  import './directives'
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 { eventBusPlugin } from '@a-vue/plugins/event-bus/EventBusPlugin'
6
7
  import { hasOptionsPlugin } from '@a-vue/plugins/has-options/HasOptionsPlugin'
@@ -69,8 +70,11 @@ export class AfeefaAdmin {
69
70
  // set app config
70
71
  adminConfig.app = this._appConfig
71
72
 
73
+ translationPlugin.setTranslations(this._appConfig.translations)
74
+
72
75
  Vue.use(configPlugin)
73
76
  Vue.use(iconsPlugin)
77
+ Vue.use(translationPlugin)
74
78
 
75
79
  // authenticate current user before doing any gui-voodo
76
80
  if (this._authService) {
@@ -15,7 +15,9 @@ class AdminConfig {
15
15
  SidebarMenu: null
16
16
  },
17
17
 
18
- icons: {}
18
+ icons: {},
19
+
20
+ translations: []
19
21
  }
20
22
 
21
23
  config = {
@@ -9,8 +9,8 @@ class TranslationPlugin {
9
9
  install (Vue) {
10
10
  Vue.mixin({
11
11
  created () {
12
- this.$t = (realm, objectId, objectType, key, lang) => {
13
- return translationService.translate(realm, objectId, objectType, key, lang)
12
+ this.$t = (...args) => {
13
+ return translationService.translate(...args)
14
14
  }
15
15
  }
16
16
  })
@@ -1,6 +1,12 @@
1
1
  class TranslationService {
2
+ lang = null
3
+
2
4
  translations = {}
3
5
 
6
+ setLang (lang) {
7
+ this.lang = lang
8
+ }
9
+
4
10
  setTranslations (translations) {
5
11
  translations.forEach(t => {
6
12
  const key = JSON.stringify([
@@ -14,13 +20,19 @@ class TranslationService {
14
20
  })
15
21
  }
16
22
 
17
- translate (realm, objectType, objectId, key, lang) {
23
+ translate (...args) {
24
+ let realm, objectType, objectId, key, lang
25
+
26
+ if (args.length === 1) {
27
+ key = args[0]
28
+ }
29
+
18
30
  const tKey = JSON.stringify([
19
31
  realm,
20
32
  objectType,
21
33
  objectId,
22
34
  key,
23
- lang
35
+ lang || this.lang
24
36
  ])
25
37
 
26
38
  if (!this.translations[tKey]) {