14.5 Multi-language support

In the chapter where we introduced internationalization and localization, we developed the go-i18n library. In this section, we will see how this library is integrated into the Beego framework, and how it enables our Beego applications to support both internationalization and localization.

Multi-language development

Setting the language and location of the language pack, then initialize i18n objects:

beego.Lang = "zh"
beego.LangPath = "views/lang"
beego.InitLang()

Designing a multi-language package

Above, we talked about how to initialize a multi-language package. Now, let's look at how to design one. Multi-language packages are typically JSON files, as you've already seen in Chapter 10. We must provide translation files for languages we wish to support on our LangPath, such as the following: