How to handle i18n in Go?

前端 未结 3 1325
别跟我提以往
别跟我提以往 2021-02-06 23:47

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?

相关标签:
3条回答
  • 2021-02-07 00:22

    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.

    0 讨论(0)
  • 2021-02-07 00:33

    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.

    0 讨论(0)
  • 2021-02-07 00:46

    go-i18n has some nice features:

    • Implements CLDR plural rules.
    • Uses text/template for strings with variables.
    • Translation files are simple JSON.
    0 讨论(0)
提交回复
热议问题