Skip to content

Commit 2053a5a

Browse files
committed
📦 build: updates dist files
1 parent 0ec6372 commit 2053a5a

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

lib/cli.js

100644100755
File mode changed.

lib/commands/infuse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ exports.builder = (args) => {
1919
})
2020
.option('messages', {
2121
type: 'string',
22-
alias: 'o',
22+
alias: 'm',
2323
describe: 'locale messages path to be infused',
2424
demandOption: true
2525
});

lib/infuser.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,27 @@ function generate(locales, messages, descriptor) {
3131
}
3232
function getTargetLocaleMessages(locales, messages, descriptor) {
3333
return locales.reduce((target, locale) => {
34+
debug(`processing curernt: locale=${locale}, target=${target}`);
3435
const obj = messages[locale];
3536
if (obj) {
3637
let o = obj;
38+
let prev = null;
3739
const hierarchy = descriptor.hierarchy.concat();
3840
while (hierarchy.length > 0) {
3941
const key = hierarchy.shift();
40-
if (!key) {
42+
debug('processing hierarchy key: ', key);
43+
if (!key || !o) {
4144
break;
4245
}
4346
o = o[key];
47+
prev = o;
48+
}
49+
if (!o && !prev) {
50+
return target;
51+
}
52+
else {
53+
return Object.assign(target, { [locale]: ((!o && prev) ? prev : o) });
4454
}
45-
return Object.assign(target, { [locale]: o });
4655
}
4756
else {
4857
return target;
@@ -104,9 +113,10 @@ ${format(utils_1.stringfyContent(target[locale], 'json'), 'json')}</i18n>`);
104113
return contents.join('');
105114
}
106115
function format(source, lang) {
116+
debug(`format: lang=${lang}, source=${source}`);
107117
switch (lang) {
108118
case 'vue':
109-
return prettier_1.default.format(source, { parser: 'vue' });
119+
return source;
110120
case 'yaml':
111121
case 'yml':
112122
return prettier_1.default.format(source, { parser: 'yaml', tabWidth: 2 });

0 commit comments

Comments
 (0)