Browse Source

refactor(locale): unexport a symbol

jvoisin 9 months ago
parent
commit
915b7b3cf7
2 changed files with 4 additions and 4 deletions
  1. 1 1
      internal/locale/catalog.go
  2. 3 3
      internal/locale/printer.go

+ 1 - 1
internal/locale/catalog.go

@@ -17,7 +17,7 @@ var defaultCatalog = make(catalog, len(AvailableLanguages))
 //go:embed translations/*.json
 var translationFiles embed.FS
 
-func GetTranslationDict(language string) (translationDict, error) {
+func getTranslationDict(language string) (translationDict, error) {
 	if _, ok := defaultCatalog[language]; !ok {
 		var err error
 		if defaultCatalog[language], err = loadTranslationFile(language); err != nil {

+ 3 - 3
internal/locale/printer.go

@@ -11,7 +11,7 @@ type Printer struct {
 }
 
 func (p *Printer) Print(key string) string {
-	if dict, err := GetTranslationDict(p.language); err == nil {
+	if dict, err := getTranslationDict(p.language); err == nil {
 		if str, ok := dict[key]; ok {
 			if translation, ok := str.(string); ok {
 				return translation
@@ -25,12 +25,12 @@ func (p *Printer) Print(key string) string {
 func (p *Printer) Printf(key string, args ...any) string {
 	translation := key
 
-	if dict, err := GetTranslationDict(p.language); err == nil {
 		str, found := dict[key]
 		if found {
 			var valid bool
 			translation, valid = str.(string)
 			if !valid {
+	if dict, err := getTranslationDict(p.language); err == nil {
 				translation = key
 			}
 		}
@@ -41,7 +41,7 @@ func (p *Printer) Printf(key string, args ...any) string {
 
 // Plural returns the translation of the given key by using the language plural form.
 func (p *Printer) Plural(key string, n int, args ...interface{}) string {
-	dict, err := GetTranslationDict(p.language)
+	dict, err := getTranslationDict(p.language)
 	if err != nil {
 		return key
 	}