Merging other languages
This commit is contained in:
49
en/10.0.md
49
en/10.0.md
@@ -1,25 +1,24 @@
|
||||
# 10 国际化和本地化
|
||||
为了适应经济的全球一体化,作为开发者,我们需要开发出支持多国语言、国际化的Web应用,即同样的页面在不同的语言环境下需要显示不同的效果,也就是说应用程序在运行时能够根据请求所来自的地域与语言的不同而显示不同的用户界面。这样,当需要在应用程序中添加对新的语言的支持时,无需修改应用程序的代码,只需要增加语言包即可实现。
|
||||
|
||||
国际化与本地化(Internationalization and localization,通常用i18n和L10N表示),国际化是将针对某个地区设计的程序进行重构,以使它能够在更多地区使用,本地化是指在一个面向国际化的程序中增加对新地区的支持。
|
||||
|
||||
目前,Go语言的标准包没有提供对i18n的支持,但有一些比较简单的第三方实现,这一章我们将实现一个go-i18n库,用来支持Go语言的i18n。
|
||||
|
||||
所谓的国际化:就是根据特定的locale信息,提取与之相应的字符串或其它一些东西(比如时间和货币的格式)等等。这涉及到三个问题:
|
||||
|
||||
1、如何确定locale。
|
||||
|
||||
2、如何保存与locale相关的字符串或其它信息。
|
||||
|
||||
3、如何根据locale提取字符串和其它相应的信息。
|
||||
|
||||
在第一小节里,我们将介绍如何设置正确的locale以便让访问站点的用户能够获得与其语言相应的页面。第二小节将介绍如何处理或存储字符串、货币、时间日期等与locale相关的信息,第三小节将介绍如何实现国际化站点,即如何根据不同locale返回不同合适的内容。通过这三个小节的学习,我们将获得一个完整的i18n方案。
|
||||
|
||||
## 目录
|
||||
|
||||

|
||||
|
||||
## links
|
||||
* [目录](<preface.md>)
|
||||
* 上一章: [第九章总结](<09.7.md>)
|
||||
* 下一节: [设置默认地区](<10.1.md>)
|
||||
# 10 Internationalization and localization
|
||||
|
||||
In order to adapt to the increasing globalization of the internet, as developers, we may sometimes need to build multilingual, international web applications.
|
||||
This means that same pages will appear in different languages according to user regions, and perhaps the UI and UX will also be adapted to show different effects based on local holidays or culture. For example at runtime, the application will be able to recognize and process requests coming from different geographical regions and render pages in the local dialect or display different user interface. As competent developers, we don't want to have to manually modify our application's source code to cater to every possible region out there. When an application needs to add support for a new language, we should be bale to simply drop in the appropriate language pack and be done with it.
|
||||
|
||||
In this section, we'll be talking about internationalization and localization (usually expressed as i18n and L10N, respectively). Internationalization is the process of designing applications that are flexible enough to be served to multiple regions around the world. In some ways, we can think of internationalization as something that helps to facilitate localization, which is the adaptation of a web application's content and design to suit the language or cultural needs of specific locales.
|
||||
|
||||
Currently, Go's standard package does not provide i18n support, but there are some useful and relatively simple third-party implementations available. In this chapter, we'll be using the open-source "go-i18n" library to support internationalization in our examples.
|
||||
|
||||
When we talk about making our web applications "international", we mean that each web page should be constructed with locale specific information and assembled with the corresponding local strings, time and currency formats, etc. This involves three things:
|
||||
|
||||
1. how to determine the user's locale.
|
||||
|
||||
2. how to save strings or other information associated with the locale.
|
||||
|
||||
3. how to embed strings and other information according to the user's locale.
|
||||
|
||||
In the first section, we'll describe how to detect and set the correct locale in order to allow website users access to their language specific pages. The second section describes how to handle or store strings, currencies, times, dates and other locale related information. Finally, the third section will describe how to internationalize your web application; more specifically, we'll discuss how to return different pages with locale appropriate content. Through these three sections, we'll be able to support full i18n in our web applications.
|
||||
|
||||
## Links
|
||||
|
||||
- [Directory](preface.md)
|
||||
- Previous Chapter: [Chapter 9 Summary](09.7.md)
|
||||
- Next section: [Time zone](10.1.md)
|
||||
|
||||
Reference in New Issue
Block a user