Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #2180 (closed defect: fixed)

Opened 10 years ago

Last modified 10 years ago

Messages translated lazily are not extracted by default

Reported by: Gustavo Owned by: faide
Priority: high Milestone: 2.0b6
Component: TurboGears Version: trunk
Severity: normal Keywords: i18n, l10n
Cc:

Description

If I use pylons.i18n.lazy_gettext instead of pylons.i18n.gettext, the messages won't get extracted by default. This occurs will the lazy edition of gettext and the others.

A workaround is extract them with:

python setup.py extract_messages --keywords lazy_gettext

Change History

comment:1 follow-up: ↓ 2 Changed 10 years ago by mramm

  • Status changed from new to closed
  • Resolution set to fixed

Is there something that needs to be changed in the tg project's quickstart template, or in Pylons, or is this just something that just needs to be documented?

I note that the pylons docs stress the avoidance of lazy_gettext where possible. Seems like this is needed for repoze.what, do we need it anywhere else?

comment:2 in reply to: ↑ 1 Changed 10 years ago by Gustavo

Replying to mramm:

Is there something that needs to be changed in the tg project's quickstart template, or in Pylons, or is this just something that just needs to be documented?

A quick solution is to add that switch in the setup.cfg file of the quickstarted application once #2179 gets fixed with lazy translations. Also documenting it may be useful for some people.

I note that the pylons docs stress the avoidance of lazy_gettext where possible. Seems like this is needed for repoze.what, do we need it anywhere else?

By default, only in repoze.what predicates because in TurboGears they are defined at module level and shared among threads. The only way we can avoid it in multilingual websites work-around would be to define it inside the controller action:

@expose(...)
def my_action(self, param):
    not_anonymous(msg=_('This message *will* get translated')).check_authorization(environ)
    pass
# instead of the traditional:
@expose(...)
@require(not_anonymous(msg=_('This message will not get translated')))
def my_action(self, param):
    pass

... a rather ugly solution.

Option C will be do nothing and just document this issue for people who are creating a multilingual website and want authorization denial messages to be translatable.

comment:3 Changed 10 years ago by Gustavo

I fixed this in the quickstart template ([6315]).

Note: See TracTickets for help on using tickets.