locize-cli 7.9.0 → 7.9.1
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/CHANGELOG.md +5 -0
- package/combineSubkeyPreprocessor.js +21 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
Project versioning adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
Change log format is based on [Keep a Changelog](http://keepachangelog.com/).
|
|
7
7
|
|
|
8
|
+
## [7.9.1](https://github.com/locize/locize-cli/compare/v7.9.0...v7.9.1) - 2022-03-02
|
|
9
|
+
|
|
10
|
+
- xliff: fix combined plural keys
|
|
11
|
+
|
|
12
|
+
|
|
8
13
|
## [7.9.0](https://github.com/locize/locize-cli/compare/v7.8.2...v7.9.0) - 2022-03-01
|
|
9
14
|
|
|
10
15
|
- xliff: detect i18n format and merge pluralforms if necessary
|
|
@@ -28,8 +28,12 @@ const uniq = (value, index, self) => self.indexOf(value) === index;
|
|
|
28
28
|
const stringify = (o) => {
|
|
29
29
|
let str = jsyaml.dump(o);
|
|
30
30
|
const subKeys = Object.keys(o);
|
|
31
|
-
subKeys.forEach((sk
|
|
32
|
-
|
|
31
|
+
subKeys.forEach((sk) => {
|
|
32
|
+
if (isNaN(sk)) {
|
|
33
|
+
str = str.replace(new RegExp(`^(?:${sk}: )+`, 'm'), `{${sk}}: `);
|
|
34
|
+
} else {
|
|
35
|
+
str = str.replace(new RegExp(`^(?:'${sk}': )+`, 'm'), `{${sk}}: `);
|
|
36
|
+
}
|
|
33
37
|
});
|
|
34
38
|
return str;
|
|
35
39
|
};
|
|
@@ -38,6 +42,11 @@ const transformKeys = (segments, baseKeys, toMerge, deli) => {
|
|
|
38
42
|
baseKeys.forEach((bk) => {
|
|
39
43
|
const asObj = toMerge[bk].reduce((mem, k) => {
|
|
40
44
|
const subKey = k.substring((bk + deli).length);
|
|
45
|
+
// special handling for i18next v3
|
|
46
|
+
if (deli === delimiter.i18next && subKey === 'plural' && segments[bk]) {
|
|
47
|
+
mem['__'] = segments[bk];
|
|
48
|
+
delete segments[bk];
|
|
49
|
+
}
|
|
41
50
|
mem[subKey] = segments[k];
|
|
42
51
|
return mem;
|
|
43
52
|
}, {});
|
|
@@ -107,7 +116,12 @@ const parse = (s) => {
|
|
|
107
116
|
let matchArray;
|
|
108
117
|
while ((matchArray = skRegex.exec(s)) !== null) {
|
|
109
118
|
const [match, sk] = matchArray;
|
|
110
|
-
|
|
119
|
+
if (isNaN(sk)) {
|
|
120
|
+
s = s.replace(new RegExp(`^(?:${match}: )+`, 'm'), `${sk}: `);
|
|
121
|
+
} else {
|
|
122
|
+
const escapedMatch = match.replace('{', '\\{').replace('}', '\\}');
|
|
123
|
+
s = s.replace(new RegExp(`^(?:${escapedMatch}: )+`, 'm'), `${sk}: `);
|
|
124
|
+
}
|
|
111
125
|
}
|
|
112
126
|
return jsyaml.load(s);
|
|
113
127
|
};
|
|
@@ -122,6 +136,10 @@ const prepareImport = (resources) => {
|
|
|
122
136
|
Object.keys(parsed).map((sk) => {
|
|
123
137
|
const skVal = parsed[sk];
|
|
124
138
|
resources[`${baseKey}_${sk}`] = skVal;
|
|
139
|
+
if (sk === '__') {
|
|
140
|
+
resources[baseKey] = resources[`${baseKey}_${sk}`];
|
|
141
|
+
delete resources[`${baseKey}_${sk}`];
|
|
142
|
+
}
|
|
125
143
|
});
|
|
126
144
|
delete resources[k];
|
|
127
145
|
}
|