mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 20:36:03 +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:
parent
02aeb6101c
commit
1e123e2124
8 changed files with 6511 additions and 0 deletions
41
cmd/i18n/main.go
Normal file
41
cmd/i18n/main.go
Normal file
|
@ -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)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue