renusify 2.1.1 → 2.1.4
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/components/calendar/index.js +1 -1
- package/components/chart/worldMap.js +1 -1
- package/components/form/addressInput/index.js +1 -1
- package/components/index.js +1 -1
- package/components/meta/index.js +1 -155
- package/components/meta/meta.js +155 -0
- package/package.json +1 -1
- package/plugins/trans/Translate.js +144 -140
- package/plugins/validation/Validate.js +11 -11
|
@@ -4,7 +4,7 @@ export * as rCalendarYearTab from './year.vue'
|
|
|
4
4
|
export * as l_container from '../container/index.js'
|
|
5
5
|
export * as l_row from '../container/row.js'
|
|
6
6
|
export * as l_col from '../container/col.js'
|
|
7
|
-
export * as l_btn from '
|
|
7
|
+
export * as l_btn from '../button/index.js'
|
|
8
8
|
export * as l_icon from '../icon/index.js'
|
|
9
9
|
export * as l_card from '../card/index.js'
|
|
10
10
|
export * as l_modal from '../modal/index.js'
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * as
|
|
1
|
+
export * as rChartMap from './worldMap.vue'
|
|
2
2
|
export * as l_float from '../float/index.js'
|
package/components/index.js
CHANGED
package/components/meta/index.js
CHANGED
|
@@ -1,155 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export const rMeta= {
|
|
3
|
-
name: "r-meta",
|
|
4
|
-
created(){
|
|
5
|
-
this.build()
|
|
6
|
-
},
|
|
7
|
-
watch: {
|
|
8
|
-
'$attrs': {
|
|
9
|
-
handler() {
|
|
10
|
-
this.build()
|
|
11
|
-
},
|
|
12
|
-
deep: true
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
activated() {
|
|
16
|
-
this.build()
|
|
17
|
-
},
|
|
18
|
-
deactivated() {
|
|
19
|
-
this.removeAll()
|
|
20
|
-
},
|
|
21
|
-
methods: {
|
|
22
|
-
build() {
|
|
23
|
-
for (let i in this.$attrs) {
|
|
24
|
-
if (this.$helper.hasKey(this.$attrs, i)) {
|
|
25
|
-
this[i](this.$attrs[i]);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
html(obj) {
|
|
30
|
-
/*
|
|
31
|
-
:html="{
|
|
32
|
-
body: {id: 'aPageId'},
|
|
33
|
-
h1: {'data-foo': 'bar'},
|
|
34
|
-
}"
|
|
35
|
-
*/
|
|
36
|
-
Object.keys(obj).forEach(selector =>
|
|
37
|
-
this.setRootElementAttributes(selector, obj[selector])
|
|
38
|
-
);
|
|
39
|
-
},
|
|
40
|
-
head(obj) {
|
|
41
|
-
/*
|
|
42
|
-
:head="{
|
|
43
|
-
'meta[charset]': {charset: 'utf-8'},
|
|
44
|
-
}"
|
|
45
|
-
*/
|
|
46
|
-
Object.keys(obj).forEach(selector =>
|
|
47
|
-
this.setHeadElementAttributes(selector, obj[selector])
|
|
48
|
-
);
|
|
49
|
-
},
|
|
50
|
-
title(val) {
|
|
51
|
-
document.title = this.isRemoveValue(val) ? "" : val;
|
|
52
|
-
this.setMetaContent('itemprop="name"', val);
|
|
53
|
-
this.setMetaContent('property="og:title"', val);
|
|
54
|
-
this.setMetaContent('name="twitter:title"', val);
|
|
55
|
-
},
|
|
56
|
-
description(val) {
|
|
57
|
-
this.setMetaContent('name="description"', val);
|
|
58
|
-
this.setMetaContent('itemprop="description"', val);
|
|
59
|
-
this.setMetaContent('property="og:description"', val);
|
|
60
|
-
this.setMetaContent('name="twitter:description"', val);
|
|
61
|
-
},
|
|
62
|
-
keywords(val) {
|
|
63
|
-
this.setMetaContent('name="keywords"',val);
|
|
64
|
-
},
|
|
65
|
-
image(val) {
|
|
66
|
-
this.setMetaContent('itemprop="image"', val);
|
|
67
|
-
this.setMetaContent('property="og:image"', val);
|
|
68
|
-
this.setMetaContent('name="twitter:image"', val);
|
|
69
|
-
},
|
|
70
|
-
lang(val) {
|
|
71
|
-
this.setRootElementAttributes("html", {lang: val});
|
|
72
|
-
this.ogLocaleTag && this.setOgLocaleIfValid(val);
|
|
73
|
-
},
|
|
74
|
-
ogLocale(val) {
|
|
75
|
-
this.setMetaContent('property="og:locale"', val);
|
|
76
|
-
},
|
|
77
|
-
url(val) {
|
|
78
|
-
this.setHeadElementAttributes('link[rel="canonical"]', {href: val});
|
|
79
|
-
this.setMetaContent('property="og:url"', val);
|
|
80
|
-
this.setMetaContent('name="twitter:url"', val);
|
|
81
|
-
},
|
|
82
|
-
createChild(parent, selector) {
|
|
83
|
-
if (!this.getElement(parent, selector)) {
|
|
84
|
-
let property = selector;
|
|
85
|
-
property = property.split("[");
|
|
86
|
-
const name = property[0];
|
|
87
|
-
property = this.$helper.replacer(property[1], "]", "");
|
|
88
|
-
property = this.$helper.replacer(property, '"', "");
|
|
89
|
-
property = this.$helper.replacer(property, "'", "");
|
|
90
|
-
property = property.trim(" ");
|
|
91
|
-
property = property.split("=");
|
|
92
|
-
let meta = document.createElement(name);
|
|
93
|
-
meta.setAttribute("c", "renusify");
|
|
94
|
-
meta.setAttribute(property[0], property[1]);
|
|
95
|
-
parent.appendChild(meta);
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
setMetaContent(attr, val) {
|
|
99
|
-
this.createChild(document.head, `meta[${attr}]`);
|
|
100
|
-
this.setHeadElementAttributes(`meta[${attr}]`, {content: val});
|
|
101
|
-
},
|
|
102
|
-
setRootElementAttributes(selector, attributes) {
|
|
103
|
-
this.createChild(document, selector);
|
|
104
|
-
this.setElementAttributes(
|
|
105
|
-
this.getElement(document, selector),
|
|
106
|
-
attributes
|
|
107
|
-
);
|
|
108
|
-
},
|
|
109
|
-
setHeadElementAttributes(selector, attributes) {
|
|
110
|
-
this.createChild(document.head, selector);
|
|
111
|
-
this.setElementAttributes(
|
|
112
|
-
this.getElement(document.head, selector),
|
|
113
|
-
attributes
|
|
114
|
-
);
|
|
115
|
-
},
|
|
116
|
-
setElementAttributes(element, attributes) {
|
|
117
|
-
if (element) {
|
|
118
|
-
Object.keys(attributes).forEach(attrName => {
|
|
119
|
-
if (this.isRemoveValue(attributes[attrName])) {
|
|
120
|
-
element.removeAttribute(attrName);
|
|
121
|
-
} else {
|
|
122
|
-
element.setAttribute(attrName, attributes[attrName]);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
getElement(parent, selector) {
|
|
128
|
-
return parent.querySelector(selector);
|
|
129
|
-
},
|
|
130
|
-
setOgLocaleIfValid(locale) {
|
|
131
|
-
if (this.isRemoveValue(locale)) {
|
|
132
|
-
this.ogLocale(locale);
|
|
133
|
-
} else if (locale.match(/^[a-z]{2}-[a-z]{2}$/i)) {
|
|
134
|
-
const [language, region] = locale.split("-");
|
|
135
|
-
const ogLocale = `${language}_${region.toUpperCase()}`;
|
|
136
|
-
this.ogLocale(ogLocale);
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
isRemoveValue(val) {
|
|
140
|
-
return val === undefined || val === null;
|
|
141
|
-
},
|
|
142
|
-
removeAll() {
|
|
143
|
-
let children = document.querySelectorAll("[c='renusify']");
|
|
144
|
-
if (children) {
|
|
145
|
-
let childArray = Array.prototype.slice.call(children);
|
|
146
|
-
|
|
147
|
-
childArray.forEach(function (child) {
|
|
148
|
-
child.parentNode.removeChild(child);
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
render() {
|
|
154
|
-
}
|
|
155
|
-
};
|
|
1
|
+
export * as rMeta from './meta.js'
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
//https://github.com/troxler/headful/blob/master/src/headful.js
|
|
2
|
+
export default {
|
|
3
|
+
name: "r-meta",
|
|
4
|
+
created(){
|
|
5
|
+
this.build()
|
|
6
|
+
},
|
|
7
|
+
watch: {
|
|
8
|
+
'$attrs': {
|
|
9
|
+
handler() {
|
|
10
|
+
this.build()
|
|
11
|
+
},
|
|
12
|
+
deep: true
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
activated() {
|
|
16
|
+
this.build()
|
|
17
|
+
},
|
|
18
|
+
deactivated() {
|
|
19
|
+
this.removeAll()
|
|
20
|
+
},
|
|
21
|
+
methods: {
|
|
22
|
+
build() {
|
|
23
|
+
for (let i in this.$attrs) {
|
|
24
|
+
if (this.$helper.hasKey(this.$attrs, i)) {
|
|
25
|
+
this[i](this.$attrs[i]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
html(obj) {
|
|
30
|
+
/*
|
|
31
|
+
:html="{
|
|
32
|
+
body: {id: 'aPageId'},
|
|
33
|
+
h1: {'data-foo': 'bar'},
|
|
34
|
+
}"
|
|
35
|
+
*/
|
|
36
|
+
Object.keys(obj).forEach(selector =>
|
|
37
|
+
this.setRootElementAttributes(selector, obj[selector])
|
|
38
|
+
);
|
|
39
|
+
},
|
|
40
|
+
head(obj) {
|
|
41
|
+
/*
|
|
42
|
+
:head="{
|
|
43
|
+
'meta[charset]': {charset: 'utf-8'},
|
|
44
|
+
}"
|
|
45
|
+
*/
|
|
46
|
+
Object.keys(obj).forEach(selector =>
|
|
47
|
+
this.setHeadElementAttributes(selector, obj[selector])
|
|
48
|
+
);
|
|
49
|
+
},
|
|
50
|
+
title(val) {
|
|
51
|
+
document.title = this.isRemoveValue(val) ? "" : val;
|
|
52
|
+
this.setMetaContent('itemprop="name"', val);
|
|
53
|
+
this.setMetaContent('property="og:title"', val);
|
|
54
|
+
this.setMetaContent('name="twitter:title"', val);
|
|
55
|
+
},
|
|
56
|
+
description(val) {
|
|
57
|
+
this.setMetaContent('name="description"', val);
|
|
58
|
+
this.setMetaContent('itemprop="description"', val);
|
|
59
|
+
this.setMetaContent('property="og:description"', val);
|
|
60
|
+
this.setMetaContent('name="twitter:description"', val);
|
|
61
|
+
},
|
|
62
|
+
keywords(val) {
|
|
63
|
+
this.setMetaContent('name="keywords"',val);
|
|
64
|
+
},
|
|
65
|
+
image(val) {
|
|
66
|
+
this.setMetaContent('itemprop="image"', val);
|
|
67
|
+
this.setMetaContent('property="og:image"', val);
|
|
68
|
+
this.setMetaContent('name="twitter:image"', val);
|
|
69
|
+
},
|
|
70
|
+
lang(val) {
|
|
71
|
+
this.setRootElementAttributes("html", {lang: val});
|
|
72
|
+
this.ogLocaleTag && this.setOgLocaleIfValid(val);
|
|
73
|
+
},
|
|
74
|
+
ogLocale(val) {
|
|
75
|
+
this.setMetaContent('property="og:locale"', val);
|
|
76
|
+
},
|
|
77
|
+
url(val) {
|
|
78
|
+
this.setHeadElementAttributes('link[rel="canonical"]', {href: val});
|
|
79
|
+
this.setMetaContent('property="og:url"', val);
|
|
80
|
+
this.setMetaContent('name="twitter:url"', val);
|
|
81
|
+
},
|
|
82
|
+
createChild(parent, selector) {
|
|
83
|
+
if (!this.getElement(parent, selector)) {
|
|
84
|
+
let property = selector;
|
|
85
|
+
property = property.split("[");
|
|
86
|
+
const name = property[0];
|
|
87
|
+
property = this.$helper.replacer(property[1], "]", "");
|
|
88
|
+
property = this.$helper.replacer(property, '"', "");
|
|
89
|
+
property = this.$helper.replacer(property, "'", "");
|
|
90
|
+
property = property.trim(" ");
|
|
91
|
+
property = property.split("=");
|
|
92
|
+
let meta = document.createElement(name);
|
|
93
|
+
meta.setAttribute("c", "renusify");
|
|
94
|
+
meta.setAttribute(property[0], property[1]);
|
|
95
|
+
parent.appendChild(meta);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
setMetaContent(attr, val) {
|
|
99
|
+
this.createChild(document.head, `meta[${attr}]`);
|
|
100
|
+
this.setHeadElementAttributes(`meta[${attr}]`, {content: val});
|
|
101
|
+
},
|
|
102
|
+
setRootElementAttributes(selector, attributes) {
|
|
103
|
+
this.createChild(document, selector);
|
|
104
|
+
this.setElementAttributes(
|
|
105
|
+
this.getElement(document, selector),
|
|
106
|
+
attributes
|
|
107
|
+
);
|
|
108
|
+
},
|
|
109
|
+
setHeadElementAttributes(selector, attributes) {
|
|
110
|
+
this.createChild(document.head, selector);
|
|
111
|
+
this.setElementAttributes(
|
|
112
|
+
this.getElement(document.head, selector),
|
|
113
|
+
attributes
|
|
114
|
+
);
|
|
115
|
+
},
|
|
116
|
+
setElementAttributes(element, attributes) {
|
|
117
|
+
if (element) {
|
|
118
|
+
Object.keys(attributes).forEach(attrName => {
|
|
119
|
+
if (this.isRemoveValue(attributes[attrName])) {
|
|
120
|
+
element.removeAttribute(attrName);
|
|
121
|
+
} else {
|
|
122
|
+
element.setAttribute(attrName, attributes[attrName]);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
getElement(parent, selector) {
|
|
128
|
+
return parent.querySelector(selector);
|
|
129
|
+
},
|
|
130
|
+
setOgLocaleIfValid(locale) {
|
|
131
|
+
if (this.isRemoveValue(locale)) {
|
|
132
|
+
this.ogLocale(locale);
|
|
133
|
+
} else if (locale.match(/^[a-z]{2}-[a-z]{2}$/i)) {
|
|
134
|
+
const [language, region] = locale.split("-");
|
|
135
|
+
const ogLocale = `${language}_${region.toUpperCase()}`;
|
|
136
|
+
this.ogLocale(ogLocale);
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
isRemoveValue(val) {
|
|
140
|
+
return val === undefined || val === null;
|
|
141
|
+
},
|
|
142
|
+
removeAll() {
|
|
143
|
+
let children = document.querySelectorAll("[c='renusify']");
|
|
144
|
+
if (children) {
|
|
145
|
+
let childArray = Array.prototype.slice.call(children);
|
|
146
|
+
|
|
147
|
+
childArray.forEach(function (child) {
|
|
148
|
+
child.parentNode.removeChild(child);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
render() {
|
|
154
|
+
}
|
|
155
|
+
};
|
package/package.json
CHANGED
|
@@ -1,161 +1,165 @@
|
|
|
1
|
-
import Axios from 'axios';
|
|
2
|
-
|
|
3
1
|
export default class Translate {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
get messages() {
|
|
16
|
-
return this._messages;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
get failed_messages() {
|
|
20
|
-
return Object.keys(this._failed_messages);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
get local() {
|
|
24
|
-
return this._local;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
set local(value) {
|
|
28
|
-
this._local = value;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
set package(value) {
|
|
32
|
-
this._package = value;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
setMessages(obj, local) {
|
|
36
|
-
this._messages[local || this._local] = Object.assign({}, this._messages[local || this._local], obj);
|
|
37
|
-
}
|
|
2
|
+
constructor($r, $storage) {
|
|
3
|
+
this.$r = $r
|
|
4
|
+
this.$storage = $storage
|
|
5
|
+
this._count = 0;
|
|
6
|
+
this._failed_messages = {};
|
|
7
|
+
this._messages = {};
|
|
8
|
+
this._local = 'en';
|
|
9
|
+
this._package = $r.package;
|
|
10
|
+
this._store = []
|
|
11
|
+
}
|
|
38
12
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this._messages[this._local] = {}
|
|
13
|
+
get messages() {
|
|
14
|
+
return this._messages;
|
|
42
15
|
}
|
|
43
|
-
this._messages[this._local][key] = value;
|
|
44
|
-
}
|
|
45
16
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
17
|
+
get failed_messages() {
|
|
18
|
+
return Object.keys(this._failed_messages);
|
|
19
|
+
}
|
|
49
20
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return ''
|
|
21
|
+
get local() {
|
|
22
|
+
return this._local;
|
|
53
23
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
key = key[0]
|
|
58
|
-
if (!variable) {
|
|
59
|
-
console.error(
|
|
60
|
-
'object key must have variables. key:' + key + ' variable:' + variable
|
|
61
|
-
)
|
|
62
|
-
this._failed_messages[key] = true
|
|
63
|
-
return key
|
|
64
|
-
}
|
|
24
|
+
|
|
25
|
+
set local(value) {
|
|
26
|
+
this._local = value;
|
|
65
27
|
}
|
|
66
28
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
'package name must be string. key:' + key + ' package_name:' + package_name
|
|
70
|
-
)
|
|
71
|
-
this._failed_messages[key] = true
|
|
72
|
-
return key
|
|
29
|
+
set package(value) {
|
|
30
|
+
this._package = value;
|
|
73
31
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
32
|
+
|
|
33
|
+
setMessages(obj, local) {
|
|
34
|
+
this._messages[local || this._local] = Object.assign({}, this._messages[local || this._local], obj);
|
|
77
35
|
}
|
|
78
|
-
key = key.toLowerCase()
|
|
79
36
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
37
|
+
add(key, value) {
|
|
38
|
+
if (!this._messages[this._local]) {
|
|
39
|
+
this._messages[this._local] = {}
|
|
40
|
+
}
|
|
41
|
+
this._messages[this._local][key] = value;
|
|
85
42
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
43
|
+
|
|
44
|
+
replaceAll(string, search, replace) {
|
|
45
|
+
return string.split(search).join(replace);
|
|
89
46
|
}
|
|
90
|
-
if (this._messages[local][key]) {
|
|
91
|
-
let val = this._messages[local][key];
|
|
92
|
-
const lng = variable.length
|
|
93
|
-
for (let i = 0; i < lng; i++) {
|
|
94
|
-
val = this.replaceAll(val, '{' + i + '}', variable[i]);
|
|
95
|
-
}
|
|
96
47
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
48
|
+
get(key, package_name = null, lang = null) {
|
|
49
|
+
if (key === undefined || key === null) {
|
|
50
|
+
return ''
|
|
51
|
+
}
|
|
52
|
+
let variable = []
|
|
53
|
+
if (typeof key === 'object') {
|
|
54
|
+
variable = key[1]
|
|
55
|
+
key = key[0]
|
|
56
|
+
if (!variable) {
|
|
57
|
+
console.error(
|
|
58
|
+
'object key must have variables. key:' + key + ' variable:' + variable
|
|
59
|
+
)
|
|
60
|
+
this._failed_messages[key] = true
|
|
61
|
+
return key
|
|
62
|
+
}
|
|
108
63
|
}
|
|
109
|
-
Axios.post(url);
|
|
110
|
-
this._count++;
|
|
111
|
-
this._store.push(key)
|
|
112
|
-
}
|
|
113
|
-
this._failed_messages[key] = true
|
|
114
|
-
return key;
|
|
115
|
-
} else {
|
|
116
|
-
this._failed_messages[key] = true
|
|
117
|
-
return key;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
64
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
65
|
+
if (package_name && typeof package_name !== 'string') {
|
|
66
|
+
console.error(
|
|
67
|
+
'package name must be string. key:' + key + ' package_name:' + package_name
|
|
68
|
+
)
|
|
69
|
+
this._failed_messages[key] = true
|
|
70
|
+
return key
|
|
71
|
+
}
|
|
72
|
+
if (typeof key !== 'string') {
|
|
73
|
+
this._failed_messages[key] = true
|
|
74
|
+
return key
|
|
75
|
+
}
|
|
76
|
+
key = key.toLowerCase()
|
|
126
77
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
Axios.get(`/translate/${pack}/${locale}`).then(
|
|
141
|
-
res => {
|
|
142
|
-
if (res.data.length !== 0) {
|
|
143
|
-
const lang = {};
|
|
144
|
-
const lng = res.data.length
|
|
78
|
+
const local = lang !== null ? lang : this._local
|
|
79
|
+
const pack = package_name !== null ? package_name : this._package
|
|
80
|
+
if (!local) {
|
|
81
|
+
this._failed_messages[key] = true
|
|
82
|
+
return key;
|
|
83
|
+
}
|
|
84
|
+
if (!this._messages[local]) {
|
|
85
|
+
this._failed_messages[key] = true
|
|
86
|
+
return key;
|
|
87
|
+
}
|
|
88
|
+
if (this._messages[local][key]) {
|
|
89
|
+
let val = this._messages[local][key];
|
|
90
|
+
const lng = variable.length
|
|
145
91
|
for (let i = 0; i < lng; i++) {
|
|
146
|
-
|
|
92
|
+
val = this.replaceAll(val, '{' + i + '}', variable[i]);
|
|
147
93
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
94
|
+
|
|
95
|
+
if (val === null || val === '') {
|
|
96
|
+
this._failed_messages[key] = true
|
|
97
|
+
return key;
|
|
98
|
+
}
|
|
99
|
+
return val;
|
|
100
|
+
} else if (this.$r && this.$r.autoAddTranslate && pack && this._count < 100 && /^([0-9a-z_.])*$/.test(key)) {
|
|
101
|
+
if (!this._store.includes(key)) {
|
|
102
|
+
let url = '/translate/' + pack + '/' + key + '?v=';
|
|
103
|
+
const lng = variable.length
|
|
104
|
+
for (let i = 0; i < lng; i++) {
|
|
105
|
+
url += '{' + i + '}';
|
|
106
|
+
}
|
|
107
|
+
fetch(url, {
|
|
108
|
+
method: 'POST'
|
|
109
|
+
});
|
|
110
|
+
this._count++;
|
|
111
|
+
this._store.push(key)
|
|
112
|
+
}
|
|
113
|
+
this._failed_messages[key] = true
|
|
114
|
+
return key;
|
|
115
|
+
} else {
|
|
116
|
+
this._failed_messages[key] = true
|
|
117
|
+
return key;
|
|
158
118
|
}
|
|
159
|
-
|
|
160
|
-
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
loads(packages = []) {
|
|
122
|
+
packages.forEach((p) => {
|
|
123
|
+
this.load(p)
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
load(p) {
|
|
128
|
+
const pack = p || this.$r.package;
|
|
129
|
+
if (!p) {
|
|
130
|
+
this.package = pack;
|
|
131
|
+
}
|
|
132
|
+
if (!this.$r.store['langs_loaded']) {
|
|
133
|
+
this.$r.store['langs_loaded'] = {}
|
|
134
|
+
}
|
|
135
|
+
this.$r.store['langs_loaded'][pack] = false;
|
|
136
|
+
let locale = this.$r.lang;
|
|
137
|
+
if (this.$storage.get("lang")) {
|
|
138
|
+
locale = this.$storage.get("lang");
|
|
139
|
+
}
|
|
140
|
+
fetch(`/api/translate/${pack}/${locale}`, {
|
|
141
|
+
method: 'GET',
|
|
142
|
+
}).then(
|
|
143
|
+
res => {
|
|
144
|
+
if (res.ok) {
|
|
145
|
+
let data = res.json()
|
|
146
|
+
if (data.length !== 0) {
|
|
147
|
+
const lang = {};
|
|
148
|
+
const lng = data.length
|
|
149
|
+
for (let i = 0; i < lng; i++) {
|
|
150
|
+
lang[data[i].key] = data[i][locale];
|
|
151
|
+
}
|
|
152
|
+
this.local = locale;
|
|
153
|
+
this.setMessages(lang);
|
|
154
|
+
} else {
|
|
155
|
+
this.local = locale;
|
|
156
|
+
this.setMessages({});
|
|
157
|
+
}
|
|
158
|
+
this.$r.store['langs_loaded'][pack] = true;
|
|
159
|
+
} else {
|
|
160
|
+
this.$r.store['langs_loaded'][pack] = true;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
}
|
|
161
165
|
}
|
|
@@ -72,17 +72,17 @@ export default class Validate {
|
|
|
72
72
|
|
|
73
73
|
checkType(names) {
|
|
74
74
|
let filters = [];
|
|
75
|
-
if (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
75
|
+
if (Array.isArray(names)) {
|
|
76
|
+
names.forEach((name) => {
|
|
77
|
+
let res = name.split(':');
|
|
78
|
+
let par1 = res[1] ? res[1] : null;
|
|
79
|
+
let par2 = res[2] ? res[2] : null;
|
|
80
|
+
let par3 = res[3] ? res[3] : null;
|
|
81
|
+
if (this[res[0]]) {
|
|
82
|
+
if (par3 === null && par2 === null) {
|
|
83
|
+
filters.push(this[res[0]](par1))
|
|
84
|
+
} else if (par3 === null) {
|
|
85
|
+
filters.push(this[res[0]](par1, par2))
|
|
86
86
|
} else {
|
|
87
87
|
filters.push(this[res[0]](par1, par2, par3))
|
|
88
88
|
}
|