bowman2001 / perplex

A Hugo theme to publish technical content (docs, news, blog, articles)
https://perplex.desider.at
Apache License 2.0
27 stars 11 forks source link

[Feature request] Multilingual #159

Open clsty opened 5 months ago

clsty commented 5 months ago

E.g. a button to switch language.

Reference: https://gohugo.io/content-management/multilingual/

P.S. I love this theme. Not only the nice looking, but also its capability handle complex layout on the page. Thank you for such great work!

bowman2001 commented 5 months ago

Yes, this would be a big improvement. It’s a lot of work and my time in the foreseeable future is very limited. I don’t have much expierience with multilang in Hugo but I know there are going to be some improvements concerning multilang in the coming (big) next release 0.123.0. And maybe someone else want’s to add multilang capability to the templates when this release is availabe... I leave this open to any assignee for now.

Kariton commented 2 weeks ago

Despite the fact that im a absolute CSS noob i gave it a try... At least the button is there - and it works. :D

current iteration works with dropdown and the language shortcode is always visible in the masthead. all content is saved in corresponding subfolders e.g. content/en / content/de and so on.

https://github.com/Kariton/perplex/tree/i18n-translations

obvious issues i have found:

Kariton commented 2 weeks ago

i updated the doc pages to work with my updated template as a demo / preview. the only translated thing is the title.

https://github.com/Kariton/perplexdoc/tree/multilang-support

@bowman2001 WDYT?

Kariton commented 2 weeks ago

despite the fact that i cant figure out how to properly css this dropdown menu i think that was somehow to easy and i totally missed something.

what did you had in mind for multilingual support? any template changes? or is it just that simple with hugo nowdays?

Kariton commented 1 week ago

i have added "i18n" string translations to the theme - those required some minor changes to the template

bowman2001 commented 1 week ago

Every hard-coded word or phrase in English inside the templates must be replaced by Hugo’s i18n translation function. The placeholder in this function needs translation tables in language-specific files in the (currently missing) i18n folder of the theme.

bowman2001 commented 1 week ago

This would be a major change to the theme and needs testing. I will create an i18n branch if you would like to contribute to these template changes and translations.

Kariton commented 1 week ago

I am already in the process to add "i18n" translations. i did not find that many.

Kariton commented 1 week ago

last thing i added today was a text block

"Missing Translation: Unfortunately, this site isn't available in {{ .RequestLang }}. As a fallback, this page is displayed in {{ .DefaultLang }}."

if someone wants to include "default" language posts in other languages they can do so with module:mounts: (i do it that way)

https://github.com/Kariton/perplexdoc/blob/124687ad47ce858808e9e08c4b21a0bc65cf4db8/config/_default/module.yaml

that text box requires every page to contain a param for its language. contentlanguage: en / contentlanguage: de because when they are mounted to "close" gaps the "site lang" is then the same where they are mounted. but to differentiate and highlight that this page is not available in the selected language i wanted this block.

Kariton commented 1 week ago

i have published my codebase where i currently use a branch of this theme which includes my PRs for the multilanguage setup as well as the currently open robots / sitemap changes.

https://github.com/Kariton/jaspers-it the website is live at https://jaspers.it

despite the missing content you can directly checkout what i have done until now.

The major problem I have is that my CSS skills are basically non-existent. :D