mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
add get_required_translations.go
This commit is contained in:
parent
df7f9c4a99
commit
cfd47b2877
4 changed files with 47 additions and 18 deletions
|
|
@ -2,8 +2,6 @@ package i18n
|
||||||
|
|
||||||
// TranslationSet is a set of localised strings for a given language
|
// TranslationSet is a set of localised strings for a given language
|
||||||
type TranslationSet struct {
|
type TranslationSet struct {
|
||||||
AddFavourite string
|
|
||||||
ErrorMessage string
|
|
||||||
NotEnoughSpace string
|
NotEnoughSpace string
|
||||||
ProjectTitle string
|
ProjectTitle string
|
||||||
MainTitle string
|
MainTitle string
|
||||||
|
|
|
||||||
|
|
@ -22,25 +22,26 @@ func NewTranslationSet(log *logrus.Entry) *TranslationSet {
|
||||||
|
|
||||||
log.Info("language: " + userLang)
|
log.Info("language: " + userLang)
|
||||||
|
|
||||||
set := englishSet()
|
baseSet := englishSet()
|
||||||
|
|
||||||
if strings.HasPrefix(userLang, "pl") {
|
for languageCode, translationSet := range GetTranslationSets() {
|
||||||
_ = mergo.Merge(&set, polishSet(), mergo.WithOverride)
|
if strings.HasPrefix(userLang, languageCode) {
|
||||||
|
_ = mergo.Merge(&baseSet, translationSet, mergo.WithOverride)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(userLang, "nl") {
|
return &baseSet
|
||||||
_ = mergo.Merge(&set, dutchSet(), mergo.WithOverride)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if strings.HasPrefix(userLang, "de") {
|
// GetTranslationSets gets all the translation sets, keyed by language code
|
||||||
_ = mergo.Merge(&set, germanSet(), mergo.WithOverride)
|
func GetTranslationSets() map[string]TranslationSet {
|
||||||
|
return map[string]TranslationSet{
|
||||||
|
"pl": polishSet(),
|
||||||
|
"nl": dutchSet(),
|
||||||
|
"de": germanSet(),
|
||||||
|
"tr": turkishSet(),
|
||||||
|
"en": englishSet(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(userLang, "tr") {
|
|
||||||
_ = mergo.Merge(&set, turkishSet(), mergo.WithOverride)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &set
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// detectLanguage extracts user language from environment
|
// detectLanguage extracts user language from environment
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import (
|
||||||
"github.com/jesseduffield/lazydocker/pkg/app"
|
"github.com/jesseduffield/lazydocker/pkg/app"
|
||||||
"github.com/jesseduffield/lazydocker/pkg/config"
|
"github.com/jesseduffield/lazydocker/pkg/config"
|
||||||
"github.com/jesseduffield/lazydocker/pkg/gui"
|
"github.com/jesseduffield/lazydocker/pkg/gui"
|
||||||
|
"github.com/jesseduffield/lazydocker/pkg/i18n"
|
||||||
)
|
)
|
||||||
|
|
||||||
type bindingSection struct {
|
type bindingSection struct {
|
||||||
|
|
@ -25,13 +26,12 @@ type bindingSection struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
langs := []string{"pl", "nl", "en"}
|
|
||||||
mConfig, err := config.NewAppConfig("lazydocker", "", "", "", "", true, nil, "")
|
mConfig, err := config.NewAppConfig("lazydocker", "", "", "", "", true, nil, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, lang := range langs {
|
for lang := range i18n.GetTranslationSets() {
|
||||||
os.Setenv("LC_ALL", lang)
|
os.Setenv("LC_ALL", lang)
|
||||||
mApp, _ := app.NewApp(mConfig)
|
mApp, _ := app.NewApp(mConfig)
|
||||||
file, err := os.Create(getProjectRoot() + "/docs/keybindings/Keybindings_" + lang + ".md")
|
file, err := os.Create(getProjectRoot() + "/docs/keybindings/Keybindings_" + lang + ".md")
|
||||||
|
|
|
||||||
30
scripts/translations/get_required_translations.go
Normal file
30
scripts/translations/get_required_translations.go
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
"github.com/jesseduffield/lazydocker/pkg/i18n"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.Println(getOutstandingTranslations())
|
||||||
|
}
|
||||||
|
|
||||||
|
// adapted from https://github.com/a8m/reflect-examples#read-struct-tags
|
||||||
|
func getOutstandingTranslations() string {
|
||||||
|
output := ""
|
||||||
|
for languageCode, translationSet := range i18n.GetTranslationSets() {
|
||||||
|
output += languageCode + ":\n"
|
||||||
|
v := reflect.ValueOf(translationSet)
|
||||||
|
|
||||||
|
for i := 0; i < v.NumField(); i++ {
|
||||||
|
value := v.Field(i).String()
|
||||||
|
if value == "" {
|
||||||
|
output += v.Type().Field(i).Name + "\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
output += "\n"
|
||||||
|
}
|
||||||
|
return output
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue