feat(04-02): load namespaced translations from embedded plugins
- Walk HasLang FS for lang/<locale>/<group>.yaml and flatten nested keys - Publish one phrasebook.Translator before Boot with en/en defaults - Hello plugin resolves en/pl vendor.plugin::group.key after Activate Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
3
examples/hello/plugins/base/lang/en/lang.yaml
Normal file
3
examples/hello/plugins/base/lang/en/lang.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
greeting: Hello
|
||||
labels:
|
||||
pluginName: Hello plugin
|
||||
3
examples/hello/plugins/base/lang/pl/lang.yaml
Normal file
3
examples/hello/plugins/base/lang/pl/lang.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
greeting: Cześć
|
||||
labels:
|
||||
pluginName: Wtyczka Hello
|
||||
@@ -9,11 +9,17 @@ import (
|
||||
"git.golem15.com/golem15/summercms/party"
|
||||
)
|
||||
|
||||
var _ pact.HasConfig = (*Plugin)(nil)
|
||||
var (
|
||||
_ pact.HasConfig = (*Plugin)(nil)
|
||||
_ pact.HasLang = (*Plugin)(nil)
|
||||
)
|
||||
|
||||
//go:embed config
|
||||
var configFS embed.FS
|
||||
|
||||
//go:embed lang
|
||||
var langFS embed.FS
|
||||
|
||||
// Plugin is the golem15.hello plugin.
|
||||
type Plugin struct{}
|
||||
|
||||
@@ -24,6 +30,7 @@ func (p *Plugin) Register(*backpack.App) error { return nil }
|
||||
func (p *Plugin) Boot(*backpack.App) error { return nil }
|
||||
|
||||
func (p *Plugin) ConfigFS() fs.FS { return configFS }
|
||||
func (p *Plugin) LangFS() fs.FS { return langFS }
|
||||
|
||||
func init() {
|
||||
party.Register(&Plugin{})
|
||||
|
||||
Reference in New Issue
Block a user