Skip to content

Commit

Permalink
Merge branch 'new_i18n_settings' into new_i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
digi604 committed Oct 3, 2012
2 parents a204712 + 203125e commit 422ceaa
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions cms/utils/i18n.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# -*- coding: utf-8 -*-
from contextlib import contextmanager
from django.conf import settings
from django.utils import translation

class force_language(object):
def __init__(self, new_lang):
self.new_lang = new_lang
self.old_lang = translation.get_language()

def __enter__(self):
translation.activate(self.new_lang)

def __exit__(self, type, value, tb):
translation.activate(self.old_lang)
@contextmanager
def force_language(new_lang):
old_lang = translation.get_language()
translation.activate(new_lang)
yield
translation.activate(old_lang)


def get_language_list(site_id=None):
Expand Down

0 comments on commit 422ceaa

Please sign in to comment.