hugo
hugo copied to clipboard
Offer i18n for internal templates
Some internal templates are in English only. It would be important that they offer an option to use i18n, or fallback to a default value in English.
Examples:
The pagination template has several terms in English. This one is even more important, as it is an aria- element:
https://github.com/gohugoio/hugo/blob/52561d561a591a6fb757b6d417138e0a79bce790/tpl/tplimpl/embedded/templates/pagination.html#L79
The disqus template "powered by" message is not i18n: https://github.com/gohugoio/hugo/blob/52561d561a591a6fb757b6d417138e0a79bce790/tpl/tplimpl/embedded/templates/disqus.html#L22
The rss template also has some sections only in English: https://github.com/gohugoio/hugo/blob/52561d561a591a6fb757b6d417138e0a79bce790/tpl/tplimpl/embedded/templates/_default/rss.xml#L38
These are only some examples, there are others. There is need to find them, make a more complete list, then solve each of them. I believe this issue could be used to discuss how this will be approached.
I've used this construct before:
{{ or (T "key") "default" }}
But keep in mind that neither the --printI18nWarnings flag nor the enableMissingTranslationPlaceholders configuration setting care if you have a fallback value. If you don't have an entry in the translation table, the first will throw a warning and the second will replace the rendered fallback value with [i18n] key.
Arguably that's the correct behavior, but as soon as we change the embedded templates, those who use the --printI18nWarnings are going to see warnings they've never seen before.
I've used this construct before:
{{ or (T "key") "default" }}
I was thinking about something like that, yes.
Arguably that's the correct behavior, but as soon as we change the embedded templates, those who use the
--printI18nWarningsare going to see warnings they've never seen before.
If the user is asking for i18n warnings they'd want to have that information. Users who are only building in a single language wouldn't be bothered, as I imagine they wouldn't be using that flag.
I copied the pagination template and added the keys myself. Maybe you should try that approach.
I copied the pagination template and added the keys myself. Maybe you should try that approach.
@tycobrah I am not thinking of only myself, but as a benefit for the whole community. But if you've already done it, you could send a PR.
I translated to my own secondary language. Joe's approach seems better coz I only copied the terse section and extensively modified it.
I want to participate and enable him to support switching between hundreds of languages at will. My open-source project is specifically designed to combine AI for this purpose https://github.com/xnx3/translate I don't know if it's possible