コード例 #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
ファイル: test_i18n.py プロジェクト: nagareproject/core
    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
ファイル: app.py プロジェクト: ephilippot/eureka-opensource
    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
ファイル: usermanager.py プロジェクト: Net-ng/kansha
 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
ファイル: usermanager.py プロジェクト: gpaugam/kansha
 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
ファイル: comp.py プロジェクト: droodle/eureka-opensource
 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
ファイル: comp.py プロジェクト: droodle/eureka-opensource
 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))