i18n: wires up translations for plugins (#102853)

* i18n: consolidate i18n types & runtime services

* Chore: updates after PR feedback

* Chore: updates after feedback

* Chore: updates after feedback

* Chore: adds feature toggle

* Chore: adds locale to backend

* Chore: adds locales to i18n instance

* Chore: fix missing path in CODEOWNERS

* Chore: fix go lint issues

* Chore: fix missing path in CODEOWNERS

* Chore: updates after PR feedback

* Trigger build

* Chore: updates after PR feedback

* Chore: use resolved language for lookup

* Chore: updates after PR feedback

* Update pkg/plugins/plugins.go

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>

* Chore: updates after PR feedback

* Chore: updates after PR feedback

---------

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
This commit is contained in:
Hugo Häggmark
2025-03-31 06:38:38 +02:00
committed by GitHub
co-authored by Will Browne
parent 7ea0fab606
commit 18ae5d7f0c
29 changed files with 759 additions and 46 deletions
@@ -190,6 +190,21 @@ func TestService(t *testing.T) {
require.NoError(t, err)
require.Equal(t, oneCDNRelativeURL, u)
})
t.Run("GetTranslations", func(t *testing.T) {
pluginInfo := NewPluginInfo(jsonData["one"], plugins.ClassExternal, pluginFS("one"), nil)
pluginInfo.pluginJSON.Languages = []string{"en-US", "pt-BR"}
translations, err := svc.GetTranslations(pluginInfo)
require.NoError(t, err)
oneCDNURL, err := url.JoinPath(tc.cdnBaseURL, "one", "1.0.0", "public", "plugins", "one")
require.NoError(t, err)
enURL, err := url.JoinPath(oneCDNURL, "locales", "en-US", "one.json")
require.NoError(t, err)
ptBRURL, err := url.JoinPath(oneCDNURL, "locales", "pt-BR", "one.json")
require.NoError(t, err)
require.Equal(t, map[string]string{"en-US": enURL, "pt-BR": ptBRURL}, translations)
})
})
}
}