3
0

Add logic for resource translation import/export

This commit is contained in:
Tomaž Jerman
2023-02-27 15:57:56 +01:00
parent c42cf298de
commit 7af889c164
15 changed files with 641 additions and 19 deletions

View File

@@ -704,16 +704,17 @@ func unmarshalFlatRBACNode(n *yaml.Node, acc rbac.Access) (out envoyx.NodeSet, e
// // // // // // // // // // // // // // // // // // // // // // // // //
func unmarshalLocaleNode(n *yaml.Node) (out envoyx.NodeSet, err error) {
return out, y7s.EachMap(n, func(lang, loc *yaml.Node) error {
err = y7s.EachMap(n, func(lang, loc *yaml.Node) error {
langTag := systemTypes.Lang{Tag: language.Make(lang.Value)}
return y7s.EachMap(loc, func(res, kv *yaml.Node) error {
return y7s.EachMap(kv, func(k, msg *yaml.Node) error {
out = append(out, &envoyx.Node{
Resource: &systemTypes.ResourceTranslation{
Lang: langTag,
K: k.Value,
Message: msg.Value,
Resource: res.Value,
Lang: langTag,
K: k.Value,
Message: msg.Value,
},
// Providing resource type as plain text to reduce cross component references
ResourceType: "corteza::system:resource-translation",
@@ -723,6 +724,21 @@ func unmarshalLocaleNode(n *yaml.Node) (out envoyx.NodeSet, err error) {
})
})
})
if err != nil {
return
}
for _, o := range out {
for _, r := range o.References {
if r.Scope.IsEmpty() {
continue
}
o.Scope = r.Scope
break
}
}
return
}
// // // // // // // // // // // // // // // // // // // // // // // // //