Skip to content

Commit 13f136f

Browse files
Include comments exporting of translations (microsoft#153769)
Include comments in call to addFile. Fixes microsoft#150990
1 parent 944c6ca commit 13f136f

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

build/lib/i18n.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -599,17 +599,24 @@ function createXlfFilesForExtensions() {
599599
const basename = path.basename(file.path);
600600
if (basename === 'package.nls.json') {
601601
const json = JSON.parse(buffer.toString('utf8'));
602-
const keys = Object.keys(json);
603-
const messages = keys.map((key) => {
602+
const keys = [];
603+
const messages = [];
604+
Object.keys(json).forEach((key) => {
604605
const value = json[key];
605606
if (Is.string(value)) {
606-
return value;
607+
keys.push(key);
608+
messages.push(value);
607609
}
608610
else if (value) {
609-
return value.message;
611+
keys.push({
612+
key,
613+
comment: value.comment
614+
});
615+
messages.push(value.message);
610616
}
611617
else {
612-
return `Unknown message for key: ${key}`;
618+
keys.push(key);
619+
messages.push(`Unknown message for key: ${key}`);
613620
}
614621
});
615622
getXlf().addFile(`extensions/${extensionName}/package`, keys, messages);

build/lib/i18n.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -714,15 +714,22 @@ export function createXlfFilesForExtensions(): ThroughStream {
714714
const basename = path.basename(file.path);
715715
if (basename === 'package.nls.json') {
716716
const json: PackageJsonFormat = JSON.parse(buffer.toString('utf8'));
717-
const keys = Object.keys(json);
718-
const messages = keys.map((key) => {
717+
const keys: Array<string | LocalizeInfo> = [];
718+
const messages: string[] = [];
719+
Object.keys(json).forEach((key) => {
719720
const value = json[key];
720721
if (Is.string(value)) {
721-
return value;
722+
keys.push(key);
723+
messages.push(value);
722724
} else if (value) {
723-
return value.message;
725+
keys.push({
726+
key,
727+
comment: value.comment
728+
});
729+
messages.push(value.message);
724730
} else {
725-
return `Unknown message for key: ${key}`;
731+
keys.push(key);
732+
messages.push(`Unknown message for key: ${key}`);
726733
}
727734
});
728735
getXlf().addFile(`extensions/${extensionName}/package`, keys, messages);

0 commit comments

Comments
 (0)