Localization when using time.Format

前端 未结 1 1498
深忆病人
深忆病人 2021-01-05 00:03

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 []st

相关标签:
1条回答
  • 2021-01-05 00:22

    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) 
    
    0 讨论(0)
提交回复
热议问题