#694: Translations scaffolding
------------------------+----------------------
Reporter: olemis | Owner: olemis
Type: task | Status: assigned
Priority: minor | Milestone:
Component: trac core | Version: 0.7.0
Resolution: | Keywords: i18n
------------------------+----------------------
Comment (by SaintGermain):
> > 1. The "Source" string comes from the base.ini file, in the
> > [mainnav] section with the browser.label entry. If base.ini doesn't
> > define a name, then "Browser Source" is used and correctly
> > translated. As the user can enter any name he wants in base.ini, I
> > don't see any correction possible.
>
> Yes , I was noticing that too and thought that there was no hope , but
> then I spotted that Tickets tab label (default=View Tickets) is
> defined in config as well and it's definitely translated (e.g. see
> attached screenshots) and thereby this makes me wonder of whether we
> can get it translated in a similar manner .
>
Ah ! I found the reason.
'Tickets' is translated because we manually force it (even if a custom
name is defined in 'base.ini') in bhdashboard/web_ui.py:
{{{#!python
if item['name'] == 'tickets':
item['label'] = tag.a(_(self.mainnav_label),
href=req.href.dashboard())
}}}
However the default Trac behavior (defined in trac/web/chrome.py) is to
skip translation if a label is given in 'base.ini' :
{{{#!python
for category, name, text in \
contributor.get_navigation_items(req) or []:
category_section = self.config[category]
if category_section.getbool(name, True):
# the navigation item is enabled (this is the default)
item = None
if isinstance(text, Element) and \
text.tag.localname == 'a':
item = text
label = category_section.get(name + '.label')
href = category_section.get(name + '.href')
if href:
if href.startswith('/'):
href = req.href + href
if label:
item = tag.a(label) # create new label
elif not item:
item = tag.a(text) # wrap old text
item = item(href=href) # use new href
elif label and item: # create new label, use old href
item = tag.a(label, href=item.attrib.get('href'))
elif not item: # use old text
item = text
allitems.setdefault(category, {})[name] = item
}}}
I am not sure about the right behavior:
1. either we force translation in every case, even if there is a custom
label in base.ini (and maybe by chance we can find the translated string)
1. either we remove the current forced translation for 'Tickets' when a
custom label in base.ini (to have a consistent behavior between "Browse
Source" and "Tickets"
What do you think ?
--
Ticket URL: <https://issues.apache.org/bloodhound/ticket/694#comment:64>
Apache Bloodhound <https://issues.apache.org/bloodhound/>
The Apache Bloodhound issue tracker