From 398ceb1dd94f2ce99f753daf6e95f434116390d9 Mon Sep 17 00:00:00 2001 From: stk Date: Sun, 30 Jun 2024 10:41:48 +0200 Subject: [PATCH] Fix loading translation set json files on Windows It seems that the embed.FS always uses foreward slashes, even on Windows. This not only affected generating the cheatsheets, but also loading a translation file in production. --- pkg/i18n/i18n.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/i18n/i18n.go b/pkg/i18n/i18n.go index ea5fcbb06..f9febbe01 100644 --- a/pkg/i18n/i18n.go +++ b/pkg/i18n/i18n.go @@ -3,8 +3,8 @@ package i18n import ( "embed" "encoding/json" + "fmt" "io/fs" - "path/filepath" "strings" "github.com/cloudfoundry/jibber_jabber" @@ -83,7 +83,7 @@ func getSupportedLanguageCodes() ([]string, error) { } func readLanguageFile(languageCode string) (*TranslationSet, error) { - jsonData, err := embedFS.ReadFile(filepath.Join("translations", languageCode+".json")) + jsonData, err := embedFS.ReadFile(fmt.Sprintf("translations/%s.json", languageCode)) if err != nil { return nil, err }