fix(i18n): lint, review and clean up a little

This commit is contained in:
Goutte 2023-04-05 05:55:48 +02:00
parent 775014c459
commit cdb680ac1e
2 changed files with 10 additions and 4 deletions

View file

@ -35,8 +35,10 @@ clean:
rm -rf $(BIN) rm -rf $(BIN)
i18n_extract: i18n_extract:
$(info ******************** extracting translation files ********************)
goi18n extract -outdir translations goi18n extract -outdir translations
goi18n merge -outdir translations translations/* goi18n merge -outdir translations translations/*
i18n_merge: i18n_merge:
$(info ******************** merging translation files ********************)
goi18n merge -outdir translations translations/* goi18n merge -outdir translations translations/*

View file

@ -3,10 +3,11 @@ package cobra
import ( import (
"embed" "embed"
"fmt" "fmt"
"os"
"github.com/BurntSushi/toml" "github.com/BurntSushi/toml"
"github.com/nicksnyder/go-i18n/v2/i18n" "github.com/nicksnyder/go-i18n/v2/i18n"
"golang.org/x/text/language" "golang.org/x/text/language"
"os"
) )
var defaultLanguage = language.English var defaultLanguage = language.English
@ -366,10 +367,13 @@ func detectLangs() []string {
func appendLang(langs *[]string, lang language.Tag) { func appendLang(langs *[]string, lang language.Tag) {
langString := lang.String() langString := lang.String()
langBase, _ := lang.Base()
*langs = append(*langs, langString) *langs = append(*langs, langString)
*langs = append(*langs, langBase.ISO3())
langBase, confidentInBase := lang.Base()
if confidentInBase != language.No {
*langs = append(*langs, langBase.String()) *langs = append(*langs, langBase.String())
*langs = append(*langs, langBase.ISO3())
}
} }
func setupLocalizer() { func setupLocalizer() {