Skip to content
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

Date.Format Internationalization #245

Closed
tubia opened this issue Mar 30, 2014 · 5 comments
Closed

Date.Format Internationalization #245

tubia opened this issue Mar 30, 2014 · 5 comments
Labels

Comments

@tubia
Copy link

tubia commented Mar 30, 2014

Hi,
Maybe I don't understand well the logic of the .Date.Format variable, but it's possible to change the language of the months (for example) when they are displayed?
Something like {{ .Date.Format.IT "30 marzo 2006" }}

@tummychow
Copy link
Contributor

The standard Go time package don't have internationalization built in. You can see the list of month names that Go is aware of here, and they're all English. The easiest solution would probably be to display the months as numbers instead.

@spf13
Copy link
Contributor

spf13 commented Apr 7, 2014

For this we use two different packages.

The go standard date library and cast

Since neither support what you are looking for, I'm going to close this for now. The right answer is for someone to extend the standard date library to support this.

@spf13 spf13 closed this as completed Apr 7, 2014
@jice-lavocat
Copy link

A hint for those who would like to solve the problem with Javascript : you can use the Moment.js library to format/localize your dates.

@variadico
Copy link

Hi, there.

I wrote a general-purpose package, called lctime, that might be able to fix this issue. It uses locales and strftime to format dates internationally. In addition, I use go-bindata to bundle locale data, which means devs don't have to distribute anything extra with their app.

I was thinking this issue could be easily solved if we could add lctime.Strftime as a template function. Then people could use this in their templates.

<p>{{strftime "%c" .Date}}</p>

The default locale is based on environment variables. However, if people want to change the locale, they can start Hugo like this.

LC_TIME=es_MX hugo server

Or maybe they could add a locale field in their config.yaml and Hugo could call lctime.SetLocale to explicitly set the locale.

Let me know if this is something that sounds interesting. I wouldn't mind opening a PR. Happy holidays! 🎄

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants