From cb4130a5758f82acdc1cf59a54120d7bc4c85897 Mon Sep 17 00:00:00 2001 From: Anchor Date: Fri, 14 Nov 2014 20:53:21 -0800 Subject: [PATCH] fix grammar --- en/eBook/10.3.md | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/en/eBook/10.3.md b/en/eBook/10.3.md index b57a820c..1d3db5ae 100644 --- a/en/eBook/10.3.md +++ b/en/eBook/10.3.md @@ -1,10 +1,10 @@ # 10.3 International sites -Previous section describes how to handle localized resources, namely Locale an appropriate configuration files, so if dealing with multiple localized resources? For example, some of our frequently used: simple text translation, time and date, number, etc. If handle it? This section eleven solve these problems. +The previous section explained how to deal with localized resources, namely by using locale configuration files. So what can we do if we need to deal with *multiple* localized resources like text translations, times and dates, numbers, etc? This section will address these issues one by one. -## Manage multiple local package +## Managing multiple locale packages -In the development of an application, the first thing we have to decide whether to support only one language, or languages, if you want to support multiple languages, we will need to develop an organizational structure to facilitate future to add more languages ​​. Here we designed as follows: Locale -related files are placed in the `config/locales`, suppose you want to support Chinese and English, then you need to be placed in this folder en.json and zh.json. Probably the contents are as follows: +In the development of an application, often the first thing you need to do is to decide whether or not you want to support more than one language. If you do decide to support multiple languages, you'll need to develop an organizational structure to facilitate the process of adding more languages in the future. One way we can do this is to put all our related locale files together in a `config/locales` directory, or something of the like. Let's suppose you want to support both Chinese and English. In this case, you'd be placing both the en.json and zh.json locale files into the aforementioned folder. Their contents would probably look something like the following: # zh.json @@ -24,18 +24,12 @@ In the development of an application, the first thing we have to decide whether } } -In order to support internationalization, in which we used an international related packages - [go-i18n](https://github.com/astaxie/go-i18n) ( ***More advanced i18n package can be found [here](https://github.com/beego/i18n)*** ), we first go-i18n package to register `config/locales` this directory, to load all of the locale files +We decided to use some 3rd party Go packages to help us internationalize our web applications. In the case of [go-i18n](https://github.com/astaxie/go-i18n) ( ***A more advanced i18n package can be found [here](https://github.com/beego/i18n)*** ), we first have to register our `config/locales` directory to load all of our locale files: Tr := i18n.NewLocale() Tr.LoadPath("config/locales") -This package is simple to use, you can be tested by the following method: - -fmt.Println (Tr.Translate ("submit")) -//Output Submit -Tr.SetLocale ("zn") -fmt.Println (Tr.Translate ("submit")) -//Outputs " Submit" +This package is simple to use. We can test that it works like so: fmt.Println(Tr.Translate("submit")) //Output "submit" @@ -45,7 +39,7 @@ fmt.Println (Tr.Translate ("submit")) ## Automatically load local package -Above we described how to automatically load custom language packs, in fact, go-i18n library has been a lot of pre-loaded default formatting information, such as time format, currency format, the user can customize the configuration override these default configurations, see the following process: +We've just described how to automatically load custom language packs. In fact, the `go-i18n` library comes pre-loaded with a bunch of default formatting information such as time and currency formats. These default configurations can be overridden and customized by users to suit their needs: //Load the default configuration files, which are placed below `go-i18n/locales` @@ -91,7 +85,7 @@ Above we described how to automatically load custom language packs, in fact, go- return nil } -Through the above method to load configuration information to the default file, so that we can customize the time we do not have information when executed the following code to obtain the corresponding information: +Using the above method to load configuration information to the default file, so that we can customize the time we do not have information when executed the following code to obtain the corresponding information: //locale = zh, execute the following code: