Skip to content

Instantly share code, notes, and snippets.

@fulopdaniel
Last active August 10, 2018 16:33
Show Gist options
  • Save fulopdaniel/922bf42497dbad3b1d3c8af505fde4fd to your computer and use it in GitHub Desktop.
Save fulopdaniel/922bf42497dbad3b1d3c8af505fde4fd to your computer and use it in GitHub Desktop.
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