Fix loading overridden translations from ${DataFolder}/resources/i18n

This commit is contained in:
Deluan
2022-02-10 14:48:41 -05:00
parent 50ff8bcce7
commit 028723f721
5 changed files with 17 additions and 21 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ var (
)
func newTranslationRepository(context.Context) rest.Repository {
if err := loadTranslations(resources.FS); err != nil {
if err := loadTranslations(resources.FS()); err != nil {
log.Error("Error loading translation files", err)
}
return &translationRepository{}
+5 -8
View File
@@ -3,7 +3,7 @@ package nativeapi
import (
"encoding/json"
"io"
"net/http"
"io/fs"
"os"
"path/filepath"
@@ -15,17 +15,14 @@ import (
var _ = Describe("Translations", func() {
Describe("I18n files", func() {
var fs http.FileSystem
BeforeEach(func() {
fs = http.FS(resources.FS)
})
It("contains only valid json language files", func() {
dir, _ := fs.Open(consts.I18nFolder)
files, _ := dir.Readdir(0)
fsys := resources.FS()
dir, _ := fsys.Open(consts.I18nFolder)
files, _ := dir.(fs.ReadDirFile).ReadDir(-1)
for _, f := range files {
name := filepath.Base(f.Name())
filePath := filepath.Join(consts.I18nFolder, name)
file, _ := fs.Open(filePath)
file, _ := fsys.Open(filePath)
data, _ := io.ReadAll(file)
var out map[string]interface{}