[Python-Dev] The "i" string-prefix: I18n'ed strings

Martin Blais blais at furius.ca
Fri Apr 7 16:38:33 CEST 2006


On 4/7/06, Alexander Schremmer <2005a at usenet.alexanderweb.de> wrote:
> On Fri, 7 Apr 2006 10:07:26 -0400, Martin Blais wrote:
>
> > There are cases where you need N_() after initialization, so you need
> > both, really.  See the link I sent to Alex earlier (to the GNU manual
> > example).
>
> On the page you were referring to, I cannot find a particular use case that
> does not work with the idea sketched above.

Okie.  Here's one example from actual code:


  class EventEdit(EventEditPages):

      def handle( self, ctxt ):
          ...
          # Render special activate/deactivate button.
          if ctxt.event.state == 'a':
              future_state = u's'
              actstr = N_('Deactivate')
          else:
              future_state = u'a'
              actstr = N_('Activate')

          values = {'state': future_state}
          rdrbutton = HoutFormRenderer(form__state_set, values)
          page.append(rdrbutton.render(submit=actstr))


HoutFormRenderer.render() expects non-translated strings, and it
performs the gettext lookup itself (this is a general library-wide
policy for all widget labels).

(This is just one example.  I have many other use cases like this.)


More information about the Python-Dev mailing list