|
|
|
@ -33,7 +33,6 @@ type translationStruct struct {
|
|
|
|
|
As string `db:"assamese" json:"as"`
|
|
|
|
|
Pa string `db:"punjabi" json:"pa"`
|
|
|
|
|
Mai string `db:"maithili" json:"mai"`
|
|
|
|
|
Mwr string `db:"marwari" json:"mwr"`
|
|
|
|
|
Sat string `db:"santali" json:"sat"`
|
|
|
|
|
Ne string `db:"nepali" json:"ne"`
|
|
|
|
|
Gom string `db:"konkani" json:"gom"`
|
|
|
|
@ -60,7 +59,6 @@ var lang_codes []string = []string{
|
|
|
|
|
"as", // Assamese
|
|
|
|
|
"pa", // Punjabi
|
|
|
|
|
"mai", // Maithili
|
|
|
|
|
"mwr", // Marwari
|
|
|
|
|
"sat", // Santali
|
|
|
|
|
"ne", // Nepali
|
|
|
|
|
"gom", // Konkani
|
|
|
|
@ -99,7 +97,7 @@ func getCachedTranslation(data string) (bool, translationStruct) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func addToDatabase(translation translationStruct) {
|
|
|
|
|
_, err := db.NamedExec(`INSERT INTO translations VALUES (:english, :hindi, :bengali, :marathi, :tamil, :telugu, :kannada, :malayalam, :oriya, :gujarati, :marwari, :urdu, :mizo, :assamese, :punjabi, :maithili, :santali, :nepali, :konkani, :tulu, :bhojpuri, :dogri, :manipuri, :sindhi, :awadhi)`, &translation)
|
|
|
|
|
_, err := db.NamedExec(`INSERT INTO translations VALUES (:english, :hindi, :bengali, :marathi, :tamil, :telugu, :kannada, :malayalam, :oriya, :gujarati, :urdu, :mizo, :assamese, :punjabi, :maithili, :santali, :nepali, :konkani, :tulu, :bhojpuri, :dogri, :manipuri, :sindhi, :awadhi)`, &translation)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
@ -157,10 +155,10 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
}
|
|
|
|
|
langToTranslation[lang_code] = translation
|
|
|
|
|
}
|
|
|
|
|
langToTranslation["en"] = toTranslate
|
|
|
|
|
langToTranslationJson, _ := json.Marshal(langToTranslation)
|
|
|
|
|
translation := translationStruct{}
|
|
|
|
|
err := json.Unmarshal(langToTranslationJson, &translation)
|
|
|
|
|
translation.En = toTranslate // langToTranslation doesn't contain the english value
|
|
|
|
|
addToDatabase(translation)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|