Page context handling in i18n

This is a workaround. We need to improve on this, but not today.

Fixes #10782
This commit is contained in:
Bjørn Erik Pedersen
2023-03-04 14:43:23 +01:00
parent ec1c97e7e9
commit 6c798eba60
6 changed files with 115 additions and 9 deletions

View File

@@ -15,6 +15,7 @@
package lang
import (
"context"
"fmt"
"math"
"strconv"
@@ -45,7 +46,7 @@ type Namespace struct {
}
// Translate returns a translated string for id.
func (ns *Namespace) Translate(id any, args ...any) (string, error) {
func (ns *Namespace) Translate(ctx context.Context, id any, args ...any) (string, error) {
var templateData any
if len(args) > 0 {
@@ -60,7 +61,7 @@ func (ns *Namespace) Translate(id any, args ...any) (string, error) {
return "", nil
}
return ns.deps.Translate(sid, templateData), nil
return ns.deps.Translate(ctx, sid, templateData), nil
}
// FormatNumber formats number with the given precision for the current language.