Just below it, we have an informative text which says, minimum 900 Rs is required in our pocket for successful login.
One last thing which should be noticed about the UI is, everything is in English language.
In order to identify globalization issues we have to take a look at Markup and Code behind.
Problems with the above code are
UI (aspx) contains too many static contents (like messages “in your pocket”, “User Name”, “Password” etc.). In order to make the UI a globalized UI, we should replace these static contents with some placeholders so that contents can be changed or replaced at run time based on specific culture.
For displaying current date we are manually concatenating the individual parts of the date and displaying in dd/mm/yyyy format which is correct for Indian cultures, but what about other cultures? We have to use a generic syntax for representing date.
For displaying amount we are using “ToString” method of our “amount” variable and appending with “Rs” string. Again this is perfect, only when it comes to Indian cultures. For displaying amount we should use some kind of generic way which will automatically format number (amount variable) for decimals, separators, prefixes and suffixes.
Solution
For making static contents dynamic, we can use “Label” in Asp.net and change its Text property at runtime based on culture at runtime.
Note: It’s not like label is the only solution, you can use anything whose content can be changed at runtime. Example: Literal, Textbox etc.
For displaying current date we will use “ToShortDateString” method of DateTime object.
And for amount instead of ordinary “ToString” method we will use overloaded version of it, passing “c” as an argument. (“C” indicates currency).
Final Code
Output
Now this output is different from the previous one
Now current date is displayed in mm/dd/yyyy format.
Formatting of amount is US formatting.
What is the reason for such kind of difference
Earlier whatever was getting displayed it was basically using fixed formats and styles, but now everything is culture and language based and when I say culture and language it means culture and language of a browser.
Let’s change the browser culture to one of the Spanish culture and check the output.
Note: we are not covering how to change browser culture. You may find lots of internet links for the same. For reference find the following link http://www.wikihow.com/Change-Your-Browser's-Language.
As you can see globalized application can adapt easily to multiple cultures.
What is the problem?
Globalized application never translates anything, it only affects the formatting. You can see in the output that all texts are still in English. In the next step we will manually tell the system what every word means in Spanish and that is called Localization.
How to make the application Localized application.
In order to make the application localized first we should make it globalized.
Now in order to achieve localization Microsoft .Net has something called as resource files.
There are 2 kinds of resource files 1) Local Resource files 2) Global Resource files.
Deep talk on Cultures and languages with Asp.net and Sql
Start from the beginning
