Compare commits

...

5 Commits

8 changed files with 904 additions and 5527 deletions

View File

@@ -33,7 +33,6 @@ type translationStruct struct {
As string `db:"assamese" json:"as"` As string `db:"assamese" json:"as"`
Pa string `db:"punjabi" json:"pa"` Pa string `db:"punjabi" json:"pa"`
Mai string `db:"maithili" json:"mai"` Mai string `db:"maithili" json:"mai"`
Mwr string `db:"marwari" json:"mwr"`
Sat string `db:"santali" json:"sat"` Sat string `db:"santali" json:"sat"`
Ne string `db:"nepali" json:"ne"` Ne string `db:"nepali" json:"ne"`
Gom string `db:"konkani" json:"gom"` Gom string `db:"konkani" json:"gom"`
@@ -60,7 +59,6 @@ var lang_codes []string = []string{
"as", // Assamese "as", // Assamese
"pa", // Punjabi "pa", // Punjabi
"mai", // Maithili "mai", // Maithili
"mwr", // Marwari
"sat", // Santali "sat", // Santali
"ne", // Nepali "ne", // Nepali
"gom", // Konkani "gom", // Konkani
@@ -99,7 +97,7 @@ func getCachedTranslation(data string) (bool, translationStruct) {
} }
func addToDatabase(translation 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 { if err != nil {
panic(err) panic(err)
} }
@@ -157,10 +155,10 @@ func handler(w http.ResponseWriter, r *http.Request) {
} }
langToTranslation[lang_code] = translation langToTranslation[lang_code] = translation
} }
langToTranslation["en"] = toTranslate
langToTranslationJson, _ := json.Marshal(langToTranslation) langToTranslationJson, _ := json.Marshal(langToTranslation)
translation := translationStruct{} translation := translationStruct{}
err := json.Unmarshal(langToTranslationJson, &translation) err := json.Unmarshal(langToTranslationJson, &translation)
translation.En = toTranslate // langToTranslation doesn't contain the english value
addToDatabase(translation) addToDatabase(translation)
if err != nil { if err != nil {
panic(err) panic(err)

View File

@@ -0,0 +1,7 @@
(Very jank)
1. Make changes in the code eg. changing the language of a state or district.
2. Uncomment the snippet of code at the bottom of index.js. This is responsible for printing out the language boundaries as JSON.
3. Get the JSON from the browser console, put it in a file, and un-minifiy it.
4. Copy the resulting JSON's text into 'india_with_districts_with_languages.json'. Put it at the start of the file, replacing the old language boundaries.
5. Fix any remaining errors that pop up (should be nothing major).
a. If Tulu and Sindhi are not loading, it's because, for some reason, the JSON definition for these languages includes the district that they're spoken in (because they're only spoken in 1 district). So the code assumes that it's a _district_, rather than a _language_ definition.

View File

@@ -11,7 +11,6 @@ const languages = {
konkani: {name: "Konkani", color: "#9b7cff", code: "gom", districts: []}, konkani: {name: "Konkani", color: "#9b7cff", code: "gom", districts: []},
hindi: {name: "Hindi", color: "#d17cff", code: "hi", districts: []}, hindi: {name: "Hindi", color: "#d17cff", code: "hi", districts: []},
gujarati: {name: "Gujarati", color: "#7cffee", code: "gu", districts: []}, gujarati: {name: "Gujarati", color: "#7cffee", code: "gu", districts: []},
marwari: {name: "Marwari", color: "#7bc4c9", code: "mwr", districts: []},
oriya: {name: "Oriya", color: "#9bcc9f", code: "or", districts: []}, oriya: {name: "Oriya", color: "#9bcc9f", code: "or", districts: []},
bengali: {name: "Bengali", color: "#bf9a77", code: "bn", districts: []}, bengali: {name: "Bengali", color: "#bf9a77", code: "bn", districts: []},
punjabi: {name: "Punjabi", color: "#e84a35", code: "pa", districts: []}, punjabi: {name: "Punjabi", color: "#e84a35", code: "pa", districts: []},
@@ -40,7 +39,7 @@ const state2lang = {
"Goa": languages["konkani"], "Goa": languages["konkani"],
"Odisha": languages["oriya"], "Odisha": languages["oriya"],
"Gujarat": languages["gujarati"], "Gujarat": languages["gujarati"],
"Rajasthan": languages["marwari"], "Rajasthan": languages["hindi"],
"Chhattisgarh": languages["hindi"], "Chhattisgarh": languages["hindi"],
"Jharkhand": languages["hindi"], // DEFAULT "Jharkhand": languages["hindi"], // DEFAULT
"West Bengal": languages["bengali"], "West Bengal": languages["bengali"],
@@ -280,10 +279,8 @@ function drawMap(world) {
d3.select(this).remove() d3.select(this).remove()
} }
}) })
.text(function(d) { .each(function(d) {
if (stateOrDistrictOrLanguage(d) == "language") { if (!stateOrDistrictOrLanguage(d) == "language") {
return "(" + d.properties.lang_name + ")";
} else {
d3.select(this).remove() // Only add this attribute if the element is a language d3.select(this).remove() // Only add this attribute if the element is a language
} }
}); });
@@ -301,26 +298,26 @@ function drawMap(world) {
.attr("font-size", "12px") .attr("font-size", "12px")
.attr("fill", "black") .attr("fill", "black")
.text("Hello, Map!"); .text("Hello, Map!");
// for (const [langId,lang] of Object.entries(languages)) { // for (const [langId,lang] of Object.entries(languages)) {
// let geojson = { // let geojson = {
// "type": "FeatureCollection", // "type": "FeatureCollection",
// "features": lang.districts // "features": lang.districts
// }; // };
// //
// let outerBound = getOuterBoundaryPolygon(geojson.features) // let outerBound = getOuterBoundaryPolygon(geojson.features)
// outerBound["id"] = "lang" + lang.name // outerBound["id"] = "lang" + lang.name
// outerBound.properties["lang_name"]= lang.name // outerBound.properties["lang_name"]= lang.name
// outerBound.properties["lang_code"]= lang.code // outerBound.properties["lang_code"]= lang.code
// allLangs.push(outerBound); // allLangs.push(outerBound);
//
// svg.append("path") // svg.append("path")
// .datum(outerBound) // .datum(outerBound)
// .attr("d", path) // .attr("d", path)
// .attr("fill", "none") // .attr("fill", "none")
// .attr("stroke", "red") // .attr("stroke", "red")
// .attr("stroke-width", 2) // .attr("stroke-width", 2)
// } // }
// console.log(JSON.stringify(allLangs)) // console.log(JSON.stringify(allLangs))
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,7 @@
1. REFACTOR 1. REFACTOR
2. Show language names as well, along with translation and romanization 2. Show language names as well, along with translation and romanization
3. Figure out positioning of the different translations, show all of them instead of having to hover 3. Figure out positioning of the different translations, show all of them instead of having to hover; for smaller languages it's hard to move the mouse around to see the full word.
4. Better translations (some of them are just terrible with Google Translate - use the ai4bharat one instead?)
4. Cache romanizations in DB 4. Cache romanizations in DB
5. General beautification 6. General beautification
6. TTS? 7. TTS?

Binary file not shown.

View File

@@ -212,7 +212,11 @@ def romanizeHandler():
"sd": "sd", "sd": "sd",
"ta": "ta", "ta": "ta",
"te": "te", "te": "te",
"ur": "ur" "ur": "ur",
"tcy": "kn", # Tulu uses Kannada script
"awa": "hi", # Awadhi uses Hindi script
"doi": "hi", # Dogri uses Hindi script
"bho": "hi", # Bhojpuri uses Hindi script
} }
rtv = dict() rtv = dict()