Python i18n using pygettext.py

I start with localization, but I'm stuck.

  • Program

    #example.py import gettext t = gettext.translation('cn', 'C:\locale', fallback=True) _ = t.ugettext print _('Hello!') 

    works.

  • But when trying to use pygettext

     python pygettext.py -d cn -o cn.pot example.py 

    I get the message "invalid syntax:<string>, line 1, pos 18

I tried even the simplest pygettest command:

 python pygettext.py example.py 

which returns the same error. I tried with other other settings and changes in the program, but this error keeps coming back.

As an example, I used the code http://achilles-keep-moving.blogspot.nl/2011/07/minimal-tutorial-for-python.html

What am I doing wrong?

+4
source share
1 answer

You should avoid the \ character in the string, for example, 'C:\\foo.bar' or r'C:\foo.bar' .

0
source

Source: https://habr.com/ru/post/1489977/


All Articles