()
| 184 | // Traverses schema json files looking for "description" fields to localized. |
| 185 | // The path to the "description" field is used to create a localization key. |
| 186 | const processJsonSchemaFiles = () => { |
| 187 | return es.through(function (file) { |
| 188 | let jsonTree = JSON.parse(file.contents.toString()); |
| 189 | let localizationJsonContents = {}; |
| 190 | let filePath = removePathPrefix(file.path, file.cwd); |
| 191 | let localizationMetadataContents = { |
| 192 | messages: [], |
| 193 | keys: [], |
| 194 | filePath: filePath |
| 195 | }; |
| 196 | let descriptionCallback = (path, value, parent) => { |
| 197 | let locId = filePath + "." + path; |
| 198 | let locHint = parent.descriptionHint; |
| 199 | localizationJsonContents[locId] = value; |
| 200 | localizationMetadataContents.keys.push(locHint ? { key: locId, comment: [locHint] } : locId); |
| 201 | localizationMetadataContents.messages.push(value); |
| 202 | }; |
| 203 | traverseJson(jsonTree, descriptionCallback, ""); |
| 204 | this.queue(new vinyl({ |
| 205 | path: path.join(file.path + '.nls.json'), |
| 206 | contents: Buffer.from(JSON.stringify(localizationJsonContents, null, '\t'), 'utf8') |
| 207 | })); |
| 208 | this.queue(new vinyl({ |
| 209 | path: path.join(file.path + '.nls.metadata.json'), |
| 210 | contents: Buffer.from(JSON.stringify(localizationMetadataContents, null, '\t'), 'utf8') |
| 211 | })); |
| 212 | }); |
| 213 | }; |
| 214 | |
| 215 | gulp.task("translations-export", (done) => { |
| 216 |
no test coverage detected