Last active
August 29, 2019 08:05
-
-
Save sagartalla/d6f56f29c7b55d1ebf9cd2c16e9f8f45 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 "./styles.css"; | |
import axios from "axios"; | |
import _ from "lodash"; | |
import EN_KEYWORDS from "./en"; | |
import AR_KEYWORDS from "./ar"; | |
axios | |
.get( | |
"https://spreadsheets.google.com/feeds/list/157erdICVrm0UhD37trQDZuzS7JG4T5ejwoZS9zUilzo/od6/public/values?alt=json" | |
) | |
.then(({ data }) => { | |
let transData = data.feed.entry.map(element => { | |
var acc = []; | |
_.forEach(element, (value, key) => { | |
if (/^gsx\$.+/.test(key)) { | |
acc.push(value.$t); | |
} | |
}); | |
return [acc[1], acc[2]]; | |
}); | |
transData.shift(); | |
transData = transData.reduce((acc, value, index) => { | |
acc[value[0].toLowerCase()] = value[1]; | |
return acc; | |
}, {}); | |
const arKeywords = {}; | |
_.map(EN_KEYWORDS, (page, pageKey) => { | |
_.map(page, (item, itemKey) => { | |
arKeywords[pageKey] = arKeywords[pageKey] || {}; | |
arKeywords[pageKey][itemKey] = | |
transData[item.toLowerCase()] || | |
(AR_KEYWORDS[pageKey] | |
? AR_KEYWORDS[pageKey][itemKey] | |
: EN_KEYWORDS[pageKey] | |
? EN_KEYWORDS[pageKey][itemKey] | |
: ""); | |
delete transData[item.toLowerCase()]; | |
}); | |
}); | |
console.log(JSON.stringify(transData)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment