-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tpl: Add localizedDate template function #2041
Conversation
Hi @soundrussian, it's a good idea to implement such a template function, especially while looking at #1744.
We should find a workaround once we have i18n support as a feature. Inside the template we will have access to the locale of the current page. Depending on the locale visitors should see the date formatted respectively. But this seems only to be possible when we set / change the environment accordingly. |
Actually, it is possible to set the locale during runtime by calling lctime.SetLocale("es_MX")
fmt.Println(lctime.Strftime("%c", time.Now()))
// prints: lun 14 dic 2015 22:31:56 PST From the readme. |
My bad. Thanks for the correction. Anyhow, it's a powerful combination. |
This one needs some thinking, the bigger picture and all. |
I've updated the code to set locale from |
Could you also add a few words for the documentation? Take a look at the examples in Maybe it seems trivial but why I would use |
bb794d0
to
72cb2f2
Compare
tpl: use languageCode to set locale Rename function to localizeDate docs: Describe localizeDate template helper
I agree that |
How would you define the bigger picture? The multilingual feature should provide a frame. A more precise context about parts that need some thoughts could help. I don't want to rush by adding this as a last-minute feature if we release the next version of Hugo soon. It's just a nice addition that fills a gap. |
I don't like the |
That is an extremely narrow minded picture ... I don't see the bigger picture, but I'm hoping someone else, specialists outside this project, would paint it for me. We're in the process of pulling lots of small localize* into a fairly fragmented and hard to maintain set of functions; there are language rulesets, dictionaries etc. duplicated, most likely not complete (I notice some shortcomings in my own language) ... We're not adding this in 0.17. What gets added is very hard to remove. |
@moorereason, Go makes international dates literally impossible. That's why This is a trade off between slightly more idiomatic code—and giving non-English users the luxury of dates. |
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This adds a template function to implement date localization, as was discussed in issue #245. All credit should really go to @variadico , I've just created a pull request to learn myself some Go.