From f6499741dd119d7021e20bcfa6c1870dbf96accb Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 4 Apr 2006 12:07:25 +0000 Subject: A typo. --- .../quickstart/protected/pages/Advanced/I18N.page | 54 +++++++++++----------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'demos') diff --git a/demos/quickstart/protected/pages/Advanced/I18N.page b/demos/quickstart/protected/pages/Advanced/I18N.page index db97c25c..75ee59ee 100644 --- a/demos/quickstart/protected/pages/Advanced/I18N.page +++ b/demos/quickstart/protected/pages/Advanced/I18N.page @@ -29,20 +29,20 @@

To enable the localization features in Prado, you need to add a few configuration options in your application configuration. First you need to include the System.I18N.* namespace to your paths.

- + - +

Then, if you wish to translate some text in your application, you need to add one translation message data source.

- + - - +

Where source in translation is the dot path to a directory where you are going to store your translate message catalogue. The autosave @@ -111,7 +111,7 @@ function clickMe($sender,$param)

The hard coded message "Hello, world!" is to be localized using the localize function.

- + function clickMe($sender,$param) { $sender->Text=localize("Hello, world!"); @@ -121,16 +121,16 @@ function clickMe($sender,$param)

Compound Messages

Compound messages can contain variable data. For example, in the message "There are 12 users online.", the integer 12 may change depending on some data in your application. This is difficult to translate because the position of the variable data may be difference for different languages. In addition, different languages have their own rules for plurals (if any) and/or quantifiers. The following example can not be easily translated, because the sentence structure is fixed by hard coding the variable data within message.

- + $num_users = 12; $message = "There are " . $num_users . " users online."; - + This problem can be solved using the localize function with string substitution. For example, the $message string above can be constructed as follows. - + $num_users = 12; $message = localize("There are {num_users} users online.", array('num_users'=>$num_users)); - +

Where the second parameter in localize takes an associative array with the key as the substitution to find in the text and replaced it with the associated value. The localize function does not solve the problem of localizing languages that have plural forms, the solution is to use TChoiceFormat.

@@ -143,47 +143,47 @@ The localize function does not solve the problem of localizing language

Messages and strings can be localized in PHP or in templates. To translate a message or string in the template, use TTranslate.

- + <com:TTranslate>Hello World</com:TTranslate> <com:TTranslate Text="Goodbye" />

TTranslate can also perform string substitution. Any attributes of TTranslate will be substituted with {attribute name} in the translation. E.g.

- + <com:TTranslate time="late"> The time is {time}. </com:TTranslate>

A short for TTranslate is also provided using the following syntax.

- -<%[string]> + +<%[string]%>

where string will be translated to different languages according to the end-user's language preference. This syntax can be used with attribute values as well.

- + <com:TLabel Text="<%[ Hello World! ]%>" />

TDateFormat

Formatting localized date and time is straight forward.

- + <com:TDateFormat Value="12/01/2005" /> - +

There are of 4 localized date patterns and 4 localized time patterns. They can be used in any combination. If using a combined pattern, the first must be the date, followed by a space, and lastly the time pattern. For example, full date pattern with short time pattern.

- + <com:TDateFormat Pattern="fulldate shorttime" /> - +

If the Value property is not specified, the current date and time is used.

TNumberFormat

PRADO's Internationalization framework provide localized currency formatting and number formatting. Please note that the TNumberFormat component provides formatting only, it does not perform current conversion or exchange.

- + <com:TNumberFormat Type="currency" Value="100" /> - +

Culture and Currency properties may be specified to format locale specific numbers.

@@ -193,13 +193,13 @@ The time is {time}. In the following example, the strings "{greeting}" and "{name}" will be replace with the values of "Hello" and "World", respectively.The substitution string must be enclose with "{" and "}". The parameters can be further translated by using TTranslate. - + <com:TTranslate> {greeting} {name}! <com:TTranslateParameter Key="name">World</com:TTranslateParameter> <com:TTranslateParameter Key="greeting">Hello</com:TTranslateParameter> </com:TTranslate> - + @@ -209,9 +209,9 @@ with the values of "Hello" and "World", respectively.The substitution string mus

The TChoiceFormat component performs message/string choice translation. The following example demonstrated a simple 2 choice message translation.

- + <com:TChoiceFormat Value="1"/>[1] One Apple. |[2] Two Apples</com:TChoiceFormat> - +

In the above example, the Value "1" (one), thus the translated string is "One Apple". If the Value was "2", then it will show "Two Apples".

@@ -221,7 +221,7 @@ is "One Apple". If the Value was "2", then it will show "Two Apples".[1,2] -- accepts values between 1 and 2, inclusive.
  • (1,2) -- accepts values between 1 and 2, excluding 1 and 2.
  • {1,2,3,4} -- only values defined in the set are accepted.
  • -
  • [-Inf,0) -- accepts value greater or equal to negative infinity +
  • [-Inf,0) -- accepts value greater or equal to negative infinity and strictly less than 0
  • -- cgit v1.2.3