diff --git a/en/eBook/10.3.md b/en/eBook/10.3.md index 5880d1c9..6d1ef4cb 100644 --- a/en/eBook/10.3.md +++ b/en/eBook/10.3.md @@ -102,7 +102,7 @@ Above, we've presented one way of managing and integrating a number of language 1 text information -Text information call `Tr.Translate` to achieve the appropriate information conversion, mapFunc is implemented as follows: +A simple text conversion function implementing a mapfunc can be seen below. It uses `Tr.Translate` to perform the appropriate translations: func I18nT(args ...interface{}) string { ok := false @@ -116,18 +116,18 @@ Text information call `Tr.Translate` to achieve the appropriate information conv return Tr.Translate(s) } -Registration function is as follows: +We register the function like so: t.Funcs(template.FuncMap{"T": I18nT}) -Using the following template: +Then use it from your template: {{.V.Submit | T}} 2. The date and time -Date and time to call `Tr.Time` function to achieve the appropriate time for a change, mapFunc is implemented as follows: +Dates and times call the `Tr.Time` function to perform their translations. The mapfunc is implemented as follows: func I18nTimeDate(args ...interface{}) string { ok := false @@ -141,17 +141,17 @@ Date and time to call `Tr.Time` function to achieve the appropriate time for a c return Tr.Time(s) } -Registration function is as follows: +Register the function like so: t.Funcs(template.FuncMap{"TD": I18nTimeDate}) -Using the following template: +Then use it from your template: {{.V.Now | TD}} 3 Currency Information -Currency called `Tr.Money` function to achieve the appropriate time for a change, mapFunc is implemented as follows: +Currencies use the `Tr.Money` function to convert money. The mapFunc is implemented as follows: func I18nMoney(args ...interface{}) string { ok := false @@ -165,17 +165,17 @@ Currency called `Tr.Money` function to achieve the appropriate time for a change return Tr.Money(s) } -Registration function is as follows: +Register the function like so: t.Funcs(template.FuncMap{"M": I18nMoney}) -Using the following template: +Then use it from your template: {{.V.Money | M}} ## Summary -Through this section we know how to implement a multi-language package for Web applications, through a custom language packs that we can facilitate the realization of multi-language, but also through the configuration file can be very convenient to expand multi-language, by default, go-i18n will be self- fixed load some common configuration information, such as time, money, etc., we can be very convenient to use, and in order to support the use of these functions in the template, but also to achieve the appropriate template functions, thus allowing us to develop Web applications in the time directly in the template the way through the pipeline operate multiple language packs. +In this section we learned how to implement multiple language packs in our web applications. We saw that through custom language packs, we can not only easily internationalize our applications, but facilitate the addition of other languages also (through the use of a configuration file). By default, the go-i18n package will provide some common configurations for time, currency, etc., which can be very convenient to use. We learned that these functions can also be used directly from our templates using mapping functions; each translated string can be piped directly to our templates. This enables our web applications to accommodate multiple languages with minimal effort. ## Links