#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):

 Replying to [comment:68 olemis]:
 > Replying to [comment:66 SaintGermain]:
 > > For the forced translation of the 'Source' tab in the mainnav.
 > > Basically I have the genshi.builder.Element:
 > > <a href="/sqlite/wiki/Guide/RepositoryAdmin">Source</a>
 > >
 > > And I would like to replace the 'Source' with the translation.
 > >
 > > it seems that I can do something like:
 > > {{{#!python
 > > label = element.generate() |
 genshi.filters.transform.Transformer().select('a/text()')
 > > element.generate() |
 genshi.filters.transform.Transformer('a/text()').replace(gettext(label))
 > > }}}
 > >
 > > What do you think ?
 >
 > I do not recommend doing so . This is filtering the Genshi template
 stream and that has a substantial performance impact just to change a
 label that apparently should be translated somehow (e.g. see Tickets) .
 >
 > > It doesn't look very nice but I haven't found any other simpler way.
 > >
 >
 > What about if a translation for ''Source'' is provided in the same
 catalog where ''Tickets'' is been translated ?
 >

 I am not 100% sure but I think this is not the problem.

 In trac/web/chrome.py (see comment 64), label are retrieved and translated
 except if there is an overriding label in base.ini (for instance 'Tickets'
 and 'Source').
 Bloodhound take the data as it is ('Ticket' and 'Source') except for
 "Tickets" which got a special treatment (replace the href) which has a
 side result of translating 'Ticket' because we force the translation:
 {{{#!python
 if item['name'] == 'tickets':
     item['label'] = tag.a(_(self.mainnav_label),
 href=req.href.dashboard())
 }}}
 If you want to have the same result for 'Source', we have also to
 duplicate that code for 'Source' (except that in our case we don't want to
 change the href, we just want to replace 'Source' by its translation).

 It is my interpretation (I can be wrong). I can use a regexp to replace
 the 'Source' if you think it will be more efficient than genshi filters ?

-- 
Ticket URL: <https://issues.apache.org/bloodhound/ticket/694#comment:70>
Apache Bloodhound <https://issues.apache.org/bloodhound/>
The Apache Bloodhound issue tracker

Reply via email to