mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-06-20 01:19:23 +02:00
Convert the non-English translation sets to JSON files
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.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user