Skip to content

Commit 433c93c

Browse files
authored
Added correct key for nls.generation and endline (#17239)
1 parent ee6558b commit 433c93c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tasks/localizationtasks.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
var os = require('os');
21
var dom = require('xmldom').DOMParser
32
var gulp = require('gulp')
43
var config = require('./config')
@@ -132,7 +131,7 @@ gulp.task('ext:localization:xliff-to-ts', function () {
132131
contents.push('};');
133132

134133
// Join with new lines in between
135-
let fullFileContents = contents.join(os.EOL) + os.EOL;
134+
let fullFileContents = contents.join('\r\n') + '\r\n';
136135
file.contents = new Buffer(fullFileContents);
137136

138137
// Name our file
@@ -169,9 +168,14 @@ function dictionaryMapping(file, packageAllKeys = undefined) {
169168
if (contents.length >= 2) {
170169
contents[contents.length - 1] += ',';
171170
}
172-
if (dict.hasOwnProperty(key)) {
171+
if (packageAllKeys && dict.hasOwnProperty(key)) {
172+
//running in localized mode, use localized value.
173173
value = dict[key]['target'];
174174
}
175+
else if (dict.hasOwnProperty(key)) {
176+
//running in generation mode, use original source value.
177+
value = dict[key]['source'];
178+
}
175179
if (packageAllKeys && value === '') {
176180
// If localizing and value is not provided, use original English value.
177181
value = packageAllKeys[key];
@@ -188,7 +192,7 @@ function dictionaryMapping(file, packageAllKeys = undefined) {
188192
contents.push('}');
189193

190194
// Join with new lines in between
191-
let fullFileContents = contents.join(os.EOL) + os.EOL;
195+
let fullFileContents = contents.join('\r\n') + '\r\n';
192196
file.contents = new Buffer(fullFileContents);
193197

194198
let indexToStart = 'localizedPackage.json.'.length + 1;

0 commit comments

Comments
 (0)