Edgewall Software

Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#11515 closed defect (fixed)

Acknowledgement message is not localized when changing language — at Version 5

Reported by: Ryan J Ollos Owned by: Jun Omae
Priority: normal Milestone: 1.0.2
Component: i18n Version:
Severity: normal Keywords:
Cc: Jun Omae Branch:
Release Notes:

Show acknowledgement message with new language setting when changed in user preferences.

API Changes:
Internal Changes:

Description

When changing languages through the preferences admin page, the notification message is displayed in the previous language:

English → French

French → English

Change History (7)

by Ryan J Ollos, 10 years ago

Attachment: EnglishToFrancais.png added

by Ryan J Ollos, 10 years ago

Attachment: FrancaisToEnglish.png added

comment:1 by Jun Omae, 10 years ago

Ad-hoc patch.

  • trac/prefs/web_ui.py

    diff --git a/trac/prefs/web_ui.py b/trac/prefs/web_ui.py
    index 5a428c2..cdc1867 100644
    a b from genshi.builder import tag  
    2727from trac.core import *
    2828from trac.prefs.api import IPreferencePanelProvider
    2929from trac.util.datefmt import all_timezones, get_timezone, localtz
    30 from trac.util.translation import _, get_available_locales
    31 from trac.web import HTTPNotFound, IRequestHandler
     30from trac.util.translation import _, deactivate, get_available_locales, \
     31                                  make_activable
     32from trac.web.api import HTTPNotFound, IRequestHandler
    3233from trac.web.chrome import add_notice, add_stylesheet, \
    3334                            INavigationContributor, ITemplateProvider
     35from trac.web.main import RequestDispatcher
    3436
    class PreferencesModule(Component):  
    148150        req.send_no_content()
    149151
    150152    def _do_save(self, req):
     153        language = req.session.get('language')
    151154        for field in self._form_fields:
    152155            val = req.args.get(field, '').strip()
    153156            if val:
    class PreferencesModule(Component):  
    163166            elif field in req.session and (field in req.args or
    164167                                           field + '_cb' in req.args):
    165168                del req.session[field]
     169        if req.session.get('language') != language:
     170            # reactivate translations with new language setting when changed
     171            locale = RequestDispatcher(self.env)._get_locale(req)
     172            deactivate()
     173            make_activable(lambda: locale, self.env.path)
    166174        add_notice(req, _('Your preferences have been saved.'))
    167175
    168176    def _do_load(self, req):
Last edited 10 years ago by Jun Omae (previous) (diff)

comment:2 by Jun Omae, 10 years ago

Cc: Jun Omae added

I've revised the patch and added functional tests, jomae.git@t11515.

comment:3 by Ryan J Ollos, 10 years ago

Thanks for the quick fix. The changes work well for me.

comment:4 by Jun Omae, 10 years ago

Milestone: next-stable-1.0.x1.0.2
Owner: set to Jun Omae
Status: newassigned

Thanks for testing. I'll push the changes later.

comment:5 by Jun Omae, 10 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed in [12578] and merged to trunk in [12579].

Note: See TracTickets for help on using tickets.