I try to get the list of available Culture information, add them to a combobox and change the language on run time. My implementation acts different on different environments. There are some PCs where it works as expected, all the satellite assemblies are recognized, but on other PCs the same application does not recognize the available languages, only the default one (English).
This is my code where I try to find the available resource:
public static IEnumerable<CultureInfo> GetAvailableCultures()
{
List<CultureInfo> result = new List<CultureInfo>();
ResourceManager rm = new ResourceManager(typeof(PresentationResources));
CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
foreach (CultureInfo culture in cultures)
{
try
{
if (culture.Equals(CultureInfo.InvariantCulture))
{
continue;
}
ResourceSet rs = rm.GetResourceSet(culture, true, false);
if (rs != null)
{
result.Add(culture);
}
}
catch (CultureNotFoundException)
{
//NOP
}
}
return result;
}
Also the code from the xaml from where I try to change the language:
<ComboBox Name="LanguageComboBox"
SelectedIndex="{Binding SelectedLanguageIndex}"
ItemsSource="{Binding AvailableLanguages}"
DisplayMemberPath="NativeName"
SelectedItem="{Binding Source={x:Static lex:LocalizeDictionary.Instance},
Path=Culture}"
SelectionChanged="LanguageComboBox_OnSelectionChanged">
</ComboBox>
I don't really understand why the exactly same application on some environments works as expected and on other ones not.