Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add translation hook for metadata content #2987

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

nbusseneau
Copy link
Contributor

@nbusseneau nbusseneau commented Aug 24, 2020

Problem: I wanted to localize the description metadata, but couldn't find a way to localize site.yaml.
I settled on using languages.yaml as a way to localize site.yaml metadata keys from metadata.html.twig, when they exist in both.

Users can override site.yaml metadata keys by providing a corresponding GRAV.METADATA.key via languages.yaml.

This is a working PR, but I don't believe this solution is elegant, even if it works fine. Input is welcome. Ideas?

Users can override site.yaml metadata keys by providing a corresponding
GRAV.METADATA.key via languages.yaml.
@mahagr mahagr requested a review from rhukster August 25, 2020 07:48
@nbusseneau
Copy link
Contributor Author

nbusseneau commented Aug 29, 2020

While skimming the doc, I discovered that we can actually override the description metadata at the page-level. Since pages are easily localized, localizing description for the home page is actually very easy. I am adding a fix to this translation hook so that page overrides take precedence when present.

Discussion: the translation hook trick would only be useful if one wants to localize the default global description tag for when one is not set up at the page level.

I have given it some more thought and I believe a good solution would be to mimic what's currently possible with templates: https://learn.getgrav.org/16/content/multi-language#language-based-twig-templates

Subfolders for overriding config values, e.g. config/fr/site.yaml.

What do you think?

Global metadata coming from translations will only be used if currently
processed metadata was not overriden at the page level.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant