-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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 .Site.Language.I18n method (or .Translate?) #7844
Comments
I'm not totally sure about the method name. Since it should behave the same as the current |
Without a capitalized "I", I'd suggest: |
|
And also, I don't want to fill the |
Was this ever added? I can't seem to find it in the current documentation. |
No, not added... this issue is still open. If you are using a simple (no pluralization rules) translation table, you can mount the i18n directory to the data directory. i18n/en.toml
i18n/pl.toml
site config
Then in your template:
I don't know of any (simple1) way of handling this if your translation tables include pluralization rules, for example: i18n/pl.toml
Footnotes
|
+1 for this to support my use case: |
This introduces two methods to enable cross-site translations: - Site.Translate returns a translated string in the language of the given site. {{ range .AllTranslations }} {{ .Site.Translate "cat" 6 }} {{ end }} - Sites.GetSite returns the site corresponding to the given language. This method simplifies cross-site translations. {{ with .Sites.GetSite "en" }} {{ .Translate "dog" 7 }} {{ end }} Closes gohugoio#7844
- Site.Language.Translate returns a translated string in the language of the given site. {{ range .AllTranslations }} {{ .Site.Language.Translate "cat" 6 }} {{ end }} - Sites.GetSite returns the site corresponding to the given language. This method simplifies cross-site translations. {{ with .Sites.GetSite "en" }} {{ .Language.Translate "dog" 7 }} {{ end }} Closes gohugoio#7844
Following the support question in this forum thread: it would be nice to have
site.Translation
method to leveragei18n
information from the.Translations
range.The text was updated successfully, but these errors were encountered: