How to handle i18n in Go?

限于喜欢 提交于 2019-12-09 05:07:34

问题


I searched on web but I didn't find anything related to i18n and Go.

I wish to use Go for develop web sites. What is the best way to handle internationalization?


回答1:


go-i18n has some nice features:

  • Implements CLDR plural rules.
  • Uses text/template for strings with variables.
  • Translation files are simple JSON.



回答2:


Packages roadmap

Comprehensive support for international text.
Support for international dates, times, etc.
Support for multilingual messages.

As you can see from the Go Roadmap, Go doesn't provide full i18n support yet.




回答3:


The new template package allows you to at add a function to template's function map, that would transform the given string to a localized version. What's going on underneath would be up to you for now, as the language choice could be based on headers sent by the browser.

That's a very basic use case for adding localized messages in a web app, for one.

Can't wait for the proper support for internationalization, local date and time formats.



来源:https://stackoverflow.com/questions/7585362/how-to-handle-i18n-in-go

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!