MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / writeInterpreterFile

Function writeInterpreterFile

tools/mage/translations.js:344–360  ·  view source on GitHub ↗
(locales, targetLanguage)

Source from the content-addressed store, hash-verified

342 * @returns {Promise<undefined>} - A promise that resolves when the file has been written.
343 */
344const 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.
363const main = async () => {

Callers 1

mainFunction · 0.85

Calls 3

writeFunction · 0.85
replaceMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected