Walter Kempees
|
Posted: 01/19/2006, 1:52 PM |
|
Using Internationalization, (great feature), I stumbled on getting my custom
error messages translated.
Situation:
On any field (that needs it) or on the page Properties->On Validate enter
any condition you need to do your validation.
In your validation you will have to set an error message, to have that
internationalized:
(As an example a Date_From/To combination:)
Normal version
// -------------------------
// Write your own code here.
// -------------------------
if ($formname->date_from->GetValue() > $formname->date_to->GetValue() ){
$formname->{Errors}->addError("Period incorrect!");
}
//End Custom Code
Internationalized version
// -------------------------
// Write your own code here.
// -------------------------
global $CCSLocales;
if ($formname->date_from->GetValue() > $formname->date_to->GetValue() ){
$formname->{Errors}->addError(CCSLocales->GetText('Period_incorrect');
}
//End Custom Code
Added the global CCSLocales; and changed the error message text, as it
cannot contain special characters.
When finished, in Project Explorer expand "Resources" and "Locales" you will
find the languages u use there.
Double-click your language and the translator will appear.
For Locale (top row) I choose to set this to ALL giving a neat display of
all translated Keys.
Press "Add" enter the Key you just used and the text per language you want.
Close Translator.
Publish and
Presto!
Thanks Yes
|