Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get culture name from cultureCode

Tags:

c#

.net

Is there a built in method in .NET to convert a culture code into a user-friendly name? E.g:

  • en-GB - English - United Kingdom
  • et-EE - Estonian - Estonia
  • pa-IN - Punjabi – India
  • fo-FO - Faroese – Faroe Islands
like image 369
Robert W Avatar asked Jun 30 '11 09:06

Robert W


2 Answers

CultureInfo has a property called DisplayName

var culture = CultureInfo.GetCultureInfo("en-GB");
var displayName = culture.DisplayName;

DisplayName gives you a localized version of the name. There is also a EnglishName property. ;)

like image 166
ba__friend Avatar answered Oct 14 '22 05:10

ba__friend


string displayName;

CultureInfo cultureInfo = CultureInfo.GetCultureInfo("fo-FO");

displayName = cultureInfo.DisplayName;

EDIT:

Removed if (culture != null).

like image 31
Dummy01 Avatar answered Oct 14 '22 04:10

Dummy01