1.0.4 • Published 3 years ago
plan9-translation-parser v1.0.4
Premise
This package can be used to parse translations from Google Sheets/Excel file to JSON files according to the sheet structure of the table
Example
Lets say we have a table that look something like this:
Sheet1:
EN | RU |
---|---|
Hello | Привет |
Sheet2:
EN | Ru |
---|---|
World | Мир |
We can use this lib to convert this to following file structure
┣ 📂translations
┃ ┣ 📂Sheet1
┃ ┣ 📜 EN.json
┃ ┣ 📜 RU.json
┃ ┣ 📂Sheet2
┃ ┣ 📜 EN.json
┃ ┣ 📜 RU.json
Usage
import tl, {saveToDirectory} from "plan9-translation-parser"
const sheets = ["mainpage", "otherpage"]
const getTranslations = async (method) => {
//Parse it from Google Table
if (method === "google") {
return await tl.parseFromGoogleSheets("tableID", sheets)
}
if (method === "excel") {
return await tl.parseFromXLSX("tableID", sheets)
}
}
const sheetData = await getTranslations("google")
// Save it to folder
saveToDirectory(dirname, sheetData)
// Or to your DB
translationsRepository.saveTranslations(sheetData)