Deep talk on Cultures and languages with Asp.net and Sql

Start from the beginning
                                        

 Collapse | Copy Code

<asp:Label />

Step 7 

Execute application for both the cultures and check the output.

So now we know what is meant by globalization and what is meant by localization. It’s time to move further and get a deep dive into some terminologies.

Culture vs. UI Culture

Let say you have created a globalized application considering all the facts we discussed above. And later with the help of resource files you try to make it localized. But the question is will your site work as desired? No, you have to set 2 more properties of your page that is Culture and UICulture to value “auto”.

In the page level

 Collapse | Copy Code

<%@ Page

meta:resourcekey="PageResource1"%>

Or in the application level – at web.config file 

 Collapse | Copy Code

<configuration>

<system.web>

………

<globalization/>

</system.web>

</configuration>

What is the difference between them? 

UICulture value determines what resource file ASP.NET needs to load. It is for the contents in the page.

For example: If UICulture value is set to es-CR then values will be taken from Login.aspx.es-CR.aspx and displayed.

Culture value determines the results of culture-dependent functions, such as the date, number, and currency formatting, and so on.

For example: when Culture value is set to es-CR DateTime and currency will displayed using Costa Rica formats.

Why 2 different properties required?

It gives us higher level of flexibility.  For example, we can switch the language of text and messages according to the browser's configuration while leaving globalization settings (such as dates and currency) constant.

Why the values should be set to auto?

When value is set to auto, values will be considered based on whatever is set for browser. For instance if browser culture is es-CR and UICulture value is set to auto, Spanish resource file will be taken and displayed.

What happen if we won’t set values for these properties?

If you forgot to set the value for culture property your datetime, currencies will start displaying using the default culture of your server. Similarly when UICulture value is not set, values from the default resource file will be considered always.

How to explicitly set culture of a page or application.

We can do it in 3 ways

1. Using @Page directive

 Collapse | Copy Code

<%@ Page

%>

2. Using web.config

 Collapse | Copy Code

<configuration>

<system.web>

...Where stories live. Discover now