Presenting dates only possible in English (e.g. month using %B becomes "March")
Only English seems to be supported for presenting dates.
An example:
# config.toml
default_language = "nl"
<!-- index.html -->
{{ "2020-03-20" | date(format="%e %B %Y") }}
Expected: "20 maart 2021" Actual: "20 March 2021"
The underlying time library (chrono) only supports English locale currently :/
The underlying time library (chrono) only supports English locale currently :/
In that case, there are three options:
- Open an issue/create a PR for Chrono to add the feature
- Switch to another library
- Hack a solution together as a patch
Ideally, option one or two would be done. But I don't think that can/will be done in the short term, so even option three would be good for me.
Al I need is translating 12 month names. I'd be happy if there's even a hacky solution.
Looks like https://github.com/chronotope/chrono/pull/453 is merged? I haven't checked how to use it and whether it's actually complete/working though.
A hacky version would be to have some JavaScript reformatting the dates automatically.
Looks like chronotope/chrono#453 is merged? I haven't checked how to use it and whether it's actually complete/working though.
I think "locale" refers to timezone, not language (or timezone and language).
A hacky version would be to have some JavaScript reformatting the dates automatically.
I was actually hoping for something compile-time.
I think "locale" refers to timezone, not language (or timezone and language).
I should have read that issue first :(
I don't think there is a solution in Rust currently.
Actually, If I read it correctly, https://github.com/chronotope/chrono/pull/453 does provide month/day translation. See the outlying documentation on the unstable-locales feature. (The feature imports pure-rust-locales, which describes itself as "imported directly from the GNU C Library" and contains the translations directly.)
So, there's some hope for under-the-hood localization (including translation) if the project is comfortable with pinning a version of chrono and using unstable-locales.
post-script edit: not trivial, of course, but possible with the _localized functions and a feature in Tera that gates access to these calls? Though I think NaiveDatetime is very prevalent in Tera at a first glance, so this would be a lot of branching...
I believe that would only happen for a new version, not for v1