Understanding Application Localization in Visual C#.NET

Decode DataMatrix in Visual C#.NET Understanding Application Localization

Understanding Application Localization
Data Matrix 2d Barcode Reader In C#.NET
Using Barcode reader for .NET framework Control to read, scan Data Matrix ECC200 image in Visual Studio .NET applications.
www.OnBarcode.com
Reading Data Matrix ECC200 In C#.NET
Using Barcode recognizer for .NET Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
Next up, the application s contact form This form definition is created using Zend_Form, which can automatically detect and use a registered Zend_Translate object to perform run-time string localization So all that s really required here is to replace each element s label with a string identifier, which will be automatically replaced by the translated value at run time Edit the form definition, at $APP_DIR/library/Square/Form/Contactphp, and make the changes highlighted in bold:
Bar Code Scanner In Visual C#.NET
Using Barcode recognizer for VS .NET Control to read, scan bar code image in .NET framework applications.
www.OnBarcode.com
Barcode Scanner In Visual C#.NET
Using Barcode recognizer for VS .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
< php class Square_Form_Contact extends Zend_Form { public function init() { // initialize form $this->setAction('/contact/index') ->setMethod('post'); // create text input for name $name = new Zend_Form_Element_Text('name'); $name->setLabel('contact-name') ->setOptions(array('size' => '35')) ->setRequired(true) ->addValidator('NotEmpty', true) ->addValidator('Alpha', true) ->addFilter('HTMLEntities') ->addFilter('StringTrim'); // create text input for email address $email = new Zend_Form_Element_Text('email'); $email->setLabel('contact-email-address'); $email->setOptions(array('size' => '50')) ->setRequired(true) ->addValidator('NotEmpty', true) ->addValidator('EmailAddress', true) ->addFilter('HTMLEntities') ->addFilter('StringToLower') ->addFilter('StringTrim'); // create text input for message body $message = new Zend_Form_Element_Textarea('message'); $message->setLabel('contact-message') ->setOptions(array('rows' => '8','cols' => '40')) ->setRequired(true) ->addValidator('NotEmpty', true) ->addFilter('HTMLEntities') ->addFilter('StringTrim');
Recognize Data Matrix 2d Barcode In Visual C#
Using Barcode recognizer for Visual Studio .NET Control to read, scan Data Matrix ECC200 image in Visual Studio .NET applications.
www.OnBarcode.com
Data Matrix Scanner In .NET
Using Barcode reader for ASP.NET Control to read, scan Data Matrix 2d barcode image in ASP.NET applications.
www.OnBarcode.com
(continued)
ECC200 Decoder In VS .NET
Using Barcode scanner for .NET framework Control to read, scan Data Matrix ECC200 image in .NET framework applications.
www.OnBarcode.com
Data Matrix ECC200 Scanner In VB.NET
Using Barcode decoder for .NET framework Control to read, scan DataMatrix image in .NET applications.
www.OnBarcode.com
Zend Framework: A Beginner s Guide
Code39 Decoder In C#
Using Barcode reader for Visual Studio .NET Control to read, scan Code 3 of 9 image in .NET applications.
www.OnBarcode.com
European Article Number 13 Scanner In Visual C#
Using Barcode scanner for VS .NET Control to read, scan GTIN - 13 image in Visual Studio .NET applications.
www.OnBarcode.com
// create captcha $captcha = new Zend_Form_Element_Captcha('captcha', array( 'captcha' => array( 'captcha' => 'Image', 'wordLen' => 6, 'timeout' => 300, 'width' => 300, 'height' => 100, 'imgUrl' => '/captcha', 'imgDir' => APPLICATION_PATH '//public/captcha', 'font' => APPLICATION_PATH '//public/fonts/LiberationSansRegularttf', ) )); $captcha->setLabel('contact-verification'); // create submit button $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('contact-send-message') ->setOptions(array('class' => 'submit')); // attach elements to form $this->addElement($name) ->addElement($email) ->addElement($message) ->addElement($captcha) ->addElement($submit); } }
Reading Data Matrix 2d Barcode In C#
Using Barcode recognizer for .NET Control to read, scan Data Matrix ECC200 image in .NET applications.
www.OnBarcode.com
Scan EAN / UCC - 13 In Visual C#.NET
Using Barcode decoder for .NET framework Control to read, scan USS-128 image in .NET framework applications.
www.OnBarcode.com
Creating Translation Sources
USPS Confirm Service Barcode Reader In C#
Using Barcode scanner for VS .NET Control to read, scan USPS Confirm Service Barcode image in Visual Studio .NET applications.
www.OnBarcode.com
PDF 417 Decoder In VB.NET
Using Barcode decoder for .NET framework Control to read, scan PDF417 image in .NET framework applications.
www.OnBarcode.com
Once the various view elements have been configured for localization, the next step is to create translation source files for each language To keep things simple, express these translation source files as PHP arrays, with locales specified within the filename Begin by creating a directory for these translation sources by changing to the $APP_DIR directory and executing the following command:
Bar Code Decoder In None
Using Barcode recognizer for Font Control to read, scan barcode image in Font applications.
www.OnBarcode.com
Recognizing Barcode In None
Using Barcode scanner for Software Control to read, scan bar code image in Software applications.
www.OnBarcode.com
shell> mkdir languages
Reading Barcode In C#
Using Barcode Control SDK for .NET Control to generate, create, read, scan barcode image in Visual Studio .NET applications.
www.OnBarcode.com
UPC-A Supplement 2 Scanner In None
Using Barcode reader for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
Then, go ahead and create translation source files for each language that should be supported Here s an example of the French translation source file, which should be saved as $APP_DIR/languages/messagesfrphp:
DataMatrix Decoder In None
Using Barcode scanner for Online Control to read, scan Data Matrix image in Online applications.
www.OnBarcode.com
GS1 DataBar Limited Scanner In Java
Using Barcode decoder for Java Control to read, scan GS1 DataBar-14 image in Java applications.
www.OnBarcode.com
< php return array( 'menu-home' 'menu-services'
=> 'ACCUEIL', => 'SERVICES',
9:
Understanding Application Localization
'menu-catalog' 'menu-contact' 'welcome' 'created-with' 'licensed-under' 'contact-name' 'contact-email-address' 'contact-message' 'contact-verification' 'contact-send-message' 'contact-title' );
=> => => => => => => => => => =>
'BROCHURE', 'CONTACTEZ-NOUS', 'Bienvenue', 'Cr avec', 'Sous license', 'Nom:', 'Adresse email:', 'Message:', 'V rification:', 'Envoyer Message', 'Contactez-Nous',
Once you re done, you should have a directory structure like the one shown in Figure 9-5
To avoid data corruption, use UTF-8 encoding when creating translation files containing non-Latin characters Some free and commercial text editors with UTF-8 encoding support include gedit on UNIX and Notepad2 on Microsoft Windows Download links can be found at the end of this chapter
Figure 9-5
The application s translation sources, each in a separate file
Ask the Expert
Q: A:
Why do you have a separate translation file for the en locale in addition to files for the en_US and en_GB locales As explained earlier in the chapter, if Zend_Translate is unable to find a translation source file for a locale identifier, it will automatically degrade the locale identifier to just the language code and use the general translation source file for that language, if available Therefore, it s recommended to always include a general translation file for every language that you plan to support in the application, in addition to the more specific translation files This is the reason for including an en language file in addition to the en_US and en_GB language files
(continued)
Zend Framework: A Beginner s Guide
Registering the Translation Object
The final step is to update the application bootstrapper and configure and register an instance of the Zend_Translate object This instance will then become available in all application controllers and views, enabling the use of the translation view helper and Zend_Form s autotranslation features To do this, update the application bootstrapper, at $APP_DIR/application/Bootstrapphp, and add the following method to it:
< php class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected function _initTranslate() { $translate = new Zend_Translate('array', APPLICATION_PATH '//languages/', null, array('scan' => Zend_Translate::LOCALE_FILENAME, 'disableNotices' => 1)); $registry = Zend_Registry::getInstance(); $registry->set('Zend_Translate', $translate); } }
Instead of getting the Zend_Registry instance, you can directly access registry values with the shorthand Zend_Registry::get($index) and Zend_ Registry::set($index, $value) methods
And you re done! To see this in action, configure your browser settings and add French or German as your preferred language Figure 9-6 shows an example of how to do this in Mozilla Firefox, while Figure 9-7 shows an example of how to do this in Microsoft Internet Explorer
Figure 9-6
Copyright © OnBarcode.com . All rights reserved.