Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

Change Translator receiver from pointer to struct.

joyqi73dc7e744f32
diff --git a/plugin/plugin.go b/plugin/plugin.go
index 47899f78..6643b5a1 100644
--- a/plugin/plugin.go
+++ b/plugin/plugin.go
@@ -135,8 +135,8 @@ func SetContext(ctx *GinContext, ts ...Translator) {
}
// Translate translates the key to the current language of the context
-func (t *Translator) Translate(ctx *GinContext) string {
- if t == nil {
+func (t Translator) Translate(ctx *GinContext) string {
+ if &t == nil || t.fn == nil {
return ""
}
@@ -144,11 +144,11 @@ func (t *Translator) Translate(ctx *GinContext) string {
}
// SetContext sets the context of the translator
-func (t *Translator) SetContext(ctx *GinContext) {
+func (t Translator) SetContext(ctx *GinContext) {
t.ctx = ctx
}
// String returns the translated string through the context
-func (t *Translator) String() string {
+func (t Translator) String() string {
return t.Translate(t.ctx)
}