Framework Structure - Internationalization (i18n)
InternationalizationInternationalization (i18n) refers to the process of designing a software application in a way that allows adaptation of to the various languages and regions without engineering changes. This proccess especially important for web applications, because the potential users or site visitors may be worldwide.
1. Locale and LanguageLocale is a set of parameters that defines the user's language, country and any special variant preferences that the user wants to see in their user interface. It is usually identified by an ID consisting of a language ID and a region ID. For example, the ID en_US stands for the locale of English and United States. This feature released in a basic frame for some languages in
framework/i18n/directory. Users always may customize this feature to suit their needs.
2. TranslationThis is the most needed feature of I18N and it including message translations. The former translates a text message to the desired language. A translation request consists of the object to be translated, the source language that the object is in, and the target language that the object needs to be translated to. In ApPHP Framework, the source language defaults to the application source language while the target language defaults to the application language.
ApPHP Framework provides support for i18n in several aspects:
- Provides the locale data for each possible language and variant
- Provides message translation service
- Provides locale-dependent date and time formatting
i18n. These files are the part of framework and they contain the array of localizable messages and constants. You may modify them by translating the specific messages.
Currently they are:
framework/ framework directory
i18n/ directory where placed all internationalization files
- de.php i18n translation in German
- en.php i18n translation in English
- es.php i18n translation in Spanish ...
- i18n/ directory where placed all internationalization files
return array ( 'monthNames' => array ( 'wide' => array ( 1=>'January', 2=>'February', 3=>'March', 4=>'April', 5=>'May', 6=>'June', 7=>'July', 8=>'August', 9=>'September', 10=>'October', 11=>'November', 12=>'December', ), 'abbreviated' => array( 1=>'Jan', 2=>'Feb', 3=>'Mar', 4=>'Apr', 5=>'May', 6=>'Jun', 7=>'Jul', 8=>'Aug', 9=>'Sep', 10=>'Oct', 11=>'Nov', 12=>'Dec' ), ), 'weekDayNames' => array ( 'wide' => array( 1=>'Sunday', 2=>'Monday', 3=>'Tuesday', 4=>'Wednesday', 5=>'Thursday', 6=>'Friday', 7=>'Saturday' ), ), ... );Usage example:
echo A::t('i18n', 'monthNames.wide.1'); // will print "January" echo A::t('i18n', 'monthNames.abbreviated.1'); // will print "Jan" echo A::t('i18n', 'weekDayNames.wide.5'); // will print "Thursday"
Click to find more information about i18n (internationalization) and l10n (localization) messages for applications.