Setting current culture doesn't work

Vote:
 

Hi,

 

I have a multilanguage site. I want this site to display prices only in Danish kronam not depending on what language is actually chosen. In order to achieve this I tried following

            var currentCulture = new CultureInfo(CultureInfo.CurrentCulture.Name);

            currentCulture.NumberFormat.CurrencySymbol = "kr";
            currentCulture.NumberFormat.CurrencyPositivePattern = 3;
            currentCulture.NumberFormat.CurrencyNegativePattern = 3;

            CultureInfo.DefaultThreadCurrentCulture = currentCulture;
            CultureInfo.DefaultThreadCurrentUICulture = currentCulture;

 

inside initialization module:

[InitializableModule]
public class FilterConfig : IConfigurableModule

 

After executing the code CultureInfo.Current culture shows correct CurrencySymbol, but when I'm accessing the page it falls back to one that correspond current language. What am I doing wrong?

#85008
Apr 11, 2014 0:50
Vote:
 

I have two sites both added in episerver admin with different cultures.

If I use:

 

var currentCulture = new CultureInfo(System.Globalization.CultureInfo.CurrentCulture.Name);

var symbol = currentCulture.NumberFormat.CurrencySymbol;

 

symbol will change depending on culture set on your site.

 

Not sure why you need to do this in a InitializableModule? I might have missed something :-)

#85026
Apr 11, 2014 11:10
Vote:
 

No, I suppose I'm doing this incorrectly. Initialize module is really not the best place. But I want to change this thing in a culture automatically in order just to call .ToString("c")

#85189
Apr 16, 2014 16:56
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.