0

The title may not be very clear but what I want to do is really simple: I want to display a list of culture by their names like this:

  • English for culture "en"
  • Deutsch for culture "de"
  • Français for culture "fr
  • Italiano for culture "it"
  • Español for culture "es"
  • etc...
G.Dealmeida
  • 325
  • 3
  • 14
  • what language are you coding in? how do you want to output the data on a webpage or csv? Have you tried any code yet? How far did you get, what error messages or issues did you come across? – Fuzzybear Jul 04 '18 at 13:10
  • Consider CultureInfo.NativeName. Beware of displaying text in non-Latin alphabets. Rough on console apps, rough on users that can't read text in such an alphabet. – Hans Passant Jul 04 '18 at 13:17

3 Answers3

3

This will display the name in the required (native) language:

Console.WriteLine(System.Globalization.CultureInfo.GetCultureInfo("en").NativeName);
Console.WriteLine(System.Globalization.CultureInfo.GetCultureInfo("de").NativeName);
Console.WriteLine(System.Globalization.CultureInfo.GetCultureInfo("fr").NativeName);
Stevo
  • 1,424
  • 11
  • 20
1

See CultureInfo.NativeName:

CultureInfo myCultureInfo = new CultureInfo("es", false);
Console.Write(myCultureInfo.NativeName);

EDIT: changed DisplayName method to NativeName as I realized the OP asked for it.

vahdet
  • 6,357
  • 9
  • 51
  • 106
0

The below little code snippet will get all the available culture and print it in tabular format. The output of the code is given below,

protected void Page_Load(object sender, EventArgs e)

    {

        CultureInfo[] cinfo = CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures);

        Response.Write("<table border=\"1\"><tr><th>Country Name</th><th>Language-Country code</th></tr>");

        foreach (CultureInfo cul in cinfo)

        {

            Response.Write("<tr>");

            Response.Write("<td>" + cul.DisplayName + " </td><td> " + cul.Name + "</td>");

            Response.Write("</tr>");

        }

        Response.Write("</table>");

    }
Fuzzybear
  • 1,388
  • 2
  • 25
  • 42