| 342 | * @returns {Promise<undefined>} - A promise that resolves when the file has been written. |
| 343 | */ |
| 344 | const writeInterpreterFile = async (locales, targetLanguage) => { |
| 345 | // Write the data as CSV, the first column being the message id |
| 346 | // the second column being the English message, and the third being the target language message. |
| 347 | |
| 348 | const locale = locales[targetLanguage] |
| 349 | const content = Object.keys(locale) |
| 350 | .filter(id => !locale[id]) |
| 351 | .map(id => { |
| 352 | const message = locale[id] || '' |
| 353 | // Add proper escapes |
| 354 | const english = locales[defaultLocale][id].replace(/"/g, '""') |
| 355 | const target = message.replace ? message.replace(/"/g, '""') : message |
| 356 | return `"${id}","${english}","${target}"` |
| 357 | }) |
| 358 | .join('\n') |
| 359 | await write(`./${targetLanguage}.csv`, `id,default,${targetLanguage}\n${content}`) |
| 360 | } |
| 361 | |
| 362 | // Main function. |
| 363 | const main = async () => { |