Skip to content

Instantly share code, notes, and snippets.

@tim-we
Created April 16, 2020 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tim-we/460382e019ebc431c4673ef9b6eda62e to your computer and use it in GitHub Desktop.
Save tim-we/460382e019ebc431c4673ef9b6eda62e to your computer and use it in GitHub Desktop.
Create a simple text file containing all the strings from a messages.json file
const fs = require('fs');
let lang = "it";
let i18n = JSON.parse(fs.readFileSync("src/_locales/" + lang + "/messages.json", "utf8"));
let output = "";
for(const prop in i18n) {
//output += prop + ": ";
output += i18n[prop].message + "\n---\n";
}
fs.writeFileSync("strings_" + lang + ".txt", output);
console.log("Done.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment