1 / 14

Yii Framework i18n – Internationalisation

Yii Framework i18n – Internationalisation. Cass Surek cass@surek.co.uk. Motivation. Expand product reach Cater for multiple markets Improve usability. i 18n - Internationalisation. Software design process Multiple targets Multiple languages Multiple regions Avoid structural changes

Download Presentation

Yii Framework i18n – Internationalisation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Yii Frameworki18n – Internationalisation Cass Surek cass@surek.co.uk

  2. Motivation • Expand product reach • Cater for multiple markets • Improve usability

  3. i18n - Internationalisation • Software design process • Multiple targets • Multiple languages • Multiple regions • Avoid structural changes • i + 18 letters + n – coined by DEC in the ’70s

  4. L10n - Localisation • Software adaptation process • Based on internationalised software • Use of locales • Term translation

  5. Yii support for i18n + L10n • Locale and language • Translation • Date and Time Formatting • Number Formatting

  6. Locale • CLocale class– e.g. Yii::app()->locale->dateFormat • Locale codes: en_us, pt_br, en_gb, es (standardised lowercase) • Provides locale specific parameters • Date format • Currency symbols • Month names • Etc

  7. Language • Active locale setup on config file or at runtime • Alters error messages to target language Target Language 1 (pt_br) Source Language (en_us) Target Language 2 (es) Target Language 3 (fr_fr)

  8. Activation - setup • Config file • /protected/config/main.php • Array(‘sourceLanguage’=>’en_gb’, ‘language’=>’pt_br’) • Runtime • Yii::app()->language= ‘pt_br’;

  9. Translation • Messages • Views

  10. Translation - Messages Storage formats • CPhpMessageSource (protected/messages) • CGettextMessageSource (GNU Gettextfiles) • CDbMessageSource (term tables) • Yii::t(’category', 'Path alias "{alias}" is redefined.’, array('{alias}'=>$alias))

  11. Translation - Views • CApplication::findLocalizedFile() – returns language view file name if exists • protected/views/ControllerID/zh_cn/edit.php • Also used for images and data files

  12. Date and Time Formatting • CDateFormatterclass • Yii::app()->dateFormatter • Uses current locale format • Example • Yii::app()->dateFormatter->formatDateTime(time())

  13. Number Formatting • CNumberFormatterclass • Yii::app()->numberFormatter • Uses current locale format • Example • Yii::app()->numberFormatter->formatDecimal("8495873.00")

  14. DEMO

More Related