Exemple #1
0
func rebuildLang(lang string, domain string) {
	ignores := []string{
		"bower_components",
		"img",
		"languages",
		"fonts",
		"bower.json",
		"scss",
	}

	var parsepath string
	if domain == "web" {
		parsepath = config.CurWebPath
	} else if domain == "server" {
		parsepath = config.DevDistPath + "/src/github.com/croll/arkeogis-server"
	}

	newTrans := make(map[string]string)
	parseDir(parsepath, ignores, newTrans)

	oldTrans, err := translate.ReadTranslation(lang, domain)
	if err != nil {
		log.Println("Problem while loading origin translation : ", err, " using empty one")
		oldTrans = make(map[string]string)
	}

	translate.MergeIn(newTrans, oldTrans)

	err = translate.WriteJSON(translate.PlateToTree(newTrans), lang, domain)
	if err != nil {
		fmt.Println(err)
	}
}
Exemple #2
0
// UserCreate Create a user, see usercreate struct inside this function for json content
func TranslatesSave(w http.ResponseWriter, r *http.Request, proute routes.Proute) {

	params := proute.Params.(*TranslateSaveParams)
	newtrans := proute.Json.(*map[string]interface{})

	trans, err := translate.ReadTranslation(params.Lang, params.Side)
	if err != nil {
		ArkeoError(w, 404, err.Error())
		return
	}

	tree := translate.PlateToTree(trans)
	domain := r.FormValue("domain")

	tree[domain] = *newtrans

	err = translate.WriteJSON(tree, params.Lang, params.Side)
	if err != nil {
		fmt.Println("WriteJSON failed: ", err)
		return
	}

	translate.Reinit()

	log.Println("theoriquement saved")
}
Exemple #3
0
// TranslatesList List root translations...
func TranslatesList(w http.ResponseWriter, r *http.Request, proute routes.Proute) {

	params := proute.Params.(*TranslateListParams)

	trans, err := translate.ReadTranslation(params.Lang, params.Side)
	if err != nil {
		ArkeoError(w, 404, err.Error())
		return
	}

	tree := translate.PlateToTree(trans)

	if params.Domain == "" {
		res := make([]string, len(tree))
		i := 0
		for k, _ := range tree {
			res[i] = k
			i++
		}
		j, err := json.Marshal(res)
		if err != nil {
			log.Fatal("Marshal of lang failed", err)
		}
		log.Printf("j: %s\n", j)
		w.Write(j)
		return
	} else {
		subtree := tree[params.Domain]
		j, err := json.Marshal(subtree)
		if err != nil {
			log.Fatal("Marshal of lang failed", err)
		}
		log.Printf("j: %s\n", j)
		w.Write(j)
		return
	}
	/*
		j := translate.BuildJSON(trans)
		log.Println("j: ", j)
		fmt.Fprint(w, j)
	*/
}