19 lines
623 B
TypeScript
19 lines
623 B
TypeScript
/* eslint-disable no-console */
|
|
import { writeFile } from 'fs/promises'
|
|
import { retrieveRecipes } from '../utils/retrieveRecipes'
|
|
|
|
const OUT_FILE = './res/translation-{lang}.json'
|
|
const languages = ['de', 'nl']
|
|
|
|
const retrieveTranslations = async () => {
|
|
for (const lang of languages) {
|
|
const entities = await retrieveRecipes(lang)
|
|
const items = Object.fromEntries(
|
|
entities.map(entity => [entity.href.replace(new RegExp(`/${lang}$`), ''), entity.name])
|
|
)
|
|
await writeFile(OUT_FILE.replace('{lang}', lang), JSON.stringify(items, null, 2), 'utf-8')
|
|
}
|
|
}
|
|
|
|
retrieveTranslations().catch(console.error)
|