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

Function writeLocales

tools/mage/translations.js:314–335  ·  view source on GitHub ↗
(locales, backendIds)

Source from the content-addressed store, hash-verified

312 * @returns {Promise<undefined>} - A promise that resolves when all locales have been written.
313 */
314const writeLocales = async (locales, backendIds) =>
315 Promise.all(
316 Object.keys(locales).map(async key => {
317 const locale = locales[key]
318 let cleaned = locale
319 if (key === defaultLocale && !backendOnly) {
320 // Remove backend keys from the default locale
321 cleaned = Object.keys(locale).reduce((acc, next) => {
322 if (!backendIds.includes(next)) {
323 return {
324 ...acc,
325 [next]: locale[next],
326 }
327 }
328 return acc
329 }, {})
330 }
331 const content = JSON.stringify(cleaned, null, 2).concat('\n')
332 await mkdirp(localesDir)
333 await write(`${localesDir}/${key}.json`, content)
334 }),
335 )
336
337/**
338 * Write messages out for supported locales as CSV, for use when translating.

Callers 1

mainFunction · 0.85

Calls 1

writeFunction · 0.85

Tested by

no test coverage detected