Edgewall Software
Modify

Opened 6 years ago

Closed 6 years ago

#13052 closed defect (fixed)

No extracted strings from report_view.html

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone: 1.3.3
Component: i18n Version:
Severity: normal Keywords: jinja2
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

report_view.html has several _('...') to translate the string, but messages.pot has no strings from the template file.

$ git grep '\<_(' -- trac/ticket/templates/report_view.html
trac/ticket/templates/report_view.html:              ${_("Max items per page")}
trac/ticket/templates/report_view.html:              <legend class="foldable">${_("Arguments")}</legend>
trac/ticket/templates/report_view.html:              <table summary="${_('Report arguments')}">
trac/ticket/templates/report_view.html:            <input type="submit" value="${_('Update')}" />
trac/ticket/templates/report_view.html:            <input type="submit" value="${_('Edit report')}" ${accesskey("e")}/>
trac/ticket/templates/report_view.html:            <input type="submit" value="${_('Copy report')}" />
trac/ticket/templates/report_view.html:            <input type="submit" value="${_('Delete report')}" />
trac/ticket/templates/report_view.html:        ${_("Results")}
trac/ticket/templates/report_view.html:        <a href="${row_group[0]['__grouplink__']}">${value_for_group or _("(empty)")}</a>
trac/ticket/templates/report_view.html:        ${value_for_group or _("(empty)")}
trac/ticket/templates/report_view.html:          else _("No matches found.")})
trac/ticket/templates/report_view.html:              <a title="${_('View report')}"
trac/ticket/templates/report_view.html:              <a title="${_('View %(realm)s', realm=row.resource.realm)}"
trac/ticket/templates/report_view.html:              <a title="${_('View %(realm)s', realm=row.resource.realm)}"
trac/ticket/templates/report_view.html:              <a title="${_('View milestone')}"
trac/ticket/templates/report_view.html:      <div id="report-notfound">${_("No matches found.")}</div>
$ grep -c '/report_view' trac/locale/messages.pot
0
$ grep -c 'Copy report' trac/locale/messages.pot
0

Attachments (0)

Change History (3)

comment:1 by Jun Omae, 6 years ago

Owner: set to Jun Omae
Status: newassigned

After silent = no option is added in messages.cfg, I get the following error:

Traceback (most recent call last):
  File "setup.py", line 163, in <module>
    **extra
  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/venv/py27/local/lib/python2.7/site-packages/babel/messages/frontend.py", line 467, in run
    for filename, lineno, message, comments, context in extracted:
  File "/venv/py27/local/lib/python2.7/site-packages/babel/messages/extract.py", line 157, in extract_from_dir
    dirpath=absname,
  File "/venv/py27/local/lib/python2.7/site-packages/babel/messages/extract.py", line 212, in check_and_call_extract_file
    strip_comment_tags=strip_comment_tags
  File "/venv/py27/local/lib/python2.7/site-packages/babel/messages/extract.py", line 241, in extract_from_file
    strip_comment_tags))
  File "/venv/py27/local/lib/python2.7/site-packages/babel/messages/extract.py", line 322, in extract
    for lineno, funcname, messages, comments in results:
  File "/src/tracdev/git/trac/dist.py", line 322, in extract_html
    for m in extractor(fileobj, keywords, comment_tags, options):
  File "/venv/py27/local/lib/python2.7/site-packages/jinja2/ext.py", line 609, in babel_extract
    node = environment.parse(source)
  File "/venv/py27/local/lib/python2.7/site-packages/jinja2/environment.py", line 493, in parse
    self.handle_exception(exc_info, source_hint=source)
  File "/venv/py27/local/lib/python2.7/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "<unknown>", line 216, in template
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'do'. Jinja was looking for the following tags: 'elif' or 'else' or 'endif'. The innermost block that needs to be closed is 'if'.
Makefile:202: recipe for target 'extract' failed
make: *** [extract] Error 1

It seems that Jinja2 extractor cannot understand do keyword which is introduced in r16361.

Ah, that's my wrong!

The strings from report_view.html would be extracted by the following changes:

  • messages.cfg

    diff --git a/messages.cfg b/messages.cfg
    index ea8d6c930..0ae9d5b47 100644
    a b  
    66[python: **.py]
    77
    88[html: **/templates/**.html]
    9 extensions = jinja2.ext.with_
     9extensions = jinja2.ext.do, jinja2.ext.with_
    1010variable_start_string = ${
    1111variable_end_string = }
    1212line_statement_prefix = #
    line_comment_prefix = ##  
    1414trim_blocks = yes
    1515lstrip_blocks = yes
    1616newstyle_gettext = yes
     17silent = no
    1718
    1819[text: **/templates/**.txt]
    19 extensions = jinja2.ext.with_
     20extensions = jinja2.ext.do, jinja2.ext.with_
    2021variable_start_string = ${
    2122variable_end_string = }
    2223line_statement_prefix = #
    line_comment_prefix = ##  
    2425trim_blocks = yes
    2526lstrip_blocks = yes
    2627newstyle_gettext = yes
     28silent = no
    2729
    2830[extractors]
    2931python = trac.dist:extract_python

comment:2 by Ryan J Ollos, 6 years ago

The changes look good.

comment:3 by Jun Omae, 6 years ago

Resolution: fixed
Status: assignedclosed

Thanks for the reviewing. Committed in [16694] and extract messages in [16695].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.