0

After set CultureInfo.DefaultThreadCurrentUICulture CultureInfo.DisplayName always returns english.

I try

    CultureInfo cu = new CultureInfo("ja-JP");
    System.Threading.Thread.CurrentThread.CurrentCulture = cu;
    CultureInfo.DefaultThreadCurrentCulture = cu;
      // CultureInfo.DefaultThreadCurrentUICulture = cu;
    // SetDefaultCulture(cu);
    Dictionary<string, string> ifile = new Dictionary<string, string>();
    var regex = new System.Text.RegularExpressions.Regex(@"([\w+\s*\.*]+\))");
    foreach (var item in CultureInfo.GetCultures(CultureTypes.FrameworkCultures))
    {

      I18nCulture country = new I18nCulture();
      var match = regex.Match(item.DisplayName);
      string countryName = match.Value.Length == 0 ? item.EnglishName : match.Value.Substring(0, match.Value.Length - 1);
      if (item.Name != "")
      { 
        ifile.Add(item.Name, item.DisplayName);
      }
    }

    string fn = System.IO.Path.Combine(rootPath, "lib", "i18n", "culture", lng + ".json");
    Console.WriteLine("save : " + fn);
    saveObjectToJSON(ifile, fn);

When I run this code item.DisplayName is in german language, which is my current os system language. When I uncomment CultureInfo.DefaultThreadCurrentUICulture = cu; item.DisplayName is in english language. At this point I would expect ja-JP version of Display name.

How to get the culture display name in thread' s current culture?

Stephan Ahlf
  • 3,310
  • 5
  • 39
  • 68
  • Possible duplicate of [How to translate CultureInfo language names](http://stackoverflow.com/questions/2432813/how-to-translate-cultureinfo-language-names) – Monticola Explorator Mar 24 '17 at 21:32

1 Answers1

0

You must install Japanese .NET Framework Language Pack.

Gurgen Sargsyan
  • 1,087
  • 15
  • 22