An overview of the so-called internationalization [generally written as I18N] refers to the process of refactoring a program designed only for a region so that it can be used in more regions. The so-called localization [generally written as L10N] refers to the process of adding support for applications in a new region to an international program. For developers who develop local applications
An overview of the so-called internationalization [generally written as I18N] refers to the process of refactoring a program designed only for a region so that it can be used in more regions. The so-called localization [generally written as L10N] refers to the process of adding support for applications in a new region to an international program. For developers who develop local applications
Overview
The so-calledInternationalization[Generally written as I18N] refers to the process of refactoring a program designed only for a region so that it can be used in more regions. The so-calledLocalization[Generally written as L10N] refersInternationalizationThe process of adding support for applications in a new region.
As a developer who develops local applications, the content of this chapter seems to be far away from us, but it is not. For wordpress, many of us use foreign hosts. At this time, the time zone settings of the host are inconsistent with those of users. The most likely problem is that when you are sending a blog, the displayed time is the time set by the server, not your local time. In this caseLocalizationSet. Adjust the time display by setting the time zone.
Setting the time zone is not that easy
Most systems now have regional systems, although regional systems help solve many problems.LocalizationBut because the degree of standardization is not enough, the inconvenience caused by the use is often frustrating. Different systems support different regions, and even have different names for the same region.
Specified Region
In PHP, you can use the setlocale function to set the region information. This function is only valid during running (that is, it does not affect other WEB programs on the server)
// Set the time zone in Linux to setlocale (LC_ALL, 'es _ MX '); setlocale (LC_ALL, 'de _ at'); // set the time zone in Windows to setlocale (LC_ALL, 'Spanish _ Mico '); setlocale (LC_ALL, 'German _ Austria ');
LocalizationText message
In order to implement multiple languages, many programs save all prompts and text information to a lang array, and then use local settings to call lang languages in different regions to implement multi-language versions. As shown below:
$messages = array ('en_US' => array( 'My favorite foods are' => 'My favorite foods are', 'french fries' => 'french fries', 'candy' => 'candy', 'potato chips' => 'potato chips', 'eggplant' => 'eggplant' ), 'en_UK' => array( 'My favorite foods are' => 'My favourite foods are', 'french fries' => 'chips', 'candy' => 'sweets', 'potato chips' => 'crisps', 'eggplant' => 'aubergine' ) );function msg($s) { global $LANG, $messages; if (isset($messages[$LANG][$s])) { return $messages[$LANG][$s]; } else { error_log("l10n error: LANG: $lang, message: '$s'"); }}$LANG = 'en_UK';print msg('My favorite foods are').":\n";print msg('french fries')."\n";print msg('potato chips')."\n";print msg('candy')."\n";
LocalizationTime
In this part, the time format display of many programs is set in the template, the book introduces the strftime to format the time
LocalizationCurrency value
The implementation through money_format () is of little significance because it does not involve the exchange rate of the currency. In actual development, you may need to override the _ tostring () method.
You can use localeconv () to return currency-related information.
LocalizationImages and files
Distinguish text-containing images or folders named by language or time zone. For example
Images/$ Lang/logo.jpg
Set character encoding
The header can be used to encode the output data.
header('Content-Type: text/html;charset=utf-8');