aloha-vue 1.0.358 → 1.0.359
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.
- package/package.json +1 -1
- package/src/ATranslation/ATranslation.js +4 -19
- package/src/ATranslation/compositionAPI/ATranslationAPI.js +32 -8
- package/src/ATranslation/compositionAPI/AriaLabelAPI.js +8 -3
- package/src/ATranslation/compositionAPI/HtmlAPI.js +12 -4
- package/src/ATranslation/compositionAPI/PlaceholderAPI.js +8 -3
- package/src/ATranslation/compositionAPI/TextAPI.js +12 -4
- package/src/ATranslation/compositionAPI/TitleAPI.js +12 -4
- package/src/ATranslation/compositionAPI/UtilsAPI.js +3 -2
- package/src/compositionAPI/APageTabTitleAPI.js +13 -4
- package/src/plugins/AI18nPlugin.js +2 -0
package/package.json
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
} from "vue";
|
|
4
4
|
|
|
5
5
|
import AriaLabelAPI from "./compositionAPI/AriaLabelAPI";
|
|
6
|
-
import ATranslationAPI from "./compositionAPI/ATranslationAPI";
|
|
7
6
|
import AttributesAPI from "./compositionAPI/AttributesAPI";
|
|
8
7
|
import HtmlAPI from "./compositionAPI/HtmlAPI";
|
|
9
8
|
import PlaceholderAPI from "./compositionAPI/PlaceholderAPI";
|
|
@@ -66,10 +65,6 @@ export default {
|
|
|
66
65
|
},
|
|
67
66
|
},
|
|
68
67
|
setup(props) {
|
|
69
|
-
const {
|
|
70
|
-
translation,
|
|
71
|
-
} = ATranslationAPI();
|
|
72
|
-
|
|
73
68
|
const {
|
|
74
69
|
hasTextAfter,
|
|
75
70
|
hasTextBefore,
|
|
@@ -82,9 +77,7 @@ export default {
|
|
|
82
77
|
isTranslateText,
|
|
83
78
|
textForCurrentDevice,
|
|
84
79
|
textLocal,
|
|
85
|
-
} = TextAPI(props
|
|
86
|
-
translation,
|
|
87
|
-
});
|
|
80
|
+
} = TextAPI(props);
|
|
88
81
|
|
|
89
82
|
const {
|
|
90
83
|
hasHtml,
|
|
@@ -99,26 +92,19 @@ export default {
|
|
|
99
92
|
hasTextBefore,
|
|
100
93
|
textAfterForCurrentDevice,
|
|
101
94
|
textBeforeForCurrentDevice,
|
|
102
|
-
translation,
|
|
103
95
|
});
|
|
104
96
|
|
|
105
97
|
const {
|
|
106
98
|
titleLocalOptions,
|
|
107
|
-
} = TitleAPI(props
|
|
108
|
-
translation,
|
|
109
|
-
});
|
|
99
|
+
} = TitleAPI(props);
|
|
110
100
|
|
|
111
101
|
const {
|
|
112
102
|
placeholderAttributes,
|
|
113
|
-
} = PlaceholderAPI(props
|
|
114
|
-
translation,
|
|
115
|
-
});
|
|
103
|
+
} = PlaceholderAPI(props);
|
|
116
104
|
|
|
117
105
|
const {
|
|
118
106
|
ariaLabelAttributes,
|
|
119
|
-
} = AriaLabelAPI(props
|
|
120
|
-
translation,
|
|
121
|
-
});
|
|
107
|
+
} = AriaLabelAPI(props);
|
|
122
108
|
|
|
123
109
|
const {
|
|
124
110
|
attributesLocal,
|
|
@@ -145,7 +131,6 @@ export default {
|
|
|
145
131
|
textAfterForCurrentDevice,
|
|
146
132
|
textBeforeForCurrentDevice,
|
|
147
133
|
textLocal,
|
|
148
|
-
translation,
|
|
149
134
|
};
|
|
150
135
|
},
|
|
151
136
|
render() {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
computed,
|
|
3
3
|
ref,
|
|
4
|
+
watch,
|
|
4
5
|
} from "vue";
|
|
5
6
|
|
|
6
7
|
import {
|
|
@@ -8,25 +9,35 @@ import {
|
|
|
8
9
|
} from "lodash-es";
|
|
9
10
|
|
|
10
11
|
const language = ref("de");
|
|
11
|
-
let i18n = {};
|
|
12
|
+
export let i18n = {};
|
|
13
|
+
const timeTranslation = ref(new Date());
|
|
14
|
+
export const timeTranslationLastChanged = ref(new Date());
|
|
15
|
+
export let translation = {};
|
|
12
16
|
export const isTranslate = ref(true);
|
|
13
17
|
|
|
14
|
-
export const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
export const watchList = computed(() => {
|
|
19
|
+
return [
|
|
20
|
+
language.value,
|
|
21
|
+
timeTranslation.value,
|
|
22
|
+
isTranslate.value,
|
|
23
|
+
];
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
watch(watchList, () => {
|
|
27
|
+
_updateTranslation();
|
|
28
|
+
}, {
|
|
29
|
+
immediate: true,
|
|
19
30
|
});
|
|
20
31
|
|
|
21
32
|
export default function ATranslationAPI() {
|
|
22
33
|
return {
|
|
23
|
-
i18n,
|
|
24
34
|
isTranslate,
|
|
25
35
|
language,
|
|
26
36
|
setI18n,
|
|
27
37
|
setLanguage,
|
|
28
38
|
toggleTranslate,
|
|
29
|
-
|
|
39
|
+
translationChanges: timeTranslationLastChanged,
|
|
40
|
+
updateTranslation,
|
|
30
41
|
};
|
|
31
42
|
}
|
|
32
43
|
|
|
@@ -45,3 +56,16 @@ export function toggleTranslate(isTranslateLocal) {
|
|
|
45
56
|
isTranslate.value = !!isTranslateLocal;
|
|
46
57
|
}
|
|
47
58
|
}
|
|
59
|
+
|
|
60
|
+
function _updateTranslation() {
|
|
61
|
+
if (isTranslate.value) {
|
|
62
|
+
translation = i18n[language.value];
|
|
63
|
+
} else {
|
|
64
|
+
translation = {};
|
|
65
|
+
}
|
|
66
|
+
timeTranslationLastChanged.value = new Date();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function updateTranslation() {
|
|
70
|
+
timeTranslation.value = new Date();
|
|
71
|
+
}
|
|
@@ -4,7 +4,9 @@ import {
|
|
|
4
4
|
} from "vue";
|
|
5
5
|
|
|
6
6
|
import AMobileAPI from "../../compositionAPI/AMobileAPI";
|
|
7
|
-
import ATranslationAPI
|
|
7
|
+
import ATranslationAPI, {
|
|
8
|
+
translation,
|
|
9
|
+
} from "./ATranslationAPI";
|
|
8
10
|
import UtilsAPI from "./UtilsAPI";
|
|
9
11
|
|
|
10
12
|
import {
|
|
@@ -17,7 +19,7 @@ export default function AriaLabelAPI(props) {
|
|
|
17
19
|
const extra = toRef(props, "extra");
|
|
18
20
|
|
|
19
21
|
const {
|
|
20
|
-
|
|
22
|
+
translationChanges,
|
|
21
23
|
} = ATranslationAPI();
|
|
22
24
|
|
|
23
25
|
const {
|
|
@@ -48,10 +50,13 @@ export default function AriaLabelAPI(props) {
|
|
|
48
50
|
});
|
|
49
51
|
|
|
50
52
|
const ariaLabelLocal = computed(() => {
|
|
53
|
+
if (!translationChanges.value) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
51
56
|
if (isTranslateAriaLabel.value) {
|
|
52
57
|
return getTranslatedText({
|
|
53
58
|
placeholder: ariaLabelForCurrentDevice.value,
|
|
54
|
-
translationObj: translation
|
|
59
|
+
translationObj: translation,
|
|
55
60
|
extra: extra.value,
|
|
56
61
|
});
|
|
57
62
|
}
|
|
@@ -4,12 +4,14 @@ import {
|
|
|
4
4
|
} from "vue";
|
|
5
5
|
|
|
6
6
|
import AMobileAPI from "../../compositionAPI/AMobileAPI";
|
|
7
|
+
import ATranslationAPI, {
|
|
8
|
+
translation,
|
|
9
|
+
} from "./ATranslationAPI";
|
|
7
10
|
import UtilsAPI from "./UtilsAPI";
|
|
8
11
|
|
|
9
12
|
import {
|
|
10
13
|
sanitizeLocal,
|
|
11
14
|
} from "../../utils/utils";
|
|
12
|
-
|
|
13
15
|
import {
|
|
14
16
|
isPlainObject,
|
|
15
17
|
isUndefined,
|
|
@@ -20,7 +22,6 @@ export default function HtmlAPI(props, {
|
|
|
20
22
|
hasTextBefore = computed(() => false),
|
|
21
23
|
textAfterForCurrentDevice = computed(() => ""),
|
|
22
24
|
textBeforeForCurrentDevice = computed(() => ""),
|
|
23
|
-
translation = computed(() => ({})),
|
|
24
25
|
}) {
|
|
25
26
|
const extra = toRef(props, "extra");
|
|
26
27
|
const html = toRef(props, "html");
|
|
@@ -35,6 +36,10 @@ export default function HtmlAPI(props, {
|
|
|
35
36
|
isMobileWidth,
|
|
36
37
|
} = AMobileAPI();
|
|
37
38
|
|
|
39
|
+
const {
|
|
40
|
+
translationChanges,
|
|
41
|
+
} = ATranslationAPI();
|
|
42
|
+
|
|
38
43
|
const safeHtmlForCurrentDevice = computed(() => {
|
|
39
44
|
if (isPlainObject(safeHtml.value)) {
|
|
40
45
|
if (isMobileWidth.value) {
|
|
@@ -84,11 +89,14 @@ export default function HtmlAPI(props, {
|
|
|
84
89
|
});
|
|
85
90
|
|
|
86
91
|
const htmlLocal = computed(() => {
|
|
92
|
+
if (!translationChanges.value) {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
87
95
|
if (hasSafeHtml.value) {
|
|
88
96
|
if (isTranslateSafeHtml.value) {
|
|
89
97
|
return getTranslatedText({
|
|
90
98
|
placeholder: safeHtmlForCurrentDevice.value,
|
|
91
|
-
translationObj: translation
|
|
99
|
+
translationObj: translation,
|
|
92
100
|
extra: extra.value
|
|
93
101
|
});
|
|
94
102
|
}
|
|
@@ -98,7 +106,7 @@ export default function HtmlAPI(props, {
|
|
|
98
106
|
if (isTranslateHtml.value) {
|
|
99
107
|
return sanitizeLocal(getTranslatedText({
|
|
100
108
|
placeholder: htmlForCurrentDevice.value,
|
|
101
|
-
translationObj: translation
|
|
109
|
+
translationObj: translation,
|
|
102
110
|
extra: extra.value
|
|
103
111
|
}));
|
|
104
112
|
}
|
|
@@ -4,7 +4,9 @@ import {
|
|
|
4
4
|
} from "vue";
|
|
5
5
|
|
|
6
6
|
import AMobileAPI from "../../compositionAPI/AMobileAPI";
|
|
7
|
-
import ATranslationAPI
|
|
7
|
+
import ATranslationAPI, {
|
|
8
|
+
translation,
|
|
9
|
+
} from "./ATranslationAPI";
|
|
8
10
|
import UtilsAPI from "./UtilsAPI";
|
|
9
11
|
|
|
10
12
|
import {
|
|
@@ -17,7 +19,7 @@ export default function PlaceholderAPI(props) {
|
|
|
17
19
|
const placeholder = toRef(props, "placeholder");
|
|
18
20
|
|
|
19
21
|
const {
|
|
20
|
-
|
|
22
|
+
translationChanges,
|
|
21
23
|
} = ATranslationAPI();
|
|
22
24
|
|
|
23
25
|
const {
|
|
@@ -48,10 +50,13 @@ export default function PlaceholderAPI(props) {
|
|
|
48
50
|
});
|
|
49
51
|
|
|
50
52
|
const placeholderLocal = computed(() => {
|
|
53
|
+
if (!translationChanges.value) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
51
56
|
if (isTranslatePlaceholder.value) {
|
|
52
57
|
return getTranslatedText({
|
|
53
58
|
placeholder: placeholderForCurrentDevice.value,
|
|
54
|
-
translationObj: translation
|
|
59
|
+
translationObj: translation,
|
|
55
60
|
extra: extra.value,
|
|
56
61
|
});
|
|
57
62
|
}
|
|
@@ -4,6 +4,9 @@ import {
|
|
|
4
4
|
} from "vue";
|
|
5
5
|
|
|
6
6
|
import AMobileAPI from "../../compositionAPI/AMobileAPI";
|
|
7
|
+
import ATranslationAPI, {
|
|
8
|
+
translation,
|
|
9
|
+
} from "./ATranslationAPI";
|
|
7
10
|
import UtilsAPI from "./UtilsAPI";
|
|
8
11
|
|
|
9
12
|
import {
|
|
@@ -11,9 +14,7 @@ import {
|
|
|
11
14
|
isUndefined,
|
|
12
15
|
} from "lodash-es";
|
|
13
16
|
|
|
14
|
-
export default function TextAPI(props
|
|
15
|
-
translation = computed(() => ({})),
|
|
16
|
-
}) {
|
|
17
|
+
export default function TextAPI(props) {
|
|
17
18
|
const extra = toRef(props, "extra");
|
|
18
19
|
const text = toRef(props, "text");
|
|
19
20
|
|
|
@@ -26,6 +27,10 @@ export default function TextAPI(props, {
|
|
|
26
27
|
isMobileWidth,
|
|
27
28
|
} = AMobileAPI();
|
|
28
29
|
|
|
30
|
+
const {
|
|
31
|
+
translationChanges,
|
|
32
|
+
} = ATranslationAPI();
|
|
33
|
+
|
|
29
34
|
const textForCurrentDevice = computed(() => {
|
|
30
35
|
if (isPlainObject(text.value)) {
|
|
31
36
|
if (isMobileWidth.value) {
|
|
@@ -45,10 +50,13 @@ export default function TextAPI(props, {
|
|
|
45
50
|
});
|
|
46
51
|
|
|
47
52
|
const textLocal = computed(() => {
|
|
53
|
+
if (!translationChanges.value) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
48
56
|
if (isTranslateText.value) {
|
|
49
57
|
return getTranslatedText({
|
|
50
58
|
placeholder: textForCurrentDevice.value,
|
|
51
|
-
translationObj: translation
|
|
59
|
+
translationObj: translation,
|
|
52
60
|
extra: extra.value
|
|
53
61
|
});
|
|
54
62
|
}
|
|
@@ -4,6 +4,9 @@ import {
|
|
|
4
4
|
} from "vue";
|
|
5
5
|
|
|
6
6
|
import AMobileAPI from "../../compositionAPI/AMobileAPI";
|
|
7
|
+
import ATranslationAPI, {
|
|
8
|
+
translation,
|
|
9
|
+
} from "./ATranslationAPI";
|
|
7
10
|
import UtilsAPI from "./UtilsAPI";
|
|
8
11
|
|
|
9
12
|
import {
|
|
@@ -13,9 +16,7 @@ import {
|
|
|
13
16
|
isPlainObject,
|
|
14
17
|
} from "lodash-es";
|
|
15
18
|
|
|
16
|
-
export default function TitleAPI(props
|
|
17
|
-
translation = computed(() => ({})),
|
|
18
|
-
}) {
|
|
19
|
+
export default function TitleAPI(props) {
|
|
19
20
|
const extra = toRef(props, "extra");
|
|
20
21
|
const title = toRef(props, "title");
|
|
21
22
|
|
|
@@ -28,6 +29,10 @@ export default function TitleAPI(props, {
|
|
|
28
29
|
isMobileWidth,
|
|
29
30
|
} = AMobileAPI();
|
|
30
31
|
|
|
32
|
+
const {
|
|
33
|
+
translationChanges,
|
|
34
|
+
} = ATranslationAPI();
|
|
35
|
+
|
|
31
36
|
const titleForCurrentDevice = computed(() => {
|
|
32
37
|
if (isPlainObject(title.value)) {
|
|
33
38
|
if (isMobileWidth.value) {
|
|
@@ -50,6 +55,9 @@ export default function TitleAPI(props, {
|
|
|
50
55
|
});
|
|
51
56
|
|
|
52
57
|
const titleLocalOptions = computed(() => {
|
|
58
|
+
if (!translationChanges.value) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
53
61
|
const TITLE_LOCAL_OPTIONS = {
|
|
54
62
|
title: undefined,
|
|
55
63
|
dataTranslateTitle: undefined,
|
|
@@ -73,7 +81,7 @@ export default function TitleAPI(props, {
|
|
|
73
81
|
if (isPlaceholderTranslate(titleEl)) {
|
|
74
82
|
titleCombined += getTranslatedText({
|
|
75
83
|
placeholder: titleEl,
|
|
76
|
-
translationObj: translation
|
|
84
|
+
translationObj: translation,
|
|
77
85
|
extra: extra.value,
|
|
78
86
|
});
|
|
79
87
|
dataTranslateTitle += titleEl;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
timeTranslationLastChanged,
|
|
2
3
|
translation,
|
|
3
4
|
} from "./ATranslationAPI";
|
|
4
5
|
|
|
@@ -24,8 +25,8 @@ export function isPlaceholderTranslate(text = "") {
|
|
|
24
25
|
text[text.length - 1] !== "_");
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
export function getTranslatedText({ placeholder, translationObj = translation
|
|
28
|
-
if (!translationObj) {
|
|
28
|
+
export function getTranslatedText({ placeholder, translationObj = translation, extra }) {
|
|
29
|
+
if (!translationObj || !timeTranslationLastChanged.value) {
|
|
29
30
|
return undefined;
|
|
30
31
|
}
|
|
31
32
|
const TEXT_FROM_TRANSLATION = isNil(translationObj[placeholder]) ? placeholder : translationObj[placeholder];
|
|
@@ -5,7 +5,9 @@ import {
|
|
|
5
5
|
watch,
|
|
6
6
|
} from "vue";
|
|
7
7
|
|
|
8
|
-
import ATranslationAPI
|
|
8
|
+
import ATranslationAPI, {
|
|
9
|
+
translation,
|
|
10
|
+
} from "../ATranslation/compositionAPI/ATranslationAPI";
|
|
9
11
|
import UtilsAPI from "../ATranslation/compositionAPI/UtilsAPI";
|
|
10
12
|
|
|
11
13
|
const baseTitle = ref("");
|
|
@@ -15,28 +17,35 @@ export default function APageTabTitleAPI(props) {
|
|
|
15
17
|
const extra = toRef(props, "extra");
|
|
16
18
|
|
|
17
19
|
const {
|
|
18
|
-
|
|
20
|
+
translationChanges,
|
|
19
21
|
} = ATranslationAPI();
|
|
22
|
+
|
|
20
23
|
const {
|
|
21
24
|
isPlaceholderTranslate,
|
|
22
25
|
getTranslatedText,
|
|
23
26
|
} = UtilsAPI();
|
|
24
27
|
|
|
25
28
|
const baseTitleTranslated = computed(() => {
|
|
29
|
+
if (!translationChanges.value) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
26
32
|
if (isPlaceholderTranslate(baseTitle.value)) {
|
|
27
33
|
return getTranslatedText({
|
|
28
34
|
placeholder: baseTitle.value,
|
|
29
|
-
translationObj: translation
|
|
35
|
+
translationObj: translation,
|
|
30
36
|
});
|
|
31
37
|
}
|
|
32
38
|
return baseTitle.value;
|
|
33
39
|
});
|
|
34
40
|
|
|
35
41
|
const titleTranslated = computed(() => {
|
|
42
|
+
if (!translationChanges.value) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
36
45
|
if (isPlaceholderTranslate(title.value)) {
|
|
37
46
|
return getTranslatedText({
|
|
38
47
|
placeholder: title.value,
|
|
39
|
-
translationObj: translation
|
|
48
|
+
translationObj: translation,
|
|
40
49
|
extra: extra.value,
|
|
41
50
|
});
|
|
42
51
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
setI18n,
|
|
3
3
|
setLanguage,
|
|
4
|
+
updateTranslation,
|
|
4
5
|
} from "../ATranslation/compositionAPI/ATranslationAPI";
|
|
5
6
|
|
|
6
7
|
export default {
|
|
7
8
|
install: (app, options, language) => {
|
|
8
9
|
setI18n(options);
|
|
9
10
|
setLanguage(language);
|
|
11
|
+
updateTranslation();
|
|
10
12
|
},
|
|
11
13
|
};
|