Localization when using time.Format

go, localization, time

Solution

As you can see in time package sourcecode that values are hardcoded in source. So, basically, Go doesn't support i18n right now. i18n is on Go roadmap, its even mentioned in the faq, but there were no comments on that topic recently.

Meanwhile, you could try to use Monday package:

  // Change LocaleEnUS to the locale you want to use for translation
  monday.Format(time.Now(), "Mon 2 January 2006", monday.LocaleEnUS) 

Problem

In the `time` package, when formatting a `time.Time` variable, the output will use the English names for weeks and months as defined in unexported []string slices. How to localize the string, using a different language (hopefully still using `Format()`)? Example: ``` fmt.Println(time.Now().Format("Mon 2 January 2006")) ``` Output: Tue 28 January 2014 Desired output: Tis 28 Januari 2014 Playground

Original source