提交 c8a51bf9 编写于 作者: A Anchor

Fix grammar and sentence structure

上级 cb4130a5
......@@ -39,11 +39,11 @@ This package is simple to use. We can test that it works like so:
## Automatically load local package
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:
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. Consider the following process:
//Load the default configuration files, which are placed below `go-i18n/locales`
//Load the default configuration files, which are placed below in `go-i18n/locales`
//File naming zh.json, en-json, en-US.json etc., can be continuously extended to support more languages
//File should be named zh.json, en-json, en-US.json etc., so we can be continuously support more languages
func (il *IL) loadDefaultTranslations(dirPath string) error {
dir, err := os.Open(dirPath)
......@@ -85,9 +85,7 @@ We've just described how to automatically load custom language packs. In fact, t
return nil
}
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:
Using the above code to load all of our default translations, we can then use the following code to select and use a locale:
fmt.Println(Tr.Time(time.Now()))
//Output: 2009年1月08日 星期四 20:37:58 CST
......@@ -100,7 +98,7 @@ Using the above method to load configuration information to the default file, so
## Template mapfunc
Above we achieve a number of language packs and load management, and some function implementation is based on the logical layer, for example: "Tr.Translate", "Tr.Time", "Tr.Money" and so on, while we at the logical level You can use these functions to the parameters required for conversion when rendering the template layer output directly, but if we want to use them directly in the template layer functions that how to achieve it? I do not know if you remember, at the time said earlier template: Go language template support custom template function, the following is our implementation to facilitate the operation of mapfunc:
Above, we've presented one way of managing and integrating a number of language packs. Some of the functions we've implemented are based on the logical layer, for example: "Tr.Translate", "Tr.Time", "Tr.Money" and so on. In the logical layer, we can use these functions (after supplying the required parameters) for applying your translations, outputting the results directly to the template layer at render time. What can we do if we want to use these functions *directly* in the template layer? In case you've forgotten, earlier in the book we mentioned that Go templates support custom template functions. The following code shows how easy mapfunc is to implement:
1 text information
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册