You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'd like to add i18n support to this clean theme. I'm a newborn to Rust/Zola/Tera, so my knowledge is limited. I found three ways to do that:
Add a base template for every language, in these templates assign corresponding text to variables, and then extends one of them in base.html, replace every language-specific text with corresponding variable. One problem is variable defined in base template cannot used inside macro, so variables can only be passed into macro by using additional parameters. Another problem is the path of extends keyword must be static, so in order to switch language it seems must change the path of extends keyword instead of changing config.toml.
Define language-specific text in one macro, e.g. i18n::text(key), then use i18n::text(key="recent_projects") to get that text. This method seems better than method 1, but the macro definition is unelegent and will be very huge.
Define langauge-specific text in config.toml. This method is the simplest way, gives user more control of language-specific text, but the config.toml will be large.
The text was updated successfully, but these errors were encountered:
Hey, thanks for expressing your interest in adding i18n to Papaya!
I'm fairly new to Zola as well, so I checked how other themes have accomplished this, plus what the Zola documentation says.
I've discovered that Zola has a pre-existing trans() Tera function that works exactly as your second idea suggests. The translation keys are defined in the config.toml.
Would this suit your needs? If so, I could refactor my code to utilize the trans() functions and migrate my English keys into the config.toml.
Hi, I'd like to add i18n support to this clean theme. I'm a newborn to Rust/Zola/Tera, so my knowledge is limited. I found three ways to do that:
base.html
, replace every language-specific text with corresponding variable. One problem is variable defined in base template cannot used inside macro, so variables can only be passed into macro by using additional parameters. Another problem is the path ofextends
keyword must be static, so in order to switch language it seems must change the path ofextends
keyword instead of changingconfig.toml
.i18n::text(key)
, then usei18n::text(key="recent_projects")
to get that text. This method seems better than method 1, but the macro definition is unelegent and will be very huge.config.toml
. This method is the simplest way, gives user more control of language-specific text, but theconfig.toml
will be large.The text was updated successfully, but these errors were encountered: