DEV Community

Cover image for Translations on-the-fly using Go
Go4WebDev
Go4WebDev

Posted on • Edited on

Translations on-the-fly using Go

There are several methods to make a Go web app "multilingual". I chose to store the translations in .po files. One language per file.

The Go html template looks like this:

<p>{{trans "Company"}}</p>

This means that the html template calls a func trans() and translates "Company" into the set language.

The html template is translated by Go web server before the page is rendered without noticeable delay.

Here is both an example and the code behind.

Top comments (0)