@itrocks/translate 0.0.6 → 0.0.8
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/cjs/translate.js +2 -5
- package/esm/translate.js +2 -5
- package/package.json +1 -1
package/cjs/translate.js
CHANGED
|
@@ -18,10 +18,7 @@ function lang() {
|
|
|
18
18
|
return language;
|
|
19
19
|
}
|
|
20
20
|
function tr(text, parts, options) {
|
|
21
|
-
if (!parts) {
|
|
22
|
-
parts = [];
|
|
23
|
-
}
|
|
24
|
-
else if (parts && !Array.isArray(parts)) {
|
|
21
|
+
if (!Array.isArray(parts)) {
|
|
25
22
|
options = parts;
|
|
26
23
|
parts = [];
|
|
27
24
|
}
|
|
@@ -67,7 +64,7 @@ async function trLoad(file) {
|
|
|
67
64
|
.then(data => data.forEach(row => {
|
|
68
65
|
exports.translations.set(row[0], row[1]);
|
|
69
66
|
if (row[0].includes('$')) {
|
|
70
|
-
exports.expressions.add(
|
|
67
|
+
exports.expressions.add(RegExp('^' + row[0].replace(/(\$[0-9]+)/, '(.*)') + '$'));
|
|
71
68
|
}
|
|
72
69
|
}));
|
|
73
70
|
}
|
package/esm/translate.js
CHANGED
|
@@ -13,10 +13,7 @@ export function lang() {
|
|
|
13
13
|
return language;
|
|
14
14
|
}
|
|
15
15
|
export function tr(text, parts, options) {
|
|
16
|
-
if (!parts) {
|
|
17
|
-
parts = [];
|
|
18
|
-
}
|
|
19
|
-
else if (parts && !Array.isArray(parts)) {
|
|
16
|
+
if (!Array.isArray(parts)) {
|
|
20
17
|
options = parts;
|
|
21
18
|
parts = [];
|
|
22
19
|
}
|
|
@@ -62,7 +59,7 @@ export async function trLoad(file) {
|
|
|
62
59
|
.then(data => data.forEach(row => {
|
|
63
60
|
translations.set(row[0], row[1]);
|
|
64
61
|
if (row[0].includes('$')) {
|
|
65
|
-
expressions.add(
|
|
62
|
+
expressions.add(RegExp('^' + row[0].replace(/(\$[0-9]+)/, '(.*)') + '$'));
|
|
66
63
|
}
|
|
67
64
|
}));
|
|
68
65
|
}
|
package/package.json
CHANGED