i18n support for Golang Web application HTML templates

Issue

Does anyone has a good idea to localize HTML templates in Golang Web application? Now I’m using Gin and go-i18n, but I will use other frameworks if they can localize.

If possible, I want to define the localized messages in property (or JSON/yaml/toml,…) files for each language:

label.password = パスワード # Password in Japanese 

and write localized html like Thymeleaf:

<label th:text="#{label.password}"></label>

Solution

I chose to use i18next instead of go-i18n because the message keys can be embedded in HTML and replaced with language JSON files.

Answered By – Kohei TAMURA

Answer Checked By – Jay B. (GoLangFix Admin)

Leave a Reply

Your email address will not be published.