0

Here is the line of code which help to find assembly for required culture:

Assembly.GetExecutingAssembly().GetSatelliteAssembly(new CultureInfo(cultureCode))

But how to find languages for which satellite assemblies exist for application, lets say if there are 3 language support for which 3 different folder created, now I want those folders and languages supported in it. I use this in drop down from where user can select language and drop down values should be dynamically loaded as per supported satellite assemblies.

4

1 回答 1

0

我已经通过以下解决方案解决了上述问题:

这将是基于以下陈述的解决方案之一:
特定语言的每个附属程序集都具有相同的名称,但位于以特定文化命名的子文件夹中,例如 fr 或 fr-CA。

public IEnumerable<CultureInfo> GetSupportedCulture()
{
    //Get all culture 
    CultureInfo[] culture = CultureInfo.GetCultures(CultureTypes.AllCultures);

    //Find the location where application installed.
    string exeLocation = Path.GetDirectoryName(Uri.UnescapeDataString(new UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path));

    //Return all culture for which satellite folder found with culture code.
    return culture.Where(cultureInfo => Directory.Exists(Path.Combine(exeLocation, cultureInfo.Name)));
}
于 2015-10-07T09:34:15.553 回答