コード例 #1
0
func main() {
	var filename string

	// Get input, if any...
	flag.Parse()
	if flag.NArg() == 1 {
		filename = flag.Arg(0)
	} else {
		fmt.Println(usage)
		os.Exit(1)
	}

	po := mattermosti18n.LoadPO(loadFile(filename))

	var json *mattermosti18n.Translations
	if len(template) > 0 {
		json = mattermosti18n.LoadJson(loadFile(template))
	}

	if len(output) == 0 {
		name := strings.TrimSuffix(filename, filepath.Ext(filename))
		output = name + "_new.json"
	}

	err := ioutil.WriteFile(output, po.ToJson(json), 0644)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}
コード例 #2
0
func main() {
	var filename string

	// Get input, if any...
	flag.Parse()
	if flag.NArg() == 1 {
		filename = flag.Arg(0)
	} else {
		fmt.Println(usage)
		os.Exit(1)
	}

	var json, po *mattermosti18n.Translations

	json = mattermosti18n.LoadJson(loadFile(filename))
	if len(template) > 0 {
		po = mattermosti18n.LoadPO(loadFile(template))
	}

	if len(output) == 0 {
		name := strings.TrimSuffix(filename, filepath.Ext(filename))
		if pot {
			output = name + "_new.pot"
		} else {
			output = name + "_new.po"
		}
	}

	var err error
	if len(template) > 0 {
		err = ioutil.WriteFile(output, po.ToPO(json, pot), 0644)
	} else {
		err = ioutil.WriteFile(output, json.ToPO(nil, pot), 0644)
	}

	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}