Loading ...
Sorry, an error occurred while loading the content.

[Cheetahtemplate-discuss] Internationalization with gettext

Expand Messages
  • Alec Matusis
    We re trying to translate our templates using Python s gettext module. ... http://www.cheetahtemplate.org/docs/users_guide_html_multipage/tips.gettext. html it
    Message 1 of 6 , Jan 19, 2011
    • 0 Attachment
      We're trying to translate our templates using Python's gettext module.

      >From reading
      http://www.cheetahtemplate.org/docs/users_guide_html_multipage/tips.gettext.
      html
      it appears that I need to mark text for translation like this:

      $_("This text will be translated")
      or like this
      $ngettext("This text will be translated")

      The templates with marked text compile. Running xgettext (or pygettext.py )
      on the compiled template successfully creates the .pot files, but the files
      does not contain the marked strings.

      Also, running the template produces the following error:

      File
      "/usr/local/lib/python2.4/site-packages/Cheetah-2.4.4-py2.4-linux-i686.egg/C
      heetah/NameMapper.py", line 246, in valueFromSearchList
      _raiseNotFoundException(key, searchList)
      File
      "/usr/local/lib/python2.4/site-packages/Cheetah-2.4.4-py2.4-linux-i686.egg/C
      heetah/NameMapper.py", line 167, in _raiseNotFoundException
      raise NotFound(excString)
      NotFound: cannot find '_'

      which means it cannot find _() function.
      Can anybody show me how to mark text for translation?

      I am using Cheetah 2.4.4 for these tests. We have Cheetah 0.9.15 in
      production, but I believe that 0.9.15 does not have gettext functionality at
      all- is that correct?


      ------------------------------------------------------------------------------
      Protect Your Site and Customers from Malware Attacks
      Learn about various malware tactics and how to avoid them. Understand
      malware threats, the impact they can have on your business, and how you
      can protect your company and customers by using code signing.
      http://p.sf.net/sfu/oracle-sfdevnl
      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
    • James Abbatiello
      I ve never used gettext with Cheetah but perhaps including a line like: #from gettext import gettext as _ at the top of your template might help? -- James
      Message 2 of 6 , Jan 19, 2011
      • 0 Attachment
        I've never used gettext with Cheetah but perhaps including a line like:
        #from gettext import gettext as _

        at the top of your template might help?

        --
        James Abbatiello

        On Wed, Jan 19, 2011 at 5:57 PM, Alec Matusis <matusis@...> wrote:
        We're trying to translate our templates using Python's gettext module.

        >From reading
        http://www.cheetahtemplate.org/docs/users_guide_html_multipage/tips.gettext.
        html

        it appears that I need to mark text for translation like this:

        $_("This text will be translated")
        or like this
        $ngettext("This text will be translated")

        The templates with marked text compile. Running xgettext (or pygettext.py )
        on the compiled template successfully creates the .pot files, but the files
        does not contain the marked strings.

        Also, running the template produces the following error:

         File
        "/usr/local/lib/python2.4/site-packages/Cheetah-2.4.4-py2.4-linux-i686.egg/C
        heetah/NameMapper.py", line 246, in valueFromSearchList
           _raiseNotFoundException(key, searchList)
         File
        "/usr/local/lib/python2.4/site-packages/Cheetah-2.4.4-py2.4-linux-i686.egg/C
        heetah/NameMapper.py", line 167, in _raiseNotFoundException
           raise NotFound(excString)
        NotFound: cannot find '_'

        which means it cannot find _() function.
        Can anybody show me how to mark text for translation?

        I am using Cheetah 2.4.4 for these tests. We have Cheetah 0.9.15 in
        production, but I believe that 0.9.15 does not have gettext functionality at
        all- is that correct?


        ------------------------------------------------------------------------------
        Protect Your Site and Customers from Malware Attacks
        Learn about various malware tactics and how to avoid them. Understand
        malware threats, the impact they can have on your business, and how you
        can protect your company and customers by using code signing.
        http://p.sf.net/sfu/oracle-sfdevnl
        _______________________________________________
        Cheetahtemplate-discuss mailing list
        Cheetahtemplate-discuss@...
        https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss

      • Alec Matusis
        That did not help. Earlier, I also tried to define function _() like so: #import gettext #t = gettext.translation( mymodule , /home/alec/gettexttest ,
        Message 3 of 6 , Jan 19, 2011
        • 0 Attachment
          That did not help.
          Earlier, I also tried to define function _() like so:

          #import gettext
          #t = gettext.translation('mymodule', '/home/alec/gettexttest', ('en-US',))
          #_ = t.gettext

          This code works in a stand-alone .py file.
          Cheetah however still does not find _() function, even with this code at the
          top.



          From: James Abbatiello [mailto:abbeyj@...]
          Sent: Wednesday, January 19, 2011 7:24 PM
          To: cheetahtemplate-discuss@...
          Subject: Re: [Cheetahtemplate-discuss] Internationalization with gettext

          I've never used gettext with Cheetah but perhaps including a line like:
          #from gettext import gettext as _

          at the top of your template might help?

          --
          James Abbatiello
          On Wed, Jan 19, 2011 at 5:57 PM, Alec Matusis <matusis@...> wrote:
          We're trying to translate our templates using Python's gettext module.

          >From reading
          http://www.cheetahtemplate.org/docs/users_guide_html_multipage/tips.gettext.
          html
          it appears that I need to mark text for translation like this:

          $_("This text will be translated")
          or like this
          $ngettext("This text will be translated")

          The templates with marked text compile. Running xgettext (or pygettext.py )
          on the compiled template successfully creates the .pot files, but the files
          does not contain the marked strings.

          Also, running the template produces the following error:

           File
          "/usr/local/lib/python2.4/site-packages/Cheetah-2.4.4-py2.4-linux-i686.egg/C
          heetah/NameMapper.py", line 246, in valueFromSearchList
             _raiseNotFoundException(key, searchList)
           File
          "/usr/local/lib/python2.4/site-packages/Cheetah-2.4.4-py2.4-linux-i686.egg/C
          heetah/NameMapper.py", line 167, in _raiseNotFoundException
             raise NotFound(excString)
          NotFound: cannot find '_'

          which means it cannot find _() function.
          Can anybody show me how to mark text for translation?

          I am using Cheetah 2.4.4 for these tests. We have Cheetah 0.9.15 in
          production, but I believe that 0.9.15 does not have gettext functionality at
          all- is that correct?


          ----------------------------------------------------------------------------
          --
          Protect Your Site and Customers from Malware Attacks
          Learn about various malware tactics and how to avoid them. Understand
          malware threats, the impact they can have on your business, and how you
          can protect your company and customers by using code signing.
          http://p.sf.net/sfu/oracle-sfdevnl
          _______________________________________________
          Cheetahtemplate-discuss mailing list
          Cheetahtemplate-discuss@...
          https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss



          ------------------------------------------------------------------------------
          Protect Your Site and Customers from Malware Attacks
          Learn about various malware tactics and how to avoid them. Understand
          malware threats, the impact they can have on your business, and how you
          can protect your company and customers by using code signing.
          http://p.sf.net/sfu/oracle-sfdevnl
          _______________________________________________
          Cheetahtemplate-discuss mailing list
          Cheetahtemplate-discuss@...
          https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
        • James Abbatiello
          If you want to include arbitrary Python code try using #silent like this: #import gettext #silent t = gettext.translation( mymodule , /home/alec/gettexttest ,
          Message 4 of 6 , Jan 19, 2011
          • 0 Attachment
            If you want to include arbitrary Python code try using #silent like this:

            #import gettext
            #silent t = gettext.translation('mymodule', '/home/alec/gettexttest', ('en-US',))
            #silent _ = t.gettext
            $_("This is some text")

            --
            James Abbatiello


            On Thu, Jan 20, 2011 at 1:09 AM, Alec Matusis <matusis@...> wrote:
            That did not help.
            Earlier, I also tried to define function _() like so:

            #import gettext
            #t = gettext.translation('mymodule', '/home/alec/gettexttest', ('en-US',))
            #_ = t.gettext

            This code works in a stand-alone .py file.
            Cheetah however still does not find _() function, even with this code at the
            top.



            From: James Abbatiello [mailto:abbeyj@...]
            Sent: Wednesday, January 19, 2011 7:24 PM
            To: cheetahtemplate-discuss@...
            Subject: Re: [Cheetahtemplate-discuss] Internationalization with gettext

            I've never used gettext with Cheetah but perhaps including a line like:
            #from gettext import gettext as _

            at the top of your template might help?

            --
            James Abbatiello
            On Wed, Jan 19, 2011 at 5:57 PM, Alec Matusis <matusis@...> wrote:
            We're trying to translate our templates using Python's gettext module.

            >From reading
            http://www.cheetahtemplate.org/docs/users_guide_html_multipage/tips.gettext.
            html

            it appears that I need to mark text for translation like this:

            $_("This text will be translated")
            or like this
            $ngettext("This text will be translated")

            The templates with marked text compile. Running xgettext (or pygettext.py )
            on the compiled template successfully creates the .pot files, but the files
            does not contain the marked strings.

            Also, running the template produces the following error:

             File
            "/usr/local/lib/python2.4/site-packages/Cheetah-2.4.4-py2.4-linux-i686.egg/C
            heetah/NameMapper.py", line 246, in valueFromSearchList
               _raiseNotFoundException(key, searchList)
             File
            "/usr/local/lib/python2.4/site-packages/Cheetah-2.4.4-py2.4-linux-i686.egg/C
            heetah/NameMapper.py", line 167, in _raiseNotFoundException
               raise NotFound(excString)
            NotFound: cannot find '_'

            which means it cannot find _() function.
            Can anybody show me how to mark text for translation?

            I am using Cheetah 2.4.4 for these tests. We have Cheetah 0.9.15 in
            production, but I believe that 0.9.15 does not have gettext functionality at
            all- is that correct?


            ----------------------------------------------------------------------------
            --
            Protect Your Site and Customers from Malware Attacks
            Learn about various malware tactics and how to avoid them. Understand
            malware threats, the impact they can have on your business, and how you
            can protect your company and customers by using code signing.
            http://p.sf.net/sfu/oracle-sfdevnl
            _______________________________________________
            Cheetahtemplate-discuss mailing list
            Cheetahtemplate-discuss@...
            https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss



          • Alec Matusis
            Same result with #silent: NotFound: cannot find _ I think this needs to be clarified, and an example needs to be added to
            Message 5 of 6 , Jan 20, 2011
            • 0 Attachment
              Same result with #silent:
              NotFound: cannot find '_'

              I think this needs to be clarified, and an example needs to be added to
              http://www.cheetahtemplate.org/docs/users_guide_html_multipage/tips.gettext.
              html
              Otherwise the internationalization feature is practically useless to many
              developers.

              From: James Abbatiello [mailto:abbeyj@...]
              Sent: Wednesday, January 19, 2011 10:27 PM
              To: cheetahtemplate-discuss@...
              Subject: Re: [Cheetahtemplate-discuss] Internationalization with gettext

              If you want to include arbitrary Python code try using #silent like this:

              #import gettext
              #silent t = gettext.translation('mymodule', '/home/alec/gettexttest',
              ('en-US',))
              #silent _ = t.gettext
              $_("This is some text")

              --
              James Abbatiello

              On Thu, Jan 20, 2011 at 1:09 AM, Alec Matusis <matusis@...> wrote:
              That did not help.
              Earlier, I also tried to define function _() like so:

              #import gettext
              #t = gettext.translation('mymodule', '/home/alec/gettexttest', ('en-US',))
              #_ = t.gettext

              This code works in a stand-alone .py file.
              Cheetah however still does not find _() function, even with this code at the
              top.



              From: James Abbatiello [mailto:abbeyj@...]
              Sent: Wednesday, January 19, 2011 7:24 PM
              To: cheetahtemplate-discuss@...
              Subject: Re: [Cheetahtemplate-discuss] Internationalization with gettext

              I've never used gettext with Cheetah but perhaps including a line like:
              #from gettext import gettext as _

              at the top of your template might help?

              --
              James Abbatiello
              On Wed, Jan 19, 2011 at 5:57 PM, Alec Matusis <matusis@...> wrote:
              We're trying to translate our templates using Python's gettext module.

              >From reading
              http://www.cheetahtemplate.org/docs/users_guide_html_multipage/tips.gettext.
              html
              it appears that I need to mark text for translation like this:

              $_("This text will be translated")
              or like this
              $ngettext("This text will be translated")

              The templates with marked text compile. Running xgettext (or pygettext.py )
              on the compiled template successfully creates the .pot files, but the files
              does not contain the marked strings.

              Also, running the template produces the following error:

               File
              "/usr/local/lib/python2.4/site-packages/Cheetah-2.4.4-py2.4-linux-i686.egg/C
              heetah/NameMapper.py", line 246, in valueFromSearchList
                 _raiseNotFoundException(key, searchList)
               File
              "/usr/local/lib/python2.4/site-packages/Cheetah-2.4.4-py2.4-linux-i686.egg/C
              heetah/NameMapper.py", line 167, in _raiseNotFoundException
                 raise NotFound(excString)
              NotFound: cannot find '_'

              which means it cannot find _() function.
              Can anybody show me how to mark text for translation?

              I am using Cheetah 2.4.4 for these tests. We have Cheetah 0.9.15 in
              production, but I believe that 0.9.15 does not have gettext functionality at
              all- is that correct?


              ----------------------------------------------------------------------------
              --
              Protect Your Site and Customers from Malware Attacks
              Learn about various malware tactics and how to avoid them. Understand
              malware threats, the impact they can have on your business, and how you
              can protect your company and customers by using code signing.
              http://p.sf.net/sfu/oracle-sfdevnl
              _______________________________________________
              Cheetahtemplate-discuss mailing list
              Cheetahtemplate-discuss@...
              https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss




              ------------------------------------------------------------------------------
              Protect Your Site and Customers from Malware Attacks
              Learn about various malware tactics and how to avoid them. Understand
              malware threats, the impact they can have on your business, and how you
              can protect your company and customers by using code signing.
              http://p.sf.net/sfu/oracle-sfdevnl
              _______________________________________________
              Cheetahtemplate-discuss mailing list
              Cheetahtemplate-discuss@...
              https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
            • James Abbatiello
              Can you post a complete minimal example that isn t working for you? -- James Abbatiello ... Special Offer-- Download ArcSight Logger for FREE (a $49 USD
              Message 6 of 6 , Jan 21, 2011
              • 0 Attachment
                Can you post a complete minimal example that isn't working for you?

                --
                James Abbatiello


                On Thu, Jan 20, 2011 at 2:06 PM, Alec Matusis <matusis@...> wrote:
                Same result with #silent:
                NotFound: cannot find '_'

                I think this needs to be clarified, and an example needs to be added to
                Otherwise the internationalization feature  is practically useless to many
                developers.

                From: James Abbatiello [mailto:abbeyj@...]
                Sent: Wednesday, January 19, 2011 10:27 PM
                To: cheetahtemplate-discuss@...
                Subject: Re: [Cheetahtemplate-discuss] Internationalization with gettext

                If you want to include arbitrary Python code try using #silent like this:

                #import gettext
                #silent t = gettext.translation('mymodule', '/home/alec/gettexttest',
                ('en-US',))
                #silent _ = t.gettext
                $_("This is some text")

                --
                James Abbatiello

                On Thu, Jan 20, 2011 at 1:09 AM, Alec Matusis <matusis@...> wrote:
                That did not help.
                Earlier, I also tried to define function _() like so:

                #import gettext
                #t = gettext.translation('mymodule', '/home/alec/gettexttest', ('en-US',))
                #_ = t.gettext

                This code works in a stand-alone .py file.
                Cheetah however still does not find _() function, even with this code at the
                top.



                From: James Abbatiello [mailto:abbeyj@...]
                Sent: Wednesday, January 19, 2011 7:24 PM
                To: cheetahtemplate-discuss@...
                Subject: Re: [Cheetahtemplate-discuss] Internationalization with gettext

                I've never used gettext with Cheetah but perhaps including a line like:
                #from gettext import gettext as _

                at the top of your template might help?

                --
                James Abbatiello
                On Wed, Jan 19, 2011 at 5:57 PM, Alec Matusis <matusis@...> wrote:
                We're trying to translate our templates using Python's gettext module.

                >From reading
                http://www.cheetahtemplate.org/docs/users_guide_html_multipage/tips.gettext.
                html

                it appears that I need to mark text for translation like this:

                $_("This text will be translated")
                or like this
                $ngettext("This text will be translated")

                The templates with marked text compile. Running xgettext (or pygettext.py )
                on the compiled template successfully creates the .pot files, but the files
                does not contain the marked strings.

                Also, running the template produces the following error:

                 File
                "/usr/local/lib/python2.4/site-packages/Cheetah-2.4.4-py2.4-linux-i686.egg/C
                heetah/NameMapper.py", line 246, in valueFromSearchList
                   _raiseNotFoundException(key, searchList)
                 File
                "/usr/local/lib/python2.4/site-packages/Cheetah-2.4.4-py2.4-linux-i686.egg/C
                heetah/NameMapper.py", line 167, in _raiseNotFoundException
                   raise NotFound(excString)
                NotFound: cannot find '_'

                which means it cannot find _() function.
                Can anybody show me how to mark text for translation?

                I am using Cheetah 2.4.4 for these tests. We have Cheetah 0.9.15 in
                production, but I believe that 0.9.15 does not have gettext functionality at
                all- is that correct?


                ----------------------------------------------------------------------------
                --
                Protect Your Site and Customers from Malware Attacks
                Learn about various malware tactics and how to avoid them. Understand
                malware threats, the impact they can have on your business, and how you
                can protect your company and customers by using code signing.
                http://p.sf.net/sfu/oracle-sfdevnl
                _______________________________________________
                Cheetahtemplate-discuss mailing list
                Cheetahtemplate-discuss@...
                https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss




              Your message has been successfully submitted and would be delivered to recipients shortly.