Skip to content

Instantly share code, notes, and snippets.

@sergiogarciadev
Created July 15, 2011 00:46
Show Gist options
  • Save sergiogarciadev/1083816 to your computer and use it in GitHub Desktop.
Save sergiogarciadev/1083816 to your computer and use it in GitHub Desktop.
Small class to help handling working with diferent locales in the same system.
public class GinxCultureHelper : IDisposable
{
private readonly CultureInfo _currentUiCulture;
private readonly CultureInfo _currentCulture;
public GinxCultureHelper(string cultureName)
{
_currentCulture = Thread.CurrentThread.CurrentCulture;
_currentUiCulture = Thread.CurrentThread.CurrentUICulture;
var culture = new CultureInfo(cultureName);
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
}
public void Dispose()
{
Thread.CurrentThread.CurrentCulture = _currentCulture;
Thread.CurrentThread.CurrentUICulture = _currentUiCulture;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment