amagaki
amagaki copied to clipboard
Define how localization tagging works
We are abandoning Grow.dev's automatic localization untagging in order to limit memory usage and improve performance. After all, most content isn't localized, so it doesn't make sense to penalize all templates if content isn't localized to begin with.
We want to support the feature but require developers to use it explicitly rather than automatically.
Some thoughts:
Option 1 - Explicit !a.Localized
YAML tag.
# In YAML
foo: !a.Localized
default: Default content
de_DE: de_DE content
# In templates (add "L" filter consistent with "T" translation filter)
{{doc.foo|l}} -> Returns "Default content" or "de_DE content" depending on the doc's locale
Option 2 - Preserve the same syntax as Grow.dev
# In YAML
foo: Default content
foo@de_DE: de_DE content
# In templates:
{{doc|l('foo')}} -> Returns "default content" or "de_DE content" depending on the doc's locale
{{l('doc.foo')}} -> Same as above
Option 3 - Something else I'm not thinking of?
I have a preference for Option 1 because the usage is clearer in templates and having the a.Localized
object likely makes it more scalable in the future in case we need to add more features to that.
# For nested structures
{{doc.foo|l().bar}}