Fix translations not looking for correct file.

pull/11698/head
Andriy Dzikh 2021-06-18 09:15:06 -07:00
parent c3f46d1e7c
commit fa7c151fdb
1 changed files with 2 additions and 5 deletions

View File

@ -19,7 +19,6 @@ package translate
import (
"encoding/json"
"fmt"
"path"
"strings"
"github.com/cloudfoundry-attic/jibber_jabber"
@ -70,14 +69,12 @@ func DetermineLocale() {
// Load translations for preferred language into memory.
p := preferredLanguage.String()
translationFile := path.Join("translations", fmt.Sprintf("%s.json", p))
t, err := translations.Translations.ReadFile(translationFile)
t, err := translations.Translations.ReadFile(fmt.Sprintf("%s.json", p))
if err != nil {
// Attempt to find a more broad locale, e.g. fr instead of fr-FR.
if strings.Contains(p, "-") {
p = strings.Split(p, "-")[0]
translationFile := path.Join("translations", fmt.Sprintf("%s.json", p))
t, err = translations.Translations.ReadFile(translationFile)
t, err = translations.Translations.ReadFile(fmt.Sprintf("%s.json", p))
if err != nil {
klog.V(1).Infof("Failed to load translation file for %s: %v", p, err)
return