当前位置: 首页 > 文档资料 > PHP 编程之道 >

国际化 (i18n) 与本地化 (l10n)

优质
小牛编辑
182浏览
2023-12-01

Disclaimer for newcomers: i18n and l10n are numeronyms, a kind of abbreviation where numbers are used to shorten words - in our case, internationalization becomes i18n and localization, l10n.

首先,我们需要为这两个相似的概念以及相关的概念下定义:

Internationalization is when you organize your code so it can be adapted to different languages or regions without refactorings. This is usually done once - preferably, in the beginning of the project, or else you’ll probably need some huge changes in the source!

Localization happens when you adapt the interface (mainly) by translating contents, based on the i18n work done before. It usually is done every time a new language or region needs support and is updated when new interface pieces are added, as they need to be available in all supported languages.

Pluralization defines the rules needed between different languages to interoperate strings containing numbers and counters. For instance, in English when you have only one item, it’s singular, and anything different from that is called plural; plural in this language is indicated by adding an S after some words, and sometimes changes parts of it. In other languages, such as Russian or Serbian, there are two plural forms in addition to the singular - you may even find languages with a total of four, five or six forms, such as Slovenian, Irish or Arabic.