mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-28 22:19:59 +02:00
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:
@@ -14,6 +14,7 @@
|
||||
package i18n
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@@ -408,9 +409,10 @@ other = "{{ . }} miesiąca"
|
||||
c.Assert(d.LoadResources(), qt.IsNil)
|
||||
|
||||
f := tp.t.Func(test.lang)
|
||||
ctx := context.Background()
|
||||
|
||||
for _, variant := range test.variants {
|
||||
c.Assert(f(test.id, variant.Key), qt.Equals, variant.Value, qt.Commentf("input: %v", variant.Key))
|
||||
c.Assert(f(ctx, test.id, variant.Key), qt.Equals, variant.Value, qt.Commentf("input: %v", variant.Key))
|
||||
c.Assert(int(depsCfg.Logger.LogCounters().WarnCounter.Count()), qt.Equals, 0)
|
||||
}
|
||||
|
||||
@@ -422,7 +424,7 @@ other = "{{ . }} miesiąca"
|
||||
func doTestI18nTranslate(t testing.TB, test i18nTest, cfg config.Provider) string {
|
||||
tp := prepareTranslationProvider(t, test, cfg)
|
||||
f := tp.t.Func(test.lang)
|
||||
return f(test.id, test.args)
|
||||
return f(context.Background(), test.id, test.args)
|
||||
}
|
||||
|
||||
type countField struct {
|
||||
@@ -542,7 +544,7 @@ func BenchmarkI18nTranslate(b *testing.B) {
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
f := tp.t.Func(test.lang)
|
||||
actual := f(test.id, test.args)
|
||||
actual := f(context.Background(), test.id, test.args)
|
||||
if actual != test.expected {
|
||||
b.Fatalf("expected %v got %v", test.expected, actual)
|
||||
}
|
||||
|
Reference in New Issue
Block a user