Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
specific_locale context manager
import contextlib
import locale
@contextlib.contextmanager
def specific_locale(category, locale_string):
prev_locale_string = locale.getlocale(category)
locale.setlocale(category, locale_string)
try:
yield
finally:
locale.setlocale(category, prev_locale_string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.