From ea28b0485b44b97c06bef7f4b4a9a2e24f861209 Mon Sep 17 00:00:00 2001 From: plastikfan Date: Wed, 9 Oct 2024 10:54:56 +0100 Subject: [PATCH] ref(locale): use go-i18n.Message directly instead of extendio (#216) --- .vscode/settings.json | 1 + src/locale/messages-command-errors.go | 13 +++++++------ src/locale/messages-command.go | 2 +- src/locale/messages-errors.go | 7 ++++--- src/locale/messages-general.go | 2 +- src/locale/test-locale-messages_test.go | 2 +- 6 files changed, 15 insertions(+), 12 deletions(-) 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/src/locale/messages-command-errors.go b/src/locale/messages-command-errors.go index e475013..15bc8c9 100644 --- a/src/locale/messages-command-errors.go +++ b/src/locale/messages-command-errors.go @@ -1,6 +1,7 @@ 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/locale/messages-command.go b/src/locale/messages-command.go index 18e71fd..291bc70 100644 --- a/src/locale/messages-command.go +++ b/src/locale/messages-command.go @@ -1,7 +1,7 @@ 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/locale/messages-errors.go b/src/locale/messages-errors.go index 848b433..067c579 100644 --- a/src/locale/messages-errors.go +++ b/src/locale/messages-errors.go @@ -1,7 +1,8 @@ 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/locale/messages-general.go b/src/locale/messages-general.go index ed01b73..42f2815 100644 --- a/src/locale/messages-general.go +++ b/src/locale/messages-general.go @@ -1,7 +1,7 @@ package locale import ( - "github.com/snivilised/extendio/i18n" + "github.com/nicksnyder/go-i18n/v2/i18n" ) type UsingConfigFileTemplData struct { diff --git a/src/locale/test-locale-messages_test.go b/src/locale/test-locale-messages_test.go index acf1b3c..d12c076 100644 --- a/src/locale/test-locale-messages_test.go +++ b/src/locale/test-locale-messages_test.go @@ -1,7 +1,7 @@ package locale_test import ( - "github.com/snivilised/extendio/i18n" + "github.com/nicksnyder/go-i18n/v2/i18n" ) const (