Monday, March 1, 2010

Globalisation

What is Globalization?

Globalization is the process of developing a program core whose features
and code design are not solely based on a single language or locale.
Instead, their design is developed for the input, display, and output of a
defined set of Unicode-supported language scripts and data related to
specific locales.

OR

Globalization is the process of making an application that supports multiple
cultures without mixing up the business logic and the culture related
information of that application.




What is localization?


In Localization you customize the application for new locales.
This consists of translating resources that you identified during
the globalization phase.



What is Local Resource?


File which stores resources with local scope into App_LocalResource directory. We can not access one pages local resource from another page.
They can be generated by ASP.Net automatically. For it go to design view of aspx page and then Tools > Generate


What is Global Resource?

File used to store resources globally, means we can access same resource
from different pages. It store in App_GlobalResource folder.
we can't generate global resource automatically.


Difference between Local Resource and Global Resource:


1. Performance: Global Resources are faster than Local Resource- because Global Resources are Strongly Typed.
2. Consistency. Explanation: In your application you have Label Text as Category and ten pages. Now you want to change it to CATEGORY then if you using Local Resource concept then you have to change 10 resource files, where as in Global Resource you need to change only one.
3. Difference as per Project Type:
* Local Resource is treated as content based resource, so we can change it and it affects to website.
* Global Resource is treated as embedded resource, So they are compiled into specific language dlls into bin folder.


Code to implement multilingual using global resource:

Globalization refers to the process with which an application or software will be designed and developed so as to make it run across all platforms and all sites with minimum or no modification to the software application. The software is very amenable to customisation so as to suit to the location-specific conditions and it is also capable of providing information based on the varied inputs and the location-specific operating system.
Under any normal circumstance, there will be two processes in Globalization and they are customisation or localisation of the application and internationalizing the application codes so as to meet the standards of the local culture and other related matters.
In internationalization process the application code base will be same and the efforts will be on jobs such as translating, storing, retrieving and to make the application user friendly for the selected locale. In any given place the culture and the language will always be different and besides this you should also take into account the other factors such as time zone, normal date pattern usage, cultural and language environments, currencies, telephone numbers, and so many other factors that are specific to the locale.
In globalization the process of internationalization enables you to remove from the code base and the presentation layer all the contents and make you to use only a single presentation layer and single code base with a common contents that can suit any culture. The internationalization process will aid you to keep all the contents in a common place with an idea of making it easily accessible by the programme codes and the results can easily be populated all over presentation layer and the application with ease and efficiently.
In addition to the above, the internationalization process also enables you to store the contents and all the collected inputs from the user in a user friendly format and in a highly secured manner without compromising any standards pertaining to the local culture. The internationalization process is one step before any attempt for localising the application to suit to the local needs.

With the help of the localization process of globalization, you can make your application adaptable to the various location specific conditions and it will be easy for you to translate and re-format your application to suit to your new location and that too without changing any of the codes. Further, you can make use of the process for rectifying any of the reported bugs and for fine tuning the application for running smoothly without any hitch.
The globalization process also makes use of the locally prevailing information on culture where the software or the application is to be installed and maintained. The locational details and the language used in that particular area constitute to culture information and for working with any culture based information the namespace concept is utilised and the SystemGlobalization, SystemResources and SystemThreading are the available namespaces in .NET Framework.
Out of the various namespaces, the SystemGlobalization namespace constitute classes that are used to hold information relating to region or country, the local language used, type of calendars, date format used, numbers, currency, etc., all in a meticulously arranged fashion and all these classes are used while developing the globalized (internationalized) applications.
You can use advanced globalization functionalities with the assistance of classes such as StringInfo and TextInfo classes and the various functionalities include text element processing and surrogate support systems.
The SystemResources namespace constitutes interfaces and classes that are very helpful for developers and maintenance experts in creating, storing, retrieving, and managing various resources used in the application that are culture and location-specific.
The SystemThreading namespace constitutes interfaces and classes that aid in multithreaded programming. The classes that are used in this type of SystemThreading namespace are also useful in accessing data and for synchronization of thread activities



Why you should go for Globalization in ASP.NET?

Globalization in ASP.Net helps you build an application that can present customized content based on the locale and the culture. For example a person who is browsing an application from France can be displayed the content in French instead of the Standard English that is used by default.
Thus Globalization helps you to build web applications that are truly global. Globalization of an application involves two steps. The first step is to internationalize the code that is developed so that it can be use in any locale or region.
The second step is to present the content according to the culture and language in the locale. The content in the presentation layer is removed and is stored in a separate entity and based on the locale that content presented to the user in their language. For globalization and localization
.Net provides you with classes grouped in the namespaces System.Globalization, System.Resources, System.Text, and System.Threading. So it is essential to use globalization in ASP.Net if you want to build an web application that is truly global.


About ASP.NET Assemblies in .Net?


An assembly in ASP.NET is a collection of single-file or multiple files. The assembly that has more than one file contains either a dynamic link library (DLL) or an EXE file. The assembly also contains metadata that is known as assembly manifest. The assembly manifest contains data about the versioning requirements of the assembly, author name of the assembly, the security requirements that the assembly requires to run, and the various files that form part of the assembly.
The biggest advantage of using ASP.NET Assemblies is that developers can create applications without interfering with other applications on the system. When the developer creates an application that requires an assembly that assembly will not affect other applications. The assembly used for one application is not applied to another application. However one assembly can be shared with other applications. In this case the assembly has to be placed in the bin directory of the application that uses it.
This is in contrast to DLL in the past. Earlier developers used to share libraries of code through DLL. To use the DLL that is developed by another developer for another application, you have to register that DLL in your machine. In ASP.NET, the assembly is created by default whenever you build a DLL. You can check the details of the manifest of the assembly by using classes located in the System.Reflection namespace.
Thus you can create two types of ASP.NET Assemblies in ASP.NET: private ASP.NET Assemblies and shared assemblies. Private ASP.NET Assemblies are created whey you build component files like DLLs that can be applied to one application. Shared ASP.NET Assemblies are created when you want to share the component files across multiple applications. Shared ASP.NET Assemblies must have a unique name and must be placed in Global Assembly Cache (GAC). The GAC is located in the Assembly directory in WinNT. You can view both the manifest and the IL using ILDisassembler (ildasm.exe).
Visit the website links listed below for more detailed information about .NET Assemblies....


Advantages of using ASP.NET Assemblies?


ASP.Net assemblies have a lot of advantages over the conventional DLLs that the developers develop earlier. In the case of DLLs if a DLL has to be shared with some other application, it has to be registered in that particular machine. In the case of assemblies there is no such registration needed.
All you have to do is to just copy the assembly and put in the bin directory of the application that is going to use it. It is as simple as that. In case you need to share a particular assembly with many other applications you can do so by placing the assembly in the Global Assembly Cache (GAC). Before you do so it is necessary that you give a strong name to that assembly.
Strong name is a unique name that is given to the assembly and it can be given using the sn.exe tool. Another advantage of using ASP.Net assemblies is the ability to read the contents of an assembly. Each assembly has a manifest that has details about the assembly itself. The System.Reflection namespace has classes like Assembly which can be used to get the details of the assembly and with that it is also possible to load an assembly dynamically at runtime!


Reflection and Assemblies in .NET?

The advantages of assembly in .Net over the raw executables that you create in conventional programming are that you get information about the assembly itself. The assembly contains information like version, the files that it contains the type of assembly, and other referenced assemblies.
Single modules are used in an assembly most of the time and these modules have types and these types contain the members. The types are usually classes, interfaces, etc. The members are usually variables, methods and properties.
In .Net System.Reflection is the namespace that contains the classes that are used to get information about an assembly. The Assembly class that is found in the System.Reflection root namespace is used to get this information. Hence with this class it is possible to get the types and members of an assembly.
This helps you to get information about assembly and based on that information you can even load assemblies during runtime. GetInterfaces(), GetMethods(), GetMembers(), and InvokeMethod() are some of the methods available in the class Assembly of the System.Reflection namespace.


Managing .NET Assemblies?


An assembly can be compared to that of the executables that are created in other frameworks. However there is a difference when you compare this to the actual executables you have created earlier.
A .Net assembly is actually a source code for the Common Language Runtime which uses the Just-In-Time compiler to compile the source code in the assembly to the native language to execute. The advantage of this type of assembly is that you can just copy it to any location when you need it and there is no need to register it like you did in the early days.
If there are any components that need to be shared by many programs then you can share a component by creating a copy in the Global Assembly Cache (GAC). Before you copy a component in the GAC, you need to give a strong name using the SN.exe tool and then use the GACUTIL tool to copy that component to the GAC.
You can also use the .NET 2.0 configuration tool found in the Control Panel - > Performance and Maintenance - > Administrative Tools to copy an assembly to the Global Assembly Cache.






The Globalization process basically includes,

Internationalizing the application code
Followed by localizing the application to other languages and cultures

Internationalization: This includes translate, store, retrieve, and present application content for any locale. This means identify all parts of our application that need to be different from respective languages.

Localization: adapting your application to other locales by translating and formatting content according to culture. This involves configuring the application for the specific languages.

Culture: This is the combination of Language and the location. For example
En-US - indication English spoken at United States.
En-GB - indication English spoken at Great Briton.



Namespaces:

To work with the cultural information, we have below namespaces in .NET.

1. System.Globalization
2. System.Resources


The .NET framework has 3 namespaces to help you develop world-ready applications:System.Threading, System.Globalization and System.Resources.

The System.Threading includes a very known class called Thread. The Thread class has a propriety called CurrentCulture that you can use to get/set the current culture of the thread.

The System.Globalization namespace contains classes that define culture-related information, including the language, the country/region, the calendars in use, the format patterns for dates, currency, and numbers, and the sort order for strings. These classes are useful for writing globalized (internationalized) applications



The System.Resources namespace provides classes and interfaces that allow developers to create, store, and manage various culture-specific resources used in an application. One of the most important classes of the System.Resources namespace is the ResourceManager class.

Using resources files and the ResourceManager class

Resources files are xml documents that have all the resources for a specific culture. The ResourceManager class provides convenient access to that culture-specific resources at runtime.

Retriving a value stored in a resource file is as simple as invoking the GetString method of the ResourceManager.




DialogResult result = MessageBox.Show("Do you want to close?", MessageBoxButtons.YesNo);

Instead we can use,

System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
DialogResult result = MessageBox.Show(resources.GetString("quitapplication"), resources.GetString("quit"), essageBoxButtons.YesNo);







1. Add below code in the page directive.

< %@ Page language="c#" Culture="kn-IN"% >

2. Add a calendar control to the page.
3. Run the application, you will find that the language is changed to Kannada (Fig.3)




If we need to set the culture at application level then we can add below code in web.config file.

< globalization culture="kn-IN" / >




==========================
Globalisatioin Development
==========================

Globalisation
gOOgle Language Translator
--------------------------

http://translate.google.com/#


LocalResource (unic)
--------------

This is Effected by Page Level
means Each .ASPX contain each .resx file

GlobalResource (Common)
--------------
This is Effected by any page in the application



Localisation Resource ( Static Values changes)
================================================


using System.Resources;
using System.Globalization


1. Design the Web page according to needs
--------------------------------------

label control with Text "What is you Name"

Add dropdownlist with list items

1. text = English, value = en-US.
2. text = Frence, Value = fr-FR.

2. Open design page and do below
-------------------------------

click Tools - Generate LocalResource .

then u get App_LocalResources with Under filename.aspx.resx.

next

copy filename.aspx.resx
right click app_LocalResources and paste.

then u get copytofilename.aspx.resx

change name copytofilename.aspx.resx to filename.aspx.fr-FR.resx

3. Double click filename.aspx.fr-FR.resx file and do below
-------------------------------------------------------

once you open filename.aspx.fr-FR.resx file than u get

list of Name and Value with columns

in that Values Translate into Frence
using Google Translate http://translate.google.com/#

(ex:- "What is you Name" is "Quel est votre Nom")



4.In code behand class add below InitializeCulture()
----------------------------------------------------

protected override void InitializeCulture()
{
if (Request.Form["DropDownList1"] != null)
{
string strUICultrue = Request.Form["DropDownList1"].ToString();
UICulture = strUICultrue;
}


base.InitializeCulture();
}


5. Run your application and Get the result by changing Dropdownlist items.


----------------------------------------------
Inserting Data in the Database(SQLSERVER 2008)
----------------------------------------------

Design Table
------------
String value datatype must be nvarchar(MAX)

Query Insert
------------

@"Insert into TabE values('"+txtUserID.Text+"',N'"+txtUserName.Text+"')"

Query Retrive
-------------

"select EName from TabE where EID = '"+txtUID.Text+"' "






----------------------------------------------
different way to fetch resource key and values
----------------------------------------------

Resource file name not use special charactor( -,. etc)

Use resource file name -- ErrormessagesfrFR (for French)

1.

// for English
Label1.Text =GetGlobalResourceObject("Errormessages", "Error1").ToString();


// for French
Label1.Text =GetGlobalResourceObject("ErrormessagesfrFR", "Error1").ToString();


2.

Label1.Text = Errormessages.Error1;

3.

lblMessage.Text = GetLocalResourceObject("PageResource1.Title").ToString() ;







resgen Strings.en-US.resx LocalizationSample.
Strings.en-US.resources
al /embed:LocalizationSample.Strings.en-US.resources /out:LocalizationSample.resources.dll /c:en-US



------------------------------------------
Steps for Localisation and Globalisation
------------------------------------------

Localisation
==============

1.Complete design for your page and whatever required hardcoded replace to label for globalisation

2.Open your design page of required Page

3.In VS Main manu Click the below

Tools- > General Local Resource

4.You will get App_LocalResources folder with YourPageName.aspx.resx file.

5.Copy your YourPageName.aspx.resx and paste in the same folder (App_LocalResources).
and rename the copied new file to YourPage.aspx.LanguageCode.resx (Ex:-YourPage.aspx.fr-FR.resx in french language).

7.using Language Translater convert values to specified language in the YourPage.aspx.LanguageCode.resx file
free translater URL : http://www.worldlingo.com/en/products_services/worldlingo_translator.html

8.in your Design page change the hardcoded label text value to resourcekey with .Text.

example:- if your resource key value meta:resourcekey="lblPasswordResource1"
than text value Text="lblPasswordResource1.Text"

9.Add below method in codebehand of every page


protected override void InitializeCulture()
{
Page.UICulture = clsCulture.CultureName();
base.InitializeCulture();
}



10. Java Script Alert in code behand

confirm('< %= clsGlbEdue.GetResourceString("alertdelete").ToString() % > ');

alert('< %= clsGlbEdue.GetResourceString("alertdelete").ToString() % > ');







Globalisation
==============


1.Create one method name Globalization() and pass resource key in below example passing "Pagetitle" and "lblUserName"


private void Globalization()
{
try
{

Page.Title = clsGlbEdue.GetResourceString("Pagetitle").ToString();
lblUserName.Text = clsGlbEdue.GetResourceString("lblUserName").ToString();

}
catch (Exception ex)
{
throw ex;
}
}


2. clsGlbEdue is a class with contain Resource file name and Cultures

3. Java Script Alert in code behand

Response.Write("< script > alert('" + clsGlbEdue.GetResourceString("alertdelete").ToString() + "')< /script > ");





======================
OTHERS Examples
======================


Example 10 :- Directly  binded in the .ASPX page control.
1.        Use GlobalResource file  :
1.       Add the below code in the Global.asax page
        void Application_Start(object sender, EventArgs e)
    {
        string[] languages = HttpContext.Current.Request.UserLanguages;
 
        if (languages[0].ToLower() != null && languages[0].ToLower() != "")
        {
 
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(languages[0].ToLower());
 
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(languages[0].ToLower());
 
        }
 
    }
2.       Add resource files in  app_globalresource folder:
                 TestResource.resx (Default) 
               TestResource.hi.resx (Hindi) 
               TestResource.zn-ch.resx (Chinese) 
TestResource  ( is a Resource file name) and    LabelText ( is a Resource file key Name)


3.       In your .ASPX page Add  label with
< asp:Label ID="lblText" runat="server" Text="< %$ Resources:TestResource, LabelText % > " / >
 


Example 11 :-  Get the Cultures which supported by DOTNET  (dotnet support 235 cultures)
1.  Add below code in Page_load
 
        protected void Page_Load(object sender, EventArgs e)
         {
        // Get the Cultures which supported by DOTNET  (dotnet support 235 cultures)
        int i = 0;
        foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures))
        {
            ListBox1.Items.Add(ci.Name.ToString());
            i++;          
        }
        Response.Write(i);
 
         }
 
2.       In  .aspx  add list box
< asp:ListBox ID="ListBox1" runat="server" > < /asp:ListBox >

Example 1 :-
1.       Create One Website
2.       Add controls like   Hyperlink  (  property settings :   text  is empty, Navigation URL is  ~/Default.aspx )  And   add Image Control (property settings : imageID  change).
And Create the folder name as Images and add the 2 images in that (flag_in.gif , flag_uk.gif)
Add local resource (Tools – LocalResourcefile) and set the values as below

Example : Name = HyperLink1Resource1.Text  , Value = Refresh
Name = imgEnteranceResource1.ImageUrl , value = ~images/flag_in.gif




3.       Copy the  above resource file and  paste in their folder itself
And rename the file as Default.aspx.pt-BR.resx    and set the values as below


Example : Name = HyperLink1Resource1.Text  , Value = Atualizar
Name = imgEnteranceResource1.ImageUrl , value = ~images/flag_uk.gif



4.       Language setting (IE – Tools – InternetOptions – Languages – add  - ( add  languages)  and move up and setting default languages )


 
5.       Now it will change the Images according to Local Languages
 
Example 2 :-

1.       To avoid the  Example 1  in Step-4  use the example continue..
2.       Add control  i.e  ImageButton and set the Property (ImageURL,PostbackUrl)
ImageURL=~/Images/flag-in.gif   , PostbackUrl=~/Default.aspx?language=en-US .
3.        Add another control  i.e  ImageButton and set the Property (ImageURL,PostbackUrl)
ImageURL=~/Images/flag-us.gif   , PostbackUrl=~/Default.aspx?language=pt-BR .
4.       In code add the InitializeCulture method
         protected override void InitializeCulture()
    {
     if (Request["language"] != null)
       {
   Thread.CurrentThread.CurrentCulture = new CultureInfo(Request["language"].ToString());
   Thread.CurrentThread.CurrentUICulture = new CultureInfo(Request["language"].ToString());       
        }
           base.InitializeCulture();
    }
 
1.       Dynamically  :
========================
1.       Add one lablel in the above  and add below code in the page_load  //  Local Resource
// get the resource file key values by using  key of file
       lblMessage.Text = GetLocalResourceObject("PageResource1.Title").ToString() ;
   // GetlocalResourceObject( add the Local Resource key Name).toString();
2.       add GlobalResource file (TestResource.resx and TestResource.pt-BR.resx) and key Name is   LabelText  and  Value =  hi how r u ,  also add in the  TestResource.pt-BR file key name and Value below code in the page_load  //  Global Resource
// get the resource file key values by using  key of file
       lblMessage.Text = GetGlobalResourceObject("TestResource", "LabelText").ToString();
   // GetlocalResourceObject(add GlobalResource file Name,Resource Key Name ).toString();
3.       also you can write as below.  (Resourcefilename.KeyName)
          lblMessage.Text = lblMessage.Text = TestResource.LabelText;
 
 


=====================================
Satalite Assembly
=====================================

Satellite Assembly
---------------------
When you wish to make the application customizable for different languages and cultures and distribute the localized modules in separate assemblies called satellite assemblies.
It can be written in code that uses resources from an assembly rather than hard-coding the resources in the program.


C:\Documents and Settings\raj.kumar\Desktop\Raj\Examples\Globalization\SPGLWEBDEMO\SPGLWEBDEMO >
al /t:lib /embed:App_LocalResources /culture:en /out:SPGLWEBDEMO.resources.dll

ResourceTemp.resx

al /t:lib /embed:Default.aspx.fr-FR /culture:fr-FR /out:SPGLWEBDEMO.resources.dll

al /t:lib /embed:rr /culture:fr-FR /out:resources.dll




Create Simple Satellite Assembly :-


http://msdn.microsoft.com/en-us/library/aa645513%28VS.71%29.aspx

http://msdn.microsoft.com/en-us/library/cc668131.aspx

http://sharpertutorials.com/creating-and-implementing-satellite-assemblies/

http://msdn.microsoft.com/en-us/library/7k989cfy%28VS.80%29.aspx




=====================================
Globalisation Design Tips
=====================================



< %@ Page UICulture="de" Culture="en-US"...% >


// C#
// Import these namespaces at the beginning of the code module.
using System.Globalization;
using System.Threading;

// Set the culture and UI culture to the browser's accept language
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages[0]);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(Request.UserLanguages[0]);


< %@ Page ResponseEncoding="utf-8" RequestEncoding="utf-8"% >


< configuration >
< system.web >
< globalization
fileEncoding="utf-8"
requestEncoding="utf-8"
responseEncoding="utf-8"
culture="en-US"
uiCulture="de-DE"
/ >
< /system.web >
< /configuration >


To set the direction attribute in a Web Forms page
In HTML view, edit the < HTML > or < BODY > tag to add the DIR attribute.

< HTML dir="rtl" >
< !-- Or -- >
< body dir="rtl" >


In HTML view, edit the tags of any HTML elements, HTML server controls, or Web Forms controls for which you wish to override the DIR attribute.

< TABLE dir="ltr" >
< asp:TextBox dir="ltr" >



HTML Layout Guidelines for Web Forms Globalization


Never use Cascading StyleSheet (CSS) properties for absolute positions.
< !-- Do not do this -- >
< DIV id = idFindWhatLabel style = "position: absolute; left: 0.98em; top: 1.2168em; width: 4.8em; height: 1.2168em;" >




Forms should take advantage of the available width and height.
< !-- Table sized to take up entire width of the form-- >
< table width=100% >

< !-- div sized to take up half the width and height of the form -- >
< div style='position:absolute; left: 0; top: 0;
height: expression(document.body.clientHeight / 2);
width: expression(document.body.clientWidth / 2); ' >



Each control should be in a separate table cell.
Allow wrapping text.
Separate check boxes and radio buttons from their label text.

Leave room for growth, and avoid fixed widths.
Text may expand when translated into other languages. A good rule of thumb is to leave room for 300% growth on short strings (fewer than 10 characters), 200% growth on medium strings (10-20 characters), and 100% growth on large strings (more than 20 characters).
One acceptable solution is to set table cell width to a percentage of the form width so the cell can expand relative to the entire table. However, try to specify as few relative sizes (other than 100%) as possible, because you want the HTML layout engine to do most of the work for you.


< !-- Table cell sized to take up one quarter width of the table -- >
< td width=25% >





Size buttons in as few places as possible. Often there is a set of buttons that should have the same size. Set this size in one place for the entire set of buttons, if possible. Allow room for the text to expand in list boxes and group boxes.
Set height as seldom as possible. Do not set the cell height for any table cell or control that contains text. (You may set the line height for CSS elements.) Otherwise, the look of the page will change if the user sets the text size in the browser.
Do not use left or right align in HTML tags. In general, avoid setting "align=left" or "align=right" for any table cell. These properties may interfere with the layout of forms for cultures in which text layout flows from right to left.
Avoid inline CSS values that may need to be changed. Keep all CSS values that localizers may need to change in style sheets, rather than inline. This includes setting the font for a page.






=====================================
Globalisation for Windows Application
=====================================

==========================================================================
Globalization of the string values in c# in Dotnet
-----------------------------------------------------------


Example:


// General is a class


// frmCustomSetup, glblbCCTitle etc resource string names. // in form


// this.text , LbccTitle.Text etc are control names // in form


//Globalization() add this method in Form_load // in form


private void Globalization()

{

General.GlobalizeApp();

this.Text = General.GetResourceString("frmCustomSetup");

this.lbCCTitle.Text = General.GetResourceString("glblbCCTitle");

this.btnCSBack.Text = General.GetResourceString("btnBack");

this.btnCSNext.Text = General.GetResourceString("btnNext");

this.lbSelectSwitch.Text = General.GetResourceString("frmCSlbComboTxt");

this.lbCSProDesc.Text = General.GetResourceString("frmCSlbTBTxt");

this.txtProDesc.Text = General.GetResourceString("frmCStxtProDescTxt");

this.lbLCSelectInstall.Text = General.GetResourceString("frmCSlbTVTxt");

this.lbContinue.Text = General.GetResourceString("glblbContinuNext");

this.lbCSSubtitle.Text = General.GetResourceString("frmCSTitle");

this.btnCSCancel.Text = General.GetResourceString("btnCancel");


}




// this method is written in General Class. // in class




// Gets the resource string.

public static string GetResourceString(string resourceKey)

{

return DVDControllerUIResx.GetString(resourceKey);

}




// Initialize Globalization Culture and Resources

private static ResourceManager DVDControllerUIResx;




// Implements Globalization accross the installer,sets resource and culture.

public static void GlobalizeApp()

{

SetCulture();

SetResource();

}




// Sets the resource for Globalization.

private static void SetResource()

{

if (DVDControllerUIResx == null)

DVDControllerUIResx = new ResourceManager("CCDVDInstaller.Resources.Description", Assembly.GetExecutingAssembly());

}









======================================================================
Globalization of Cultures and Resources of the string values in c# in Dotnet
--------------------------------------------------------------



public static void GlobalizeApp()

{

SetCulture();

SetResource();

}



/// Sets the culture for Globalization.


private static void SetCulture()

{

Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;

}



/// Sets the resource for Globalization.

//

// Initialize Globalization Culture and Resources

private static ResourceManager DVDControllerUIResx;

private static void SetResource()

{

if (DVDControllerUIResx == null)

DVDControllerUIResx = new ResourceManager("CCDVDInstaller.Resources.Description", Assembly.GetExecutingAssembly());

}





===========================================
AUTO Vertical Scroll for richtextbox C# in Dotnet
----------------------------------------------------

//auto scrolling according to the text change

// richtxtUnInsDesc is the richtextbox name


private void richtxtUnInsDesc_TextChanged(object sender, EventArgs e)

{

richtxtUnInsDesc.Focus();

richtxtUnInsDesc.SelectionStart = richtxtUnInsDesc.Text.Length - 1;

this.richtxtUnInsDesc.ScrollToCaret();

}






------------------------------
Globalisation in Java Script
------------------------------

http://www.codeproject.com/KB/aspnet/globalizedJsXslt.aspx



In the root directory of the Web site, add a folder named Scripts.

In the Scripts folder, add a JScript file named CheckAnswer.js, and then add the following code to the file.

Sys.Application.add_load(SetButton);
function SetButton()
{
$get('Button1').value = Answer.Verify;
}
function CheckAnswer()
{
var firstInt = $get('firstNumber').innerText;
var secondInt = $get('secondNumber').innerText;
var userAnswer = $get('userAnswer');

if ((Number.parseLocale(firstInt) + Number.parseLocale(secondInt)) == userAnswer.value)
{
alert(Answer.Correct);
return true;
}
else
{
alert(Answer.Incorrect);
return false;
}
}


Answer={
"Verify":"Verify Answer",
"Correct":"Yes, your answer is correct.",
"Incorrect":"No, your answer is incorrect."
};



In the Scripts folder, add a JScript file named CheckAnswer.it-IT.js. Add the following code to the file.

Sys.Application.add_load(SetButton);
function SetButton()
{
$get('Button1').value = Answer.Verify;
}
function CheckAnswer()
{
var firstInt = $get('firstNumber').innerText;
var secondInt = $get('secondNumber').innerText;
var userAnswer = $get('userAnswer');

if ((Number.parseLocale(firstInt) + Number.parseLocale(secondInt)) == userAnswer.value)
{
alert(Answer.Correct);
return true;
}
else
{
alert(Answer.Incorrect);
return false;
}
}

Answer={
"Verify":"Verificare la risposta",
"Correct":"Si, la risposta e’ corretta.",
"Incorrect":"No, la risposta e’ sbagliata."
};









LCID's
------

Kannada -- kn-IN
Hindi -- hi-IN
Gujarati -- gu-IN
English(UK) -- en-GB
English(US) -- en-us
etc.......



------------------------------
Example 1.
-----------------------------



public string Getschool(string clientMsg)
{
String strResourcesPath = Server.MapPath("App_LocalResources");
ResourceManager rm = ResourceManager.CreateFileBasedResourceManager("resource", strResourcesPath, null);

string retSname = String.Empty;
retSname = rm.GetString("009");
if (!String.IsNullOrEmpty(retSname))
{

}
else
{

}
return retSname.Replace("'", @"\'");
}



public string Getaddress(string clientMsg)
{
String strResourcesPath = Server.MapPath("App_LocalResources");
ResourceManager rm = ResourceManager.CreateFileBasedResourceManager("resource", strResourcesPath, null);
string retadd = String.Empty;
retadd = rm.GetString("010");
if (!String.IsNullOrEmpty(retadd))
{

}
else
{

}
return retadd.Replace("'", @"\'");
}

---------------------------------------
Create Resource file from Text file
----------------------------------------

resgen c:\WebSite\SiteResources.txt c:\WebSite\SiteResources.resx

---------------------------------------
Get Values from local Resource file
----------------------------------------

txtEID.Text = GetLocalResourceObject("val2").ToString();




References
=============


http://javascript.internet.com/forms/basic-validation.html

Vedio

http://forums.asp.net/151.aspx?PageIndex=107&forumoptions=0:1:11::

http://www.asp.net/learn/videos/video-40.aspx



Globalisation telerik
http://www.telerik.com/help/aspnet-ajax/grdlocalizingtootips.html


Validation

http://cwiki.apache.org/WICKET/form-validation-messages.html

http://www.quirksmode.org/dom/error.html



http://www.worldlingo.com/en/products_services/document_translator.html

Calender changes
--------------------------
http://www.c-sharpcorner.com/UploadFile/rupadhyaya/GloblizationInDotNEt12032005004146AM/GloblizationInDotNEt.aspx

No comments:

Post a Comment