Closed cs-qyzhang closed 2 years ago
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.