<bdo id='7E9dd'></bdo><ul id='7E9dd'></ul>
  • <small id='7E9dd'></small><noframes id='7E9dd'>

    1. <i id='7E9dd'><tr id='7E9dd'><dt id='7E9dd'><q id='7E9dd'><span id='7E9dd'><b id='7E9dd'><form id='7E9dd'><ins id='7E9dd'></ins><ul id='7E9dd'></ul><sub id='7E9dd'></sub></form><legend id='7E9dd'></legend><bdo id='7E9dd'><pre id='7E9dd'><center id='7E9dd'></center></pre></bdo></b><th id='7E9dd'></th></span></q></dt></tr></i><div id='7E9dd'><tfoot id='7E9dd'></tfoot><dl id='7E9dd'><fieldset id='7E9dd'></fieldset></dl></div>

        <legend id='7E9dd'><style id='7E9dd'><dir id='7E9dd'><q id='7E9dd'></q></dir></style></legend>
      1. <tfoot id='7E9dd'></tfoot>
      2. 获取所有可用语言的编程方式(在附属程序集中

        时间:2023-08-27
        <legend id='NFocI'><style id='NFocI'><dir id='NFocI'><q id='NFocI'></q></dir></style></legend>
          <tfoot id='NFocI'></tfoot>
          • <bdo id='NFocI'></bdo><ul id='NFocI'></ul>

                <small id='NFocI'></small><noframes id='NFocI'>

                <i id='NFocI'><tr id='NFocI'><dt id='NFocI'><q id='NFocI'><span id='NFocI'><b id='NFocI'><form id='NFocI'><ins id='NFocI'></ins><ul id='NFocI'></ul><sub id='NFocI'></sub></form><legend id='NFocI'></legend><bdo id='NFocI'><pre id='NFocI'><center id='NFocI'></center></pre></bdo></b><th id='NFocI'></th></span></q></dt></tr></i><div id='NFocI'><tfoot id='NFocI'></tfoot><dl id='NFocI'><fieldset id='NFocI'></fieldset></dl></div>

                    <tbody id='NFocI'></tbody>
                • 本文介绍了获取所有可用语言的编程方式(在附属程序集中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用 .resx 文件设计一个多语言应用程序.

                  I'm designing a multilingual application using .resx files.

                  我有一些文件,例如 GlobalStrings.resx、GlobalStrings.es.resx、GlobalStrings.en.resx 等.当我想使用它时,我只需要设置 Thread.CurrentThread.CurrentCulture.

                  I have a few files like GlobalStrings.resx, GlobalStrings.es.resx, GlobalStrings.en.resx, etc. When I want to use this, I just need to set Thread.CurrentThread.CurrentCulture.

                  问题:我有一个包含所有可用语言的组合框,但我是手动加载的:

                  The problem: I have a combobox with all the available languages, but I'm loading this manually:

                  comboLanguage.Items.Add(CultureInfo.GetCultureInfo("en"));
                  comboLanguage.Items.Add(CultureInfo.GetCultureInfo("es"));
                  

                  我试过了

                  cmbLanguage.Items.AddRange(CultureInfo.GetCultures(CultureTypes.UserCustomCulture));
                  

                  没有任何成功.还尝试了 CultureTypes 中的所有元素,但我只得到一个包含更多我没有使用的语言的大列表,或者一个空列表.

                  without any success. Also tried with all the elements in CultureTypes, but I'm only getting a big list with a lot more languages that I'm not using, or an empty list.

                  有没有办法只获得支持的语言?

                  Is there any way to get only the supported languages?

                  推荐答案

                  使用 Rune Grimstad 所说的,我最终得到了这个:

                  Using what Rune Grimstad said I end up with this:

                  string executablePath = Path.GetDirectoryName(Application.ExecutablePath);
                  string[] directories = Directory.GetDirectories(executablePath);
                  foreach (string s in directories)
                  {
                      try
                      {
                          DirectoryInfo langDirectory = new DirectoryInfo(s);
                          cmbLanguage.Items.Add(CultureInfo.GetCultureInfo(langDirectory.Name));
                      }
                      catch (Exception)
                      {
                  
                      }
                  }
                  

                  或者其他方式

                  int pathLenght = executablePath.Length + 1;
                  foreach (string s in directories)
                  {
                      try
                      {
                          cmbLanguage.Items.Add(CultureInfo.GetCultureInfo(s.Remove(0, pathLenght)));
                      }
                      catch (Exception)
                      {
                  
                      }
                  }
                  

                  我还是觉得这不是个好主意……

                  I still don't think that this is a good idea ...

                  这篇关于获取所有可用语言的编程方式(在附属程序集中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在 Javascript 中本地化字符串 下一篇:如何在 WPF 中设置和更改区域性

                  相关文章

                  最新文章

                    <tfoot id='p6k0d'></tfoot>

                      • <bdo id='p6k0d'></bdo><ul id='p6k0d'></ul>
                    1. <small id='p6k0d'></small><noframes id='p6k0d'>

                      <legend id='p6k0d'><style id='p6k0d'><dir id='p6k0d'><q id='p6k0d'></q></dir></style></legend>
                    2. <i id='p6k0d'><tr id='p6k0d'><dt id='p6k0d'><q id='p6k0d'><span id='p6k0d'><b id='p6k0d'><form id='p6k0d'><ins id='p6k0d'></ins><ul id='p6k0d'></ul><sub id='p6k0d'></sub></form><legend id='p6k0d'></legend><bdo id='p6k0d'><pre id='p6k0d'><center id='p6k0d'></center></pre></bdo></b><th id='p6k0d'></th></span></q></dt></tr></i><div id='p6k0d'><tfoot id='p6k0d'></tfoot><dl id='p6k0d'><fieldset id='p6k0d'></fieldset></dl></div>