Skip to content

Commit

Permalink
fix(li18ngo): use nefilim absolute-fs to access translation file (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
plastikfan committed Oct 24, 2024
1 parent f4537d8 commit 766c709
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 337 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/onsi/ginkgo/v2 v2.20.2
github.com/onsi/gomega v1.34.2
github.com/pkg/errors v0.9.1
github.com/snivilised/nefilim v0.1.1
github.com/snivilised/nefilim v0.1.4
golang.org/x/text v0.19.0
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/snivilised/nefilim v0.1.1 h1:uMhLSfj5prGr2bahwzSM50rpd22fiiv0ZDLSzxYWsgg=
github.com/snivilised/nefilim v0.1.1/go.mod h1:+4/hKxgfvE8eNjLMJC+3ropEZSQuiR/NqfPtIuw7ZMw=
github.com/snivilised/nefilim v0.1.4 h1:bhiENDl/T6ZQO146eF8UnxtXLQenSzEyjwuTeWScImw=
github.com/snivilised/nefilim v0.1.4/go.mod h1:+4/hKxgfvE8eNjLMJC+3ropEZSQuiR/NqfPtIuw7ZMw=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY=
Expand Down
116 changes: 0 additions & 116 deletions internal/ifs/file-systems.go

This file was deleted.

3 changes: 0 additions & 3 deletions internal/ifs/ifs-defs.go

This file was deleted.

46 changes: 0 additions & 46 deletions internal/ifs/matchers_test.go

This file was deleted.

128 changes: 0 additions & 128 deletions internal/ifs/nfs-suite_test.go

This file was deleted.

5 changes: 3 additions & 2 deletions internal/translate/localizer-factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

func createLocalizer(lang *LanguageInfo, sourceID string,
fS nef.MakeDirFS,
fS nef.ReaderFS,
) (*i18n.Localizer, error) {
bundle := i18n.NewBundle(lang.Tag)
bundle.RegisterUnmarshalFunc("json", json.Unmarshal)
Expand All @@ -35,8 +35,9 @@ func createLocalizer(lang *LanguageInfo, sourceID string,
return i18n.NewLocalizer(bundle, supported...), nil
}

// returns an absolute reference to the bundle file
func resolveBundlePath(lang *LanguageInfo, txSource TranslationSource,
fS nef.MakeDirFS,
fS nef.ReaderFS,
) string {
path := lo.Ternary(txSource.Path != "" && fS.DirectoryExists(txSource.Path),
txSource.Path,
Expand Down
6 changes: 2 additions & 4 deletions internal/translate/multiplexor-container.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package translate

import (
"io/fs"

"github.com/nicksnyder/go-i18n/v2/i18n"
nef "github.com/snivilised/nefilim"
)
Expand All @@ -20,8 +18,8 @@ func (mx *multiplexor) invoke(localizer *i18n.Localizer, data Localisable) (stri
type multiContainer struct {
multiplexor
localizers localizerContainer
queryFS fs.StatFS
fS nef.MakeDirFS
queryFS nef.ReaderFS
fS nef.ReaderFS
create LocalizerCreatorFn
}

Expand Down
6 changes: 2 additions & 4 deletions internal/translate/translate-defs.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package translate

import (
"io/fs"

"github.com/nicksnyder/go-i18n/v2/i18n"
"github.com/pkg/errors"
nef "github.com/snivilised/nefilim"
Expand Down Expand Up @@ -67,7 +65,7 @@ type (
// LocalizerCreatorFn represents the signature of the function that can
// optionally be provided to override how an i18n Localizer is created.
LocalizerCreatorFn func(li *LanguageInfo, sourceID string,
fS nef.MakeDirFS,
fS nef.ReaderFS,
) (*i18n.Localizer, error)

// UseOptionFn functional options function required by Use.
Expand Down Expand Up @@ -102,7 +100,7 @@ type (
// FS is a file system from where translations are loaded from. This
// does not have to performed explicitly asa it will be created using
// the From field if not specified.
FS fs.StatFS
FS nef.ReaderFS
}

// LanguageInfo information pertaining to setting language. Auto detection
Expand Down
Loading

0 comments on commit 766c709

Please sign in to comment.