Last active
August 10, 2018 16:33
-
-
Save fulopdaniel/922bf42497dbad3b1d3c8af505fde4fd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios'; | |
import * as fs from 'fs'; | |
import { sync as mkdirpSync } from 'mkdirp'; | |
const supportedLanguages = ['en', 'hu']; | |
const API_URL = "YOUR API URL"; | |
const LANG_DIR = './src/translations/'; | |
axios.get(API_URL).then(() => { | |
supportedLanguages.forEach((lang) => { | |
const translations = getTranslationsByLanguage(); // Replace with your own logic | |
mkdirpSync(LANG_DIR); | |
fs.writeFileSync(`${LANG_DIR + lang}.json`, JSON.stringify(translations, null, 2)); | |
}); | |
}).catch((err) => { | |
console.log(err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment