mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 20:36:03 +02:00
We write a hacky, one-off script to do that. We need this script only once, so we don't bother polishing it much. We'll re-purpose it later in the branch to convert the English translation set to JSON; that is an operation that we need to do regularly in the future.
41 lines
714 B
Go
41 lines
714 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/i18n"
|
|
)
|
|
|
|
func saveLanguageFileToJson(tr i18n.TranslationSet, filepath string) error {
|
|
jsonData, err := json.MarshalIndent(tr, "", " ")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
jsonData = append(jsonData, '\n')
|
|
return os.WriteFile(filepath, jsonData, 0o644)
|
|
}
|
|
|
|
func saveNonEnglishLanguageFilesToJson() error {
|
|
for lang, tr := range i18n.GetTranslationSets() {
|
|
if lang == "en" {
|
|
continue
|
|
}
|
|
|
|
err := saveLanguageFileToJson(tr, "pkg/i18n/translations/"+lang+".json")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func main() {
|
|
err := saveNonEnglishLanguageFilesToJson()
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|