Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / May 2005

Tip: Looking for answers? Try searching our database.

displaying country name in current UI culture?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rich - 06 May 2005 17:38 GMT
I have a two-letter country code and I need to display the name of this
country in the current UI culture.

Sadly I can't create a CultureInfo and use the DisplayName property
because this displays it in the localised version of the .NET framework
and not in the current UI culture which I might have changed (it is
calculated regardless of the language that the system is set to
display).

e.g:
country code: US
current ui culture: Spanish:
test string i need: "Estados Unidos"

Any suggestions?
Katy King - 06 May 2005 21:05 GMT
From: "Rich" <webstuff@urbanperspective.net>
| I have a two-letter country code and I need to display the name of this
| country in the current UI culture.
[quoted text clipped - 4 lines]
| calculated regardless of the language that the system is set to
| display).

CultureInfo.NativeName is in the language of that culture.  So if you're
looking for the native name of the current UI culture, use that.
CultureInfo.DisplayName is (as you found) based on the language of the .NET
framework.
CultureInfo.EnglishName is always the English name for the culture.

If you want to display the name of a culture in some other language (e.g.,
Framework is English, current UI is Spanish, and you want the name of
German culture in Spanish), I'm not sure how to get that.

Katy
Rich Urwin - 07 May 2005 10:21 GMT
Hi,

> If you want to display the name of a culture in some
> other language (e.g., Framework is English, current UI
> is Spanish, and you want the name of German culture in
> Spanish), I'm not sure how to get that.

Thanks for replying - that's exactly what I want! Anybody else have any
suggestions?

cheers,
rich
Marc Bernard - 09 May 2005 17:56 GMT
> Hi,
>
[quoted text clipped - 5 lines]
> Thanks for replying - that's exactly what I want! Anybody else have any
> suggestions?

I would suggest asking in microsoft.public.dotnet.internationalization

:)
Nicole Calinoiu - 09 May 2005 19:05 GMT
How about the same way the CultureInfo class does it?  e.g.:

public string GetLocalizedName(CultureInfo targetCulture, CultureInfo
languageCulture)
{
     ResourceManager manager = new ResourceManager("mscorlib",
typeof(string).Assembly);
     return manager.GetString("Globalization.ci_" + targetCulture.Name,
languageCulture);
}

One important detail is that the mscorlib resources file for the specified
language must be installed on the machine.  If not, the usual
ResourceManager language fallback rules will be applied.  In other words,
it's probably pretty useless even if all available language packs have been
installed (which is extremely unlikely).

> Hi,
>
[quoted text clipped - 10 lines]
>
> *** Sent via Developersdex http://www.developersdex.com ***

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.