Newbie Question: Recommended method of globalization

G

Guest

I am certain that there are many long chapters on this subject, but perhaps
someone can quickly point me in the right direction:

When developing a pocket-pc app, is there a recommended (simple) approach to
localizing applications? My pocket-pc application implements many
date-related operations, and the date-format differences between US and
European countries are causing problems.

Currently, I have “hard-coded†the culture info as follows: private
CultureInfo defaultCulture = new CultureInfo("en-US");

When executing DML with SQL CE or directly w/ SQL 2002, i then convert the
date format manually to “en-USâ€. However, i am certain there is an easier
way? In ASP.NET in the WEB.CONFIG file, i can specify globalization in one
centralized attribute, and that’s it. I wonder if the same can be done when
developing apps w/ the Compact Framework?

Thanks,
 
G

Guest

Hi Charlie,

In .NET Framework we are able to set the CurrentCulture or CurrentUICulture
to the specified culture through the CultureInfo method of the Thread class.
But it can only set on the main thread of the application. This is not
supported in .NET Compact Framework. But resource files for localized content
are supported.

So you can use the the CultureInfo class without hardcoding, rather you get
the CurrentCulture through the
System.Globalization.CultureInfo.CurrentCulture (or CurrentUICulture) and
assign it to a global variable of type string.

public string str;
str=System.Globalization.CultureInfo.CurrentCulture.Name;
private CultureInfo defaultCulture = new CultureInfo(str);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top