diff --git a/.vscode/settings.json b/.vscode/settings.json index 95d797a..dc380cb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -66,6 +66,7 @@ "nakedret", "natefinch", "navi", + "nicksnyder", "nolint", "nolintlint", "nosec", diff --git a/go.mod b/go.mod index 4f1f8ac..3da20fc 100644 --- a/go.mod +++ b/go.mod @@ -60,7 +60,7 @@ require ( github.com/magiconair/properties v1.8.7 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/natefinch/lumberjack v2.0.0+incompatible - github.com/nicksnyder/go-i18n/v2 v2.4.0 // indirect + github.com/nicksnyder/go-i18n/v2 v2.4.0 github.com/pelletier/go-toml/v2 v2.1.1 // indirect github.com/snivilised/cobrass v0.4.5 github.com/spf13/afero v1.11.0 // indirect diff --git a/src/app/command/bootstrap.go b/src/app/command/bootstrap.go index a34741f..aee2ffb 100644 --- a/src/app/command/bootstrap.go +++ b/src/app/command/bootstrap.go @@ -23,7 +23,7 @@ import ( "github.com/snivilised/pixa/src/app/plog" "github.com/snivilised/pixa/src/app/proxy" "github.com/snivilised/pixa/src/app/proxy/common" - "github.com/snivilised/pixa/src/i18n" + "github.com/snivilised/pixa/src/locale" ) type LocaleDetector interface { @@ -125,8 +125,8 @@ func (b *Bootstrap) Root(options ...ConfigureOptionFn) *cobra.Command { b.Container = assistant.NewCobraContainer( &cobra.Command{ Use: "main", - Short: xi18n.Text(i18n.RootCmdShortDescTemplData{}), - Long: xi18n.Text(i18n.RootCmdLongDescTemplData{}), + Short: xi18n.Text(locale.RootCmdShortDescTemplData{}), + Long: xi18n.Text(locale.RootCmdLongDescTemplData{}), Version: fmt.Sprintf("'%v'", Version), RunE: func(_ *cobra.Command, args []string) error { inputs := b.getRootInputs() @@ -178,7 +178,7 @@ func (b *Bootstrap) Root(options ...ConfigureOptionFn) *cobra.Command { func (b *Bootstrap) configure() { if err := b.OptionsInfo.Runner.Run(); err != nil { - msg := xi18n.Text(i18n.UsingConfigFileTemplData{ + msg := xi18n.Text(locale.UsingConfigFileTemplData{ ConfigFileName: b.OptionsInfo.Config.Viper.ConfigFileUsed(), }) diff --git a/src/app/command/shrink-cmd.go b/src/app/command/shrink-cmd.go index e5455a7..57af1ff 100644 --- a/src/app/command/shrink-cmd.go +++ b/src/app/command/shrink-cmd.go @@ -17,7 +17,7 @@ import ( "github.com/snivilised/pixa/src/app/proxy" "github.com/snivilised/pixa/src/app/proxy/common" - "github.com/snivilised/pixa/src/i18n" + "github.com/snivilised/pixa/src/locale" ) // We define all the options here, even the ones inherited from the root @@ -83,11 +83,11 @@ type shrinkParameterSetPtr = *assistant.ParamSet[common.ShrinkParameterSet] func (b *Bootstrap) buildShrinkCommand(container *assistant.CobraContainer) *cobra.Command { shrinkCommand := &cobra.Command{ Use: "shrink", - Short: i18n.LeadsWith( + Short: locale.LeadsWith( "shrink", - xi18n.Text(i18n.ShrinkCmdShortDefinitionTemplData{}), + xi18n.Text(locale.ShrinkCmdShortDefinitionTemplData{}), ), - Long: xi18n.Text(i18n.ShrinkLongDefinitionTemplData{}), + Long: xi18n.Text(locale.ShrinkLongDefinitionTemplData{}), RunE: func(cmd *cobra.Command, args []string) error { var appErr error @@ -168,7 +168,7 @@ func (b *Bootstrap) buildShrinkCommand(container *assistant.CobraContainer) *cob paramSet.BindValidatedString( newShrinkFlagInfoWithShort( - xi18n.Text(i18n.ShrinkCmdOutputPathParamUsageTemplData{}), + xi18n.Text(locale.ShrinkCmdOutputPathParamUsageTemplData{}), defaultOutputPath, ), ¶mSet.Native.OutputPath, func(_ string, _ *pflag.Flag) error { @@ -190,7 +190,7 @@ func (b *Bootstrap) buildShrinkCommand(container *assistant.CobraContainer) *cob paramSet.BindValidatedString( newShrinkFlagInfoWithShort( - xi18n.Text(i18n.ShrinkCmdTrashPathParamUsageTemplData{}), + xi18n.Text(locale.ShrinkCmdTrashPathParamUsageTemplData{}), defaultTrashPath, ), ¶mSet.Native.TrashPath, func(_ string, _ *pflag.Flag) error { @@ -212,7 +212,7 @@ func (b *Bootstrap) buildShrinkCommand(container *assistant.CobraContainer) *cob paramSet.BindBool( newShrinkFlagInfoWithShort( - xi18n.Text(i18n.ShrinkCmdCuddleParamUsageTemplData{}), + xi18n.Text(locale.ShrinkCmdCuddleParamUsageTemplData{}), defaultCuddle, ), ¶mSet.Native.Cuddle, @@ -228,7 +228,7 @@ func (b *Bootstrap) buildShrinkCommand(container *assistant.CobraContainer) *cob paramSet.BindValidatedFloat32Within( newShrinkFlagInfoWithShort( - xi18n.Text(i18n.ShrinkCmdGaussianBlurParamUsageTemplData{}), + xi18n.Text(locale.ShrinkCmdGaussianBlurParamUsageTemplData{}), defaultBlur, ), ¶mSet.Native.ThirdPartySet.GaussianBlur, @@ -246,7 +246,7 @@ func (b *Bootstrap) buildShrinkCommand(container *assistant.CobraContainer) *cob paramSet.BindValidatedEnum( newShrinkFlagInfoWithShort( - xi18n.Text(i18n.ShrinkCmdSamplingFactorParamUsageTemplData{}), + xi18n.Text(locale.ShrinkCmdSamplingFactorParamUsageTemplData{}), defaultSamplingFactor, ), ¶mSet.Native.ThirdPartySet.SamplingFactorEn.Source, @@ -254,7 +254,7 @@ func (b *Bootstrap) buildShrinkCommand(container *assistant.CobraContainer) *cob if f.Changed && !(common.SamplingFactorEnumInfo.IsValid(value)) { acceptableSet := common.SamplingFactorEnumInfo.AcceptablePrimes() - return i18n.NewInvalidSamplingFactorError(value, acceptableSet) + return locale.NewInvalidSamplingFactorError(value, acceptableSet) } return nil @@ -271,7 +271,7 @@ func (b *Bootstrap) buildShrinkCommand(container *assistant.CobraContainer) *cob paramSet.BindValidatedEnum( newShrinkFlagInfoWithShort( - xi18n.Text(i18n.ShrinkCmdInterlaceParamUsageTemplData{}), + xi18n.Text(locale.ShrinkCmdInterlaceParamUsageTemplData{}), defaultInterlace, ), ¶mSet.Native.ThirdPartySet.InterlaceEn.Source, @@ -279,7 +279,7 @@ func (b *Bootstrap) buildShrinkCommand(container *assistant.CobraContainer) *cob if f.Changed && !(common.InterlaceEnumInfo.IsValid(value)) { acceptableSet := common.InterlaceEnumInfo.AcceptablePrimes() - return i18n.NewInterlaceError(value, acceptableSet) + return locale.NewInterlaceError(value, acceptableSet) } return nil @@ -294,7 +294,7 @@ func (b *Bootstrap) buildShrinkCommand(container *assistant.CobraContainer) *cob paramSet.BindBool( newShrinkFlagInfoWithShort( - xi18n.Text(i18n.ShrinkCmdStripParamUsageTemplData{}), + xi18n.Text(locale.ShrinkCmdStripParamUsageTemplData{}), defaultStrip, ), ¶mSet.Native.ThirdPartySet.Strip, @@ -310,7 +310,7 @@ func (b *Bootstrap) buildShrinkCommand(container *assistant.CobraContainer) *cob paramSet.BindValidatedIntWithin( newShrinkFlagInfoWithShort( - xi18n.Text(i18n.ShrinkCmdQualityParamUsageTemplData{}), + xi18n.Text(locale.ShrinkCmdQualityParamUsageTemplData{}), defaultQuality, ), ¶mSet.Native.ThirdPartySet.Quality, diff --git a/src/internal/helpers/test-utils.go b/src/internal/helpers/test-utils.go index 65ed18d..e2ecc30 100644 --- a/src/internal/helpers/test-utils.go +++ b/src/internal/helpers/test-utils.go @@ -15,8 +15,8 @@ import ( "github.com/snivilised/cobrass/src/assistant/configuration" ci18n "github.com/snivilised/cobrass/src/assistant/i18n" "github.com/snivilised/pixa/src/app/proxy/common" - "github.com/snivilised/pixa/src/i18n" "github.com/snivilised/pixa/src/internal/matchers" + "github.com/snivilised/pixa/src/locale" xi18n "github.com/snivilised/extendio/i18n" "github.com/snivilised/extendio/xfs/storage" @@ -122,7 +122,7 @@ func UseI18n(l10nPath string) error { uo.From = xi18n.LoadFrom{ Path: l10nPath, Sources: xi18n.TranslationFiles{ - i18n.PixaSourceID: xi18n.TranslationSource{ + locale.PixaSourceID: xi18n.TranslationSource{ Name: "dummy-cobrass", }, diff --git a/src/i18n/default/pixa.active.en-GB.json b/src/locale/default/pixa.active.en-GB.json similarity index 100% rename from src/i18n/default/pixa.active.en-GB.json rename to src/locale/default/pixa.active.en-GB.json diff --git a/src/i18n/deploy/pixa.active.en-US.json b/src/locale/deploy/pixa.active.en-US.json similarity index 100% rename from src/i18n/deploy/pixa.active.en-US.json rename to src/locale/deploy/pixa.active.en-US.json diff --git a/src/i18n/i18n_suite_test.go b/src/locale/locale-suite_test.go similarity index 58% rename from src/i18n/i18n_suite_test.go rename to src/locale/locale-suite_test.go index 17dd065..4acd08c 100644 --- a/src/i18n/i18n_suite_test.go +++ b/src/locale/locale-suite_test.go @@ -1,4 +1,4 @@ -package i18n_test +package locale_test import ( "testing" @@ -7,7 +7,7 @@ import ( "github.com/onsi/gomega" ) -func TestI18n(t *testing.T) { +func TestLocale(t *testing.T) { gomega.RegisterFailHandler(ginkgo.Fail) - ginkgo.RunSpecs(t, "I18n Suite") + ginkgo.RunSpecs(t, "Locale Suite") } diff --git a/src/i18n/messages-command-errors.go b/src/locale/messages-command-errors.go similarity index 89% rename from src/i18n/messages-command-errors.go rename to src/locale/messages-command-errors.go index 65d7d14..15bc8c9 100644 --- a/src/i18n/messages-command-errors.go +++ b/src/locale/messages-command-errors.go @@ -1,6 +1,7 @@ -package i18n +package locale import ( + "github.com/nicksnyder/go-i18n/v2/i18n" xi18n "github.com/snivilised/extendio/i18n" ) @@ -12,8 +13,8 @@ type ShrinkCmdSamplingFactorInvalidTemplData struct { Acceptable string } -func (td ShrinkCmdSamplingFactorInvalidTemplData) Message() *xi18n.Message { - return &xi18n.Message{ +func (td ShrinkCmdSamplingFactorInvalidTemplData) Message() *i18n.Message { + return &i18n.Message{ ID: "shrink-cmd-sampling-factor-invalid.error", Description: "shrink command sampling factor failed validation", Other: "invalid sampling factor value: {{.Value}}, acceptable: {{.Acceptable}}", @@ -49,8 +50,8 @@ type ShrinkCmdInterlaceInvalidTemplData struct { Acceptable string } -func (td ShrinkCmdInterlaceInvalidTemplData) Message() *xi18n.Message { - return &xi18n.Message{ +func (td ShrinkCmdInterlaceInvalidTemplData) Message() *i18n.Message { + return &i18n.Message{ ID: "shrink-cmd-interlace-invalid.error", Description: "shrink command interlace failed validation", Other: "invalid interlace value: {{.Value}}, acceptable: {{.Acceptable}}", @@ -85,8 +86,8 @@ type ShrinkCmdOutputPathDoesNotExistTemplData struct { Path string } -func (td ShrinkCmdOutputPathDoesNotExistTemplData) Message() *xi18n.Message { - return &xi18n.Message{ +func (td ShrinkCmdOutputPathDoesNotExistTemplData) Message() *i18n.Message { + return &i18n.Message{ ID: "shrink-cmd-output-path-does-not-exist.error", Description: "shrink command mirror path does not exist validation", Other: "output path: {{.Path}}, does not exist", diff --git a/src/i18n/messages-command.go b/src/locale/messages-command.go similarity index 99% rename from src/i18n/messages-command.go rename to src/locale/messages-command.go index 0eb8057..291bc70 100644 --- a/src/i18n/messages-command.go +++ b/src/locale/messages-command.go @@ -1,7 +1,7 @@ -package i18n +package locale import ( - "github.com/snivilised/extendio/i18n" + "github.com/nicksnyder/go-i18n/v2/i18n" ) // ⚠️ for the usage definitions, make sure that the first token inside the "Other" diff --git a/src/i18n/messages-errors.go b/src/locale/messages-errors.go similarity index 88% rename from src/i18n/messages-errors.go rename to src/locale/messages-errors.go index 581bdc5..067c579 100644 --- a/src/i18n/messages-errors.go +++ b/src/locale/messages-errors.go @@ -1,7 +1,8 @@ -package i18n +package locale import ( - i18n "github.com/snivilised/extendio/i18n" + i18n "github.com/nicksnyder/go-i18n/v2/i18n" + xi18n "github.com/snivilised/extendio/i18n" ) // ❌ FooBar @@ -34,7 +35,7 @@ type FooBarErrorBehaviourQuery interface { } type FooBarError struct { - i18n.LocalisableError + xi18n.LocalisableError } // FooBar enables the client to check if error is FooBarError @@ -46,7 +47,7 @@ func (e FooBarError) FooBar() bool { // NewFooBarError creates a FooBarError func NewFooBarError(path string, reason error) FooBarError { return FooBarError{ - LocalisableError: i18n.LocalisableError{ + LocalisableError: xi18n.LocalisableError{ Data: FooBarTemplData{ Path: path, Reason: reason, diff --git a/src/i18n/messages-general.go b/src/locale/messages-general.go similarity index 85% rename from src/i18n/messages-general.go rename to src/locale/messages-general.go index 8982c28..42f2815 100644 --- a/src/i18n/messages-general.go +++ b/src/locale/messages-general.go @@ -1,7 +1,7 @@ -package i18n +package locale import ( - "github.com/snivilised/extendio/i18n" + "github.com/nicksnyder/go-i18n/v2/i18n" ) type UsingConfigFileTemplData struct { diff --git a/src/i18n/out/active.en-GB.json b/src/locale/out/active.en-GB.json similarity index 100% rename from src/i18n/out/active.en-GB.json rename to src/locale/out/active.en-GB.json diff --git a/src/i18n/out/active.en-US.json b/src/locale/out/active.en-US.json similarity index 100% rename from src/i18n/out/active.en-US.json rename to src/locale/out/active.en-US.json diff --git a/src/i18n/out/en-US/pixa.translate.en-US.json b/src/locale/out/en-US/pixa.translate.en-US.json similarity index 100% rename from src/i18n/out/en-US/pixa.translate.en-US.json rename to src/locale/out/en-US/pixa.translate.en-US.json diff --git a/src/i18n/out/translate.en-US.json b/src/locale/out/translate.en-US.json similarity index 100% rename from src/i18n/out/translate.en-US.json rename to src/locale/out/translate.en-US.json diff --git a/src/i18n/test-i18n-messages_test.go b/src/locale/test-locale-messages_test.go similarity index 94% rename from src/i18n/test-i18n-messages_test.go rename to src/locale/test-locale-messages_test.go index f00a22d..d12c076 100644 --- a/src/i18n/test-i18n-messages_test.go +++ b/src/locale/test-locale-messages_test.go @@ -1,7 +1,7 @@ -package i18n_test +package locale_test import ( - "github.com/snivilised/extendio/i18n" + "github.com/nicksnyder/go-i18n/v2/i18n" ) const ( diff --git a/src/i18n/translate-defs.go b/src/locale/translate-defs.go similarity index 94% rename from src/i18n/translate-defs.go rename to src/locale/translate-defs.go index f54c310..9c789b7 100644 --- a/src/i18n/translate-defs.go +++ b/src/locale/translate-defs.go @@ -1,4 +1,4 @@ -package i18n +package locale // TODO: Should be updated to use url of the implementing project, // so should not be left as arcadia. diff --git a/src/i18n/utils.go b/src/locale/utils.go similarity index 90% rename from src/i18n/utils.go rename to src/locale/utils.go index 55a49d7..060d446 100644 --- a/src/i18n/utils.go +++ b/src/locale/utils.go @@ -1,4 +1,4 @@ -package i18n +package locale import ( "strings"