This articles explains the concept of Localization, Globlization, Resources, Satelite Assembly etc for developing Multi-lingual ASP.Net.
Developing Multi-lingual Web Application we first need to
understand the concept behind multi-lingual.
As per name we can say that it should support various languages
to display its web contents and stores data in various languages.
- Understanding Globalization, Localization and Culture
- Local Resources, Global Resources and Satellite Assemblies
- Implementing Internalization
.Net provides concepts of Globalization and localization
for it, so first understand it.
Globalization is process of identifying all the
localizable resources in the application that will support multiple cultures.
Ideally it is performing during design phase of an application, so that the resources
always remain separate from the code.
In Localization you customize the application for new
locales. This consists of translating resources that you identified during the
Difference between Localization and Globalization:
Globalization is process of identifying how many resources
needs to be localized to adopt a multiple culture support, while Localization
is actual process of translating resource to a specific culture. So
Localization is the part of Globalization.
Culture means geographical location which identify group
of people having same type interest, life style, language etc.
As for Example:
Hi-IN - indication Hindi spoken at India.
En-US - indication English spoken at United States.
En-GB - indication English spoken at Great Briton.
Microsoft .Net provides .resx files to support
Resource file is xml format file having key-value pair for
Resource files consists of user interface data, like
texts, logos, images etc resources.
English - Hello, good morning.
You can not use any special character in key pair.
Local Resource is xml based 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
<asp:Button ID="Button1" runat="server" Text="<%$Resources: MyLocalResourcekey1%>" />Way 2:
Button1.Text = GetLocalResourceObject("MyLocalResourcekey1").ToString();
Global Resource is also xml format file, used to store
resources globally, means we can access same resource from different pages. It
store in App_GlobalResource folder.
As like Local Resource we can not generate it
<asp:Button ID="Button1" runat="server" Text="<%$Resources:MyGlobalResourceClass, MyGlobalResourcekey1%>" />Way 2:
Button1.Text = GetGlobalResourceObject("MyGlobalResourcekey1").ToString();Way 3:
Button1.Text = Resources. MyGlobalResourceClass. MyGlobalResourcekey1;
Local Resource vs. Global Resource:
1. Performance: Global Resources are faster than Local
Resource- because Global Resources are Strongly Typed.
2. Data 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
3. Difference as per Project Type:
a. ASP.Net Website (Microsoft Visual Studio’s
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
b. ASP.Net Web Application
Both Local and Global resource
are treated as content based resource, so both are editable.
Any change in any type of
resource cause whole resource compilation.
Assembly containing no
executable code—only resources. Typically, satellite assemblies are used for
storing localized data. Satellite assembles can be added, modified, and loaded
into a .NET application at runtime without recompiling. Use the Assembly
Linking Utility to create satellite assemblies by compiling .resource files.
It reduces the overhead of
compiling resources and makes application faster.
Step 1: Creating
Compile resource files (.resource)
Use “resgen.exe” tool to create Compile resource files (.resource) from resource file (.txt or
resgen myresource.resxStep 2: Creating
Use following AL commandline to
AL /t:lib /culture:en-US /embed: myresource.en-GU.resources /out: myresource.resources.dllWhere,
switch tells that the output is of type library (DLL),
switch tells that the resources being embedded in the assembly are for en-US
/embed switch specifies the
.resources file that is to be embedded in the Satellite Assembly,
switch specifies the name of output assembly.