473,395 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Locale support for address labels

Hiyas

Our app has a search field where you can select a country drop down
and then enter some search criteria that is address based. We want the
labels on the search form to change based on what country you select.
For example, if I select UK, it might ask for District and Borough
(sp?). Whereas if I select Australia, I need it to say State and
Postcode. For the US it might say Zip instead.

I figure best way is to store all these labels in a resx file by
locale, and when I select UK from ddl, it passes en-uk locale to my
control, which loads the correct labels.

Before I start typing out all the locales in my resx file, I'd like to
know if it already exists. No doubt it does, but couldn't find it by
searching. Anyone know of such a file or even a control that supports
it all?

Cheers,
Steve
Aug 5 '08 #1
5 1387
On Aug 5, 6:26*am, Steven Nagy <learndot...@hotmail.comwrote:
Hiyas

Our app has a search field where you can select a country drop down
and then enter some search criteria that is address based. We want the
labels on the search form to change based on what country you select.
For example, if I select UK, it might ask for District and Borough
(sp?). Whereas if I select Australia, I need it to say State and
Postcode. For the US it might say Zip instead.

I figure best way is to store all these labels in a resx file by
locale, and when I select UK from ddl, it passes en-uk locale to my
control, which loads the correct labels.

Before I start typing out all the locales in my resx file, I'd like to
know if it already exists. No doubt it does, but couldn't find it by
searching. Anyone know of such a file or even a control that supports
it all?

Cheers,
Steve
Hi Steve,

here's a list of cultures
http://msdn.microsoft.com/en-us/libr...o(VS..80).aspx

and here is an example of using resx for a label customization
http://msdn.microsoft.com/en-us/libr...6f(VS.80).aspx

Hope this helps
Aug 5 '08 #2
Thanks Alexey,

Do you (or anyone) know if you can set the locale for a specific
control only?
Lets say my CurrentThread.CurrentUICulture is set to en-US and I want
this to remain as is (loading all the resources for en-US) but I want
to change the locale for just one control to en-UK so that those
resources are loaded for that control instead.
Is this possible?

Cheers,
Steve
Aug 5 '08 #3
On Aug 5, 12:49*pm, Steven Nagy <learndot...@hotmail.comwrote:
Thanks Alexey,

Do you (or anyone) know if you can set the locale for a specific
control only?
Lets say my CurrentThread.CurrentUICulture is set to en-US and I want
this to remain as is (loading all the resources for en-US) but I want
to change the locale for just one control to en-UK so that those
resources are loaded for that control instead.
Is this possible?

Cheers,
Steve
If you understood you correct, you could do it per control as follows

<asp:Label ID="ZIPCodeLabel" Runat="server" Text="<%$
Resources:LocalizedText, ZIPname %>">

For US it would be a "ZIP", for Canada/Europe a "Postal Code", etc.

You could also check the current culture and decide if control/string
needs to be translated or not

if (Thread.CurrentThread.CurrentCulture.Name == "en-US") {
....
} else {
....
}

or

System.Globalization.CultureInfo culture = new
System.Globalization.CultureInfo("en-US");
HttpContext.GetGlobalResourceObject("resource", "ZIPname", culture);

where GetGlobalResourceObject is to retrieve the resource value
("ZIPname") from global resource file, named Resource.resx
programmatically

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

Basically the idea of using resources is to have the translation for
all "strings" in the application. And an application loads the
appropriate localized resources based on the current culture.
Aug 5 '08 #4
Ah this is the code I was after:

System.Globalization.CultureInfo culture = new
System.Globalization.CultureInfo("en-US");
HttpContext.GetGlobalResourceObject("resource", "ZIPname", culture);
Means I can have my single control changed to a different culture, and
have the labels loaded for that culture, while the rest of hte
application still sits in a different culture.

Thanks!
Aug 5 '08 #5
On Aug 6, 12:51*am, Steven Nagy <learndot...@hotmail.comwrote:
Ah this is the code I was after:
System.Globalization.CultureInfo culture = new
System.Globalization.CultureInfo("en-US");
HttpContext.GetGlobalResourceObject("resource", "ZIPname", culture);

Means I can have my single control changed to a different culture, and
have the labels loaded for that culture, while the rest of hte
application still sits in a different culture.

Thanks!

Yes, you can.

Note, there is also the GetLocalResourceObject method to get a page-
level resource (not the global one)
http://msdn.microsoft.com/en-us/library/ms149953.aspx

for example

System.Globalization.CultureInfo culture = new
System.Globalization.CultureInfo("en-US");
GetLocalResourceObject("~/Default.aspx", "PageResource1.Title",
culture);

Hope this helps
Aug 6 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: madeo | last post by:
hi, i'm looking for some script which would export address labels from a mysql db to pdf ... There's an exapmle, but i'm not able to convert it for using with mysql ... can anybody help? THX...
9
by: Nuff Said | last post by:
When I type the following code in the interactive python shell, I get 'UTF-8'; but if I put the code into a Python script and run the script - in the same terminal on my Linux box in which I...
3
by: Ksenia Marasanova | last post by:
Hi, I have some problems with locale module. On my workstation, changing locale doesn't have effect: Python 2.3 (#1, Sep 13 2003, 00:49:11) on darwin Type "help", "copyright", "credits" or...
4
by: Timothy Smith | last post by:
i'm trying to setlocale() on 4.10, and it appears the python package doesn't support this under 4.10. Python 2.3.3 (#2, Apr 28 2004, 22:48:37) ] on freebsd4 Type "help", "copyright", "credits"...
22
by: Keith MacDonald | last post by:
Hello, Is there a portable (at least for VC.Net and g++) method to convert text between wchar_t and char, using the standard library? I may have missed something obvious, but the section on...
4
by: Roger Leigh | last post by:
Hello, I'm writing a fixed-precision floating point class, based on the ideas in the example fixed_pt class in the "Practical C++ Programming" book by Steve Oualline (O' Reilly). This uses a...
3
by: Torsten Bronger | last post by:
Hallöchen! I have to generate excerpts in different human languages in a program. In general, the language is not the locale's language, but set at runtime. Nevertheless, GNU's gettext should...
24
by: Donn Ingle | last post by:
Hello, I hope someone can illuminate this situation for me. Here's the nutshell: 1. On start I call locale.setlocale(locale.LC_ALL,''), the getlocale. 2. If this returns "C" or anything...
0
by: Gabriel Genellina | last post by:
En Tue, 26 Aug 2008 07:52:21 -0300, Robert Rawlins <robert.rawlins@thinkbluemedia.co.ukescribi�: Probably you don't have support for 'de_DE' locale. Try using locale.setlocale(locale.LC_ALL,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.