Asp – How to get all available culture names in ASP.NET application

asp.netasp.net-2.0localization

My ASP.NET application is localized (by using resources) to many cultures. What I need is to find all these cultures (in runtime) and for example fill a DropDownList.

I have code which does that in windows applications – buids collection of available cultures by seeking satellite assemblies.

But what about web apps? It's possibe to find satellite assemblies? Or this can be done some other way?

Any suggestions?

Thanks

Best Answer

Something like this should work for you ...

var ass = Assembly.GetExecutingAssembly();

foreach( var c in CultureInfo.GetCultures( 
  CultureTypes.SpecificCultures | 
  CultureTypes.NeutralCultures) ) 
{
  try 
  {
    var sat = ass.GetSatelliteAssembly( c );
    // Add to dropdown
   }
   catch( FileNotFoundException ) 
   {
   }
}
Related Topic