Saturday, May 8, 2010

Globalization and Localization

Globalization is the process of designing and developing applications that function for multiple cultures. Localization is the process of customizing your application for a given culture and locale. The topics in this section describe how to create ASP.NET Web applications that can be adapted to different languages and cultures.

Learn more about globalization and localization of ASP.NET web applications at http://msdn.microsoft.com/en-us/library/c6zyy3s9.aspx.

Globalization

Now you can explicitly define the globalization options in the code generator project wizard.

image

You can request the application culture and UI culture to be driven by the client browser or explicitly specify the default culture values. The upcoming releases of the framework will also introduce a language selection menu on the membership bar of the generated ASP.NET+AJAX web applications.

Localization

The new release also supports localization of client-side scripts. The future releases will also introduce data controller localization and externalize any serve-side text constants in resource files.

You can quickly create custom language translations in Web Site Builder and Web Site Factory code generator projects.  The client JavaScript library of Data Aquarium Framework has been re-factored to make translation easy.

The localization file set of  Web Site Factory premium project can be found under [My Documents]\Code OnTime\Library\Data Aquarium\_Translate directory as shown in the picture.

image

The localization file set of Web Site Builder is under [My Documents]\Code OnTime\Library\Web Site Builder\_Translate.

Both code generator projects have the same base localization file set consisting of two files:

  • _Scripts-Web_DataViewResources.txt
  • _Scripts-Web_MembershipResources.txt

Notice that more files will be added in the future.

Here is an example that shows how one can translate membership resources for en-CA locale:

  1. Create an empty text file “Scripts-Web_MembershipResources.en-CA.txt” in the _Translate folder. Notice that the file does not have a leading underscore symbol and includes suffix en-CA representing the locale code. The suffix is inserted just before the file extension. 
  2. Run the code generator, select your project and either enable a client-based culture or select en-CA locale culture in the project wizard on Globalization tab.
  3. Generate the project. The code generator will automatically take notice of the new file in the localization file set and will create sample values. If new based localization resources become available then the file will be updated accordingly. The italicized content of the file is shown below.

    Translations for 'en-CA' are listed below.

    The sample line must be followed by the translation line.
    Both are limited by starting and ending 'pipe' symbol.
    If the sample starts with one or more symbol '^' then do not
    include symbols '^' in the translation.

    ************************************************************
    Scripts\Web.MembershipResources.js
    ************************************************************

    | to this website|
    | to this website|

    |Close|
    |Close|

    |Forgot your password?|
    |Forgot your password?|

    |Full Screen|
    |Full Screen|

    |Help|
    |Help|

    |Login|
    |Login|

    |Logout|
    |Logout|

    |My Account|
    |My Account|

    |Password cannot be blank.|
    |Password cannot be blank.|

    |Password:|
    |Password:|

    |Remember me next time|
    |Remember me next time|

    |Roles|
    |Roles|

    |Sign up now|
    |Sign up now|

    |User name cannot be blank.|
    |User name cannot be blank.|

    |User Name:|
    |User Name:|

    |Users|
    |Users|

    |Your user name and password are not valid.|
    |Your user name and password are not valid.|

  4. Open the file in your favorite text editor  and modify the translation lines. Generate the project again and observe the translated resources displayed in a browser. The generated code will now include new file ~/Scripts/Web.MembershipResources.en-CA.js, which will provide the resources for en-CA locale. The application will automatically serve the right file according to globalization settings.

The following membership login dialog is displayed if you modify the file as shown in the next sample. Notice that numbers are displayed next to all text labels.

image

Sample modifications of  Scripts-Web_MembershipResources.en-CA.txt for the picture above:

Translations for 'en-CA' are listed below.

The sample line must be followed by the translation line.
Both are limited by starting and ending 'pipe' symbol.
If the sample starts with one or more symbol '^' then do not
include symbols '^' in the translation.

************************************************************
Scripts\Web.MembershipResources.js
************************************************************

| to this website|
| to this website 01|

|Close|
|Close 02|

|Forgot your password?|
|Forgot your password? 03|

|Full Screen|
|Full Screen 04|

|Help|
|Help 05|

|Login|
|Login 06|

|Logout|
|Logout 07|

|My Account|
|My Account 08|

|Password cannot be blank.|
|Password cannot be blank. 09|

|Password:|
|Password: 10|

|Remember me next time|
|Remember me next time 11|

|Roles|
|Roles 12|

|Sign up now|
|Sign up now 13|

|User name cannot be blank.|
|User name cannot be blank. 14|

|User Name:|
|User Name: 15|

|Users|
|Users 16|

|Your user name and password are not valid.|
|Your user name and password are not valid. 17|

The upcoming releases of the code generation projects will also introduce right-to-left support. Stay tuned.

Preserving Localization Between Code Generation Library Updates

Code generation library updates automatically replace the previous versions of the code generation files. The custom localization files will be moved to the [My Documents]\Code OnTime\Backup folder when it happens. You can create a copy of your localizations and restore them after each update.

You can also submit the completed localization file sets to Code OnTime for inclusion in the general distribution of the code generation library. The localization file sets will be shared with the community and will get installed automatically with each update.

Please contact us for submission instructions at http://codeontime.com/contactus.aspx.

0 comments:

You can find more about Code OnTime Generator, Data Aquarium Framework, and other great products here.


© 2010 Code OnTime LLC. Intelligent code generation software for ASP.NET. Visit us at http://codeontime.com