예제 #1
0
    def test_context_manager(self):
        locale1 = i18n.Locale('fr', 'FR', domain='domain1')
        locale2 = i18n.Locale('fr', 'FR', domain='domain2')

        i18n.set_locale(locale1)
        self.assertEqual(i18n.get_locale().domain, 'domain1')

        with locale2:
            self.assertEqual(i18n.get_locale().domain, 'domain2')
            with locale2:
                self.assertEqual(i18n.get_locale().domain, 'domain2')

        self.assertEqual(i18n.get_locale().domain, 'domain1')
예제 #2
0
    def test_context_manager(self):
        locale1 = i18n.Locale('fr', 'FR', domain='domain1')
        locale2 = i18n.Locale('fr', 'FR', domain='domain2')

        i18n.set_locale(locale1)
        self.assertEqual(i18n.get_locale().domain, 'domain1')

        with locale2:
            self.assertEqual(i18n.get_locale().domain, 'domain2')
            with locale2:
                self.assertEqual(i18n.get_locale().domain, 'domain2')

        self.assertEqual(i18n.get_locale().domain, 'domain1')
예제 #3
0
def test_context_manager():
    locale1 = i18n.Locale('fr', 'FR', domain='domain1')
    locale2 = i18n.Locale('fr', 'FR', domain='domain2')

    i18n.set_locale(locale1)
    assert i18n.get_locale().domain == 'domain1'

    with locale2:
        assert i18n.get_locale().domain == 'domain2'
        with locale2:
            assert i18n.get_locale().domain == 'domain2'

    assert i18n.get_locale().domain == 'domain1'
예제 #4
0
 def create_user(self,
                 username,
                 password,
                 fullname,
                 email,
                 source=u'application',
                 picture=None,
                 create_board=True):
     from ..authentication.database import forms
     from ..board.boardsmanager import BoardsManager
     user = DataUser(username,
                     password,
                     fullname,
                     email,
                     source,
                     picture,
                     language=i18n.get_locale().language)
     token_gen = forms.TokenGenerator(email, u'invite board')
     for token in token_gen.get_tokens():
         if token_gen.check_token(token.token) and token.board:
             user.add_board(token.board)
         token_gen.reset_token(token.token)
     if create_board:
         BoardsManager().create_board(u"Welcome Board", user, True)
     return user
예제 #5
0
    def _save_locale(self, response):
        language = i18n.get_locale().language
        response.set_cookie('language', language, max_age=timedelta(days=365))

        current_user = get_current_user()
        if current_user:
            current_user.locale = language
예제 #6
0
    def _save_locale(self, response):
        language = i18n.get_locale().language
        response.set_cookie("language", language, max_age=timedelta(days=365))

        current_user = get_current_user()
        if current_user:
            current_user.locale = language
예제 #7
0
파일: comp.py 프로젝트: Net-ng/kansha
    def get_locale(self):
        locale = i18n.Locale(self.data.language)

        # At this point, the locale object only knows about builtin Nagare translation directories
        # We need to register Kansha's translation directories too (get them from the current locale)
        locale.translation_directories.update(i18n.get_locale().translation_directories)

        return locale
예제 #8
0
파일: comp.py 프로젝트: amatthi/mazik
    def get_locale(self):
        locale = i18n.Locale(self.data.language)

        # At this point, the locale object only knows about builtin Nagare translation directories
        # We need to register Kansha's translation directories too (get them from the current locale)
        locale.translation_directories.update(
            i18n.get_locale().translation_directories)

        return locale
예제 #9
0
def test_context_manager():
    locale1 = i18n.Locale('fr', 'FR', domain='domain1')
    locale2 = i18n.Locale('fr', 'FR', domain='domain2')
    i18n.set_locale(locale1)
    assert i18n.get_locale().domain == 'domain1', i18n.get_locale().domain
    with locale2:
        assert i18n.get_locale().domain == 'domain2', i18n.get_locale().domain
        with locale2:
            assert i18n.get_locale().domain == 'domain2', i18n.get_locale().domain

    assert i18n.get_locale().domain == 'domain1', i18n.get_locale().domain
예제 #10
0
 def create_user(self, username, password, fullname, email,
                 source=u'application', picture=None):
     from kansha.authentication.database import forms
     user = DataUser(username, password, fullname, email,
                     source, picture, language=i18n.get_locale().language)
     token_gen = forms.TokenGenerator(email, u'invite board')
     for token in token_gen.get_tokens():
         if token_gen.check_token(token.token) and token.board:
             user.add_board(token.board)
         token_gen.reset_token(token.token)
     return user
예제 #11
0
 def create_user(self, username, password, fullname, email,
                 source=u'application', picture=None):
     from kansha.authentication.database import forms
     user = DataUser(username, password, fullname, email,
                     source, picture, language=i18n.get_locale().language)
     token_gen = forms.TokenGenerator(email, u'invite board')
     for token in token_gen.get_tokens():
         if token_gen.check_token(token.token) and token.board:
             token.board.add_member(user)
         token_gen.reset_token(token.token)
     return user
예제 #12
0
 def create_user(self, username, password, fullname, email,
                 source=u'application', picture=None, create_board=True):
     from ..authentication.database import forms
     from ..board.boardsmanager import BoardsManager
     user = DataUser(username, password, fullname, email,
                     source, picture, language=i18n.get_locale().language)
     token_gen = forms.TokenGenerator(email, u'invite board')
     for token in token_gen.get_tokens():
         if token_gen.check_token(token.token) and token.board:
             user.add_board(token.board)
         token_gen.reset_token(token.token)
     if create_board:
         BoardsManager().create_board(u"Welcome Board", user, True)
     return user
예제 #13
0
 def language(self, language):
     locale_info = (language, None)
     locale_dir = i18n.get_locale().dirname
     domain = i18n.get_locale().domain
     i18n.set_locale(
         i18n.Locale(*locale_info, domain=domain, dirname=locale_dir))
예제 #14
0
 def language(self, language):
     locale_info = (language, None)
     locale_dir = i18n.get_locale().dirname
     domain = i18n.get_locale().domain
     i18n.set_locale(i18n.Locale(*locale_info, domain=domain, dirname=locale_dir))
예제 #15
0
 def language(self):
     return i18n.get_locale().language
예제 #16
0
 def language(self):
     return i18n.get_locale().language
예제 #17
0
 def xml_file(self):
     language = i18n.get_locale().language
     return resource_stream(os.path.join('data', 'staticcontent', language, self.filename))