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)
i18n_extract:
$(info ******************** extracting translation files ********************)
goi18n extract -outdir translations
goi18n merge -outdir translations translations/*
i18n_merge:
$(info ******************** merging translation files ********************)
goi18n merge -outdir translations translations/*

View file

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