Finish translation fix for 14.5.md
This commit is contained in:
14
en/14.5.md
14
en/14.5.md
@@ -60,17 +60,17 @@ In order to facilitate multi-language calls in the template package directly, we
|
||||
return beego.Translation.Money(s)
|
||||
}
|
||||
|
||||
## Use multi-language development
|
||||
## Multi-language development
|
||||
|
||||
1. Set the location of language and language packs, then initialize the i18n objects:
|
||||
1. Setting the language and location of the language pack, then initialize i18n objects:
|
||||
|
||||
beego.Lang = "zh"
|
||||
beego.LangPath = "views/lang"
|
||||
beego.InitLang()
|
||||
|
||||
2. Design Multi-language Pack
|
||||
2. Designing a multi-language package
|
||||
|
||||
The above talked about how to initialize multi language pack, the language pack is now designing multi, multi-language package is json file, as described in Chapter X, we need to design a document on LangPath following example zh.json or en.json
|
||||
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:
|
||||
|
||||
# zh.json
|
||||
|
||||
@@ -90,16 +90,16 @@ In order to facilitate multi-language calls in the template package directly, we
|
||||
}
|
||||
}
|
||||
|
||||
3. Use the Language Pack
|
||||
3. Using language packages
|
||||
|
||||
We can call the controller to get the response of the translation language translation, as follows:
|
||||
We can call the controller to get the translated response in the desired language, like so::
|
||||
|
||||
func (this *MainController) Get() {
|
||||
this.Data["create"] = beego.Translation.Translate("create")
|
||||
this.TplNames = "index.tpl"
|
||||
}
|
||||
|
||||
We can also directly call response in the template translation function:
|
||||
We can also directly interpolate translated responses in our templates:
|
||||
|
||||
// Direct Text translation
|
||||
{{.create | Trans}}
|
||||
|
||||
Reference in New Issue
Block a user