Added fetching scripts
This commit is contained in:
18
scripts/translations/index.ts
Normal file
18
scripts/translations/index.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/* 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)
|
||||
Reference in New Issue
Block a user