I am trying to implement an internationalization library. I created it and it was working fine but i have one problem. public static void SetCurrentLanguage(string language) {
if (m_resourceManager == null)
{
CultureInfo cultInfo = new CultureInfo(language);
Thread.CurrentThread.CurrentCulture = cultInfo;
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
m_resourceManager = ResourceManager.CreateFileBasedResourceManager("Globalization", m_path, null);
}
The above function is called twice with two different function. When it is called from first function we setCurrentLanguage(de-DE) and it works well. but when we call the function second time it gives me the result in (en-EN) beacuse culture is not set second time due m_resourceManager is not null.
What i want that if i set first time cultureInfo class with de-DE language for second call also it should be set.
I am stuck at this point. Can anyone please help me with that ?
Thanks In Advance
Cant you rearrange the method to something like so?
public static void SetCurrentLanguage(string language) {
CultureInfo cultInfo = new CultureInfo(language);
Thread.CurrentThread.CurrentCulture = cultInfo;
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
if (m_resourceManager == null)
{
m_resourceManager = ResourceManager.CreateFileBasedResourceManager("Globalization", m_path, null);
}
}
So you just create the resource manager when it's null but still change the cultureinfo everytime the function is called.