The Internationalized implementation method of YII Framework Framework tutorial, yiiframework_php Tutorial

Source: Internet
Author: User
Tags configuration php getting started with php i18n smarty template

The international implementation of YII Framework tutorial, Yiiframework


This paper describes the internationalization implementation of YII framework tutorial. Share to everyone for your reference, as follows:

A Web application, published to the Internet, is for global users. Users in all corners of the world can access to your Web application, of course, it depends on your website and disharmony, discordant Web applications in a harmonious society is not let you visit.

YII provides international support that allows us to create apps that are suitable for people in different languages.

Internationalization is a very fancy thing, no big website really can do internationalization. Most of them are for languages that do not understand, and different sites are designed for different locations. If your application is relatively small, there are not many things to deal with, so the internationalization of things is quite possible.

Internationalization starts with the following aspects:

Regional Settings

Translation of information texts and file resources

Date/time, currency symbol, and number format

The classes that are involved in the internationalization of Yii are below the/yii_dev/yii/framework/i18n directory:

/yii_dev/yii/framework/i18n# Tree
.
├──cchoiceformat.php
├──cdateformatter.php
├──cdbmessagesource.php
├──cgettextmessagesource.php
├──clocale.php
├──cmessagesource.php
├──cnumberformatter.php
├──cphpmessagesource.php
├──data
│├──en_us.php
│├── ....... ........
│├──zh_hk.php
│├──zh_mo.php
│├──zh.php
│├──zh_sg.php
│├──zh_tw.php
│├──zu.php
│└──zu_za.php
└──gettext
├──cgettextfile.php
├──cgettextmofile.php
└──cgettextpofile.php

2 directories, 616 files

Regional Settings

The locale is used to determine the international and spoken language of the user.

Yii defines a common area identifier, which can be considered to represent a unique ID for a region.

Yii stores area data (including currency, date, number format, etc.) through the Clocale class.

The corresponding Clocale instance can be obtained through clocale::getinstance ($localeID) or Capplication::getlocale ($localeID) through a unique region ID. With Clocale instances, you can determine the language in which the user is located. It can then be translated according to Clocale data, making the Web app more suitable for current users and readers. The most fundamental is for the user to make a specific translation.

Translation of information texts and file resources

It is easy to translate a language into another language. The use of 26 letters in the computer is e-text. So you can think of e as the original language, the source of all the language, all other languages are translated through the E-text, the E-text is called the source language. The translated language is called the target language.

Description of the specific class

/*** translates a message to the specified language.* starting from version 1.0.2, this method supports choice format (see {@link Cchoiceformat}), * i.e., the message returned be is chosen from a few candidates according to the given* number V Alue.  This feature was mainly used to solve plural format issue in case* a message have different plural forms in some languages.* @param string $category message category. Please use only word letters. Note, category ' Yii ' is* reserved for YII framework core code use. See {@link Cphpmessagesource} for* more interpretation about message category.* @param string $message the original Messag e* @param array $params parameters to being applied to the message usingstrtr. * Starting from version 1.0.2, the first parameter can is a number without key.* and in this case, the method would call { @link Cchoiceformat::format} to choose* a appropriate message translation.* starting from version 1.1.6 can pass Para Meter for {@link cchoiceformat::format}* or plural forms format without wrapping it with array.* @param string $source whi  CH Message source application component to use.* Defaults to null, meaning using ' coremessages ' for messages belonging to* The ' yii ' category and using ' messages ' for the rest messages.* @param string $language the target language. If null (default), the {@link capplication::getlanguage application language} 'll be is used.* this parameter have been avail Able since version 1.0.3.* @return string The translated message* @see cmessagesource*/public static function T ($category, $message, $params =array (), $source =null, $language =null) {

$category Source Language
$mesage Target language
$params is an array of $mesage in which to match the translation.

Specific use methods such as:

Yii::t (' app ', ' Path alias ' {alias} ' is redefined. ',  Array (' {alias} ' = $alias))

Of course, you can use the command line command message provided by YIIC to translate, the specific reference YIIC command usage instructions

Date/time, money, and number formats

Date/Time Processing Cdateformatter class
Specific reference (/yii_dev/yii/framework/i18n/cdateformatter.php) class file

Digital processing
Specific reference (/yii_dev/yii/framework/i18n/cnumberformatter.php) class file

For more information on YII related content readers can view this site topic: "YII framework Introduction and common skills Summary", "PHP Excellent Development Framework Summary", "Smarty Template Primer Basic Tutorial", "PHP date and Time usage summary", "PHP object-oriented Programming introduction Tutorial", " PHP String Usage Summary, "Getting Started with Php+mysql database operations" and "PHP Common Database Operations Skills Summary"

It is hoped that this article is helpful to the PHP program design based on YII framework.

Articles you may be interested in:

    • PHP YII Framework Development Little tricks Model (models) Rules custom validation rule
    • Nginx configuration PHP Rewrite rules example of Yii and cakephp framework
    • How to install the Yii framework using composer
    • Yii method for executing SQL statements using the Migrate command
    • Yii Framework framework uses YIIC to quickly create migrate usage examples of YII applications
    • Yii Framework Framework tutorial using YIIC quickly create a detailed application of Yii
    • A detailed description of the caching usage of YII Framework Framework Tutorial
    • A detailed description of the security scheme for YII Framework Framework Tutorial
    • A detailed description of the log usage of YII Framework Framework Tutorial
    • An explanation of the exception handling of YII Framework Tutorial
    • Example of common rules for YII rules

http://www.bkjia.com/PHPjc/1110084.html www.bkjia.com true http://www.bkjia.com/PHPjc/1110084.html techarticle The internationalization realization method of Yii framework frame tutorial, Yiiframework This paper narrates the internationalization realization method of YII framework Framework tutorial. Share to everyone for your reference, as follows: ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.