Internationalization, L10n and I18N

Asked

Viewed 1,900 times

7

According to the W3, with regard to L10n and I18N, I have separated the explanation below that will serve as a basis to illustrate my doubts.

L10n [ source ]

Generally regarded only as a synonym for translation of a graphical interface or documentation, localization is substantially much more complex. It may imply customization related to:

  1. Date, time and number formats
  2. Use of currency
  3. Verification and classification
  4. Symbols, icons and colors
  5. Texts and graphics that, in a given culture, may be subject to misinterpretation
  6. Variation of legal requirements

I18n [ source ]

Internationalization is the creation and development of a product, application or content of a document that allows easy localization for target audiences that vary in culture, region or language.

  1. Inclusion of support for local, regional, cultural or language preferences. Typically, this involves the predefined insertion of location data and resources derived from available libraries or user preferences. Examples include: date and time formats, local calendars, number formats and numerical systems, list classification and presentation, manipulation of personal names, address forms, etc..

Many examples and explanations limit to internationalization only for translation of language packs and hourly and monetary formatting. Even if the correct and broad use of i18n is made, it will always be related to the visual composition related to the view, displaying the content formatted for the language chosen by the user?

About the localization, it seems to me that in addition to maintaining a relationship with the view, it can influence controllers and models, as in examples n. 3, 5 and 6. L10n can have influence and customize the content that will be displayed - is that correct? In this case, it would also be based on the language chosen by the user or on the regionalization of the content in question?

I’ve been looking for some Pattern [PHP] for some time but only find separate examples, and L10n is almost non-existent. My I18n provides the system translation and formatting in the view without problems, but now I need to have management on the dynamic content according to the geolocation, and I believe it is the responsibility of L10n. I don’t want a multipurpose class or breaking the pattern.

  • 2

    This one I want to see. My little translation pack simply reads a file. MO generated from a . PO, generates an array and bora. Now to do the right thing, the right way is they.

  • @Brunoaugusto, so I gave the basis of the explanation, but there are still other options like the globalization. My i18n works with vsprintf where I can format according to the package. I think it covers some points of the i18n, but I do not bridge with the l10n, which may limit the use of both.

  • l10n is out of use because it is less wide than i18n. In l10n you cared with few aspects , only even in translating text and displaying currency, date in the format of the country. The i18n is wider and is being used more, you take into account the character set (example Japanese, Chinese), the writing form ( right - left, left - right, up - down ) and adjust Resources (video, audio ) to the user’s location. The texts placed are much more theoretical than practical.

1 answer

3

Internationalization (i18n): is the process of developing an application that can be adapted to various language types without interfering with the core of the application.

Location (l10n): It is the process of adapting an internationalized application to a specific region or language using a specific location (locale) and translations of texts. Source Wikipedia (en).

In theory the term localization (l10n) is used synonymously with internationalization (i18n), and globalization is the summary of both terms.

To simplify, What you want is to adapt your application to support other languages, date formats, string, time zone and etc according to location (locale) user, then you will use the term internationalization.

Setup:

To internationalize your application with PHP, basically two aspects are important:

01: you can set the function setlocale() according to user-defined locale or automatically identified by your application:

Ex:

setlocale (LC_ALL, 'pt_BR', 'pt_BR.utf8');

This way you will change the format that the user views monetary value, date, strings and etc.

02: To translate the strings for this you will use the functions of gettext available for dozens of languages and also for PHP.

NOTE: It is not effective to translate your website using arrays of strings This causes disruption to front-end and back-end development, as well as performance reasons.

To use the gettext what you need to know if your server supports this feature:

if (!function_exists("gettext")){
   echo "gettext não esta instalado\n";
}
else{
   echo "gettext é suportado\n";
}

See on PHP manual how to proceed with the installation and configuration of the gettext.

After configuring your server your application is ready to be translated. Now just proceed with the development in its layers (MVC) of the application normally, but with one exception so that gettext can identify and make the translation you will now use the function _() in your strings, this in any layer that these strings will appear, model, view or controller, an ex:

echo _("text to be translated");

// ou

echo gettext("text to be translated");

Translation of the strings

I recommend the program Poedit to extract the strings of your application and generate your files .po (Portable Object) a text file containing your translations, an example below:

#: test.php:3
english/messages.po:
msgid "Hello World!"
msgstr "Hola Mundo"

This file can be translated by anyone with the help of Poedit or another editor. When saving this file another file will be compiled .mo (Machine Object) a binary file that the gettext use for reading and translation of strings.

With their .mo translated, save to a folder according to each locale:

Portable Object files

.
├── i18n
│   ├── en_US
│   │   └── LC_MESSAGES
│   │       └── messages.mo
│   ├── en_UK
│   │   └── LC_MESSAGES
│   │       └── messages.mo
│   └── es_ES
│       └── LC_MESSAGES
│           └── messages.mo
└── index.php        

Automatically your texts will be translated according to the user’s locale.

Considerations

Although at first sight the gettext seems to be and a little complex, once configured in your system your application can be translated and updated quickly and effectively, and still allows other people who are not respectively programmers to work on the translations of the files in a synchronous manner and using only an editor .po.

There are some "cons" to this way to internationalize application, one of them is due to binary files .mo are stored in the server memory each change in the files .po you will have to recompile and generate new files .mo and with it restart your server.

Alternatives if your server does not support gettext

Alternatively you can use a similar PHP library to simulate the function _() in the same way that Wordpress uses as fallback if there is no function gettext. However the use of this alternative results considerably the performance of the server.

  • The configuration part was not required, and you only addressed translation packages and my question is precisely about l10n. Localization goes beyond "adapting an internationalized application", that is the internationalization itself.

  • @Papacharlie I agree with Adriano’s (and Wikipedia’s) definition of the terms. However, the definitions of these terms are not absolute, there are people and companies that use them according to their own definitions.

  • Because it is @bfavaretto, not absolute. But I do not agree with the description of l10n which was given. Up to the description by W3 may create confusion, but in my view, the l10n relates to regional content and not only the fact of "adapting an internationalized application". But I am open to debate :)

  • @Papacharlie the subject is very good! really cause doubts, in my perception if the goal is to make a product/application available to other languages and cultures i18n is the term p/ design/ development. Make this product/content available in the correct format to your target, eg en_UK, en_US, en_AU so L10n makes sense, let’s say an i18n X application is located to pt_BR, pt_PT and en_US, technically speaking in PHP is more or less like I mentioned earlier, from my point of view, but I think it goes further, and speaking of world scale the term G11n is more.

  • Take the case of Google Doodles that formats the logo. Or when you access a national news site and see the highlight of your city. It’s the L18n in action. My point is this and not the focus on I18n. As I said in the question, I already have the I18n in operation.

  • Dude, can someone give me a light on how to create a new PO, so I can open in PO Edit?

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.