i18n troubles

I have finally realized the need to implement internationalization in my application, so I set up gettext. However, I am getting an error when I try running my application.

Traceback (most recent call last):
File “C:\Saketh\source\Notalon\Notalon.py”, line 36, in ?
self.lan_en = gettext.translation(‘Notalon’, ‘./locale’, languages=[‘en’])
File “C:\Python24\lib\gettext.py”, line 456, in translation

raise IOError(ENOENT, 'No translation file found for domain', domain)

IOError: [Errno 2] No translation file found for domain: ‘Notalon’

I think this is because the mki18n.py does not generate the English translation MO files for some reason. Even when I use python mki18n.py -m -e (and there is a Notalon_en_EN.po file), the English translation is not generated. French files are generated fine, though.

Here’s the important part of my code:

gettext.install(‘Notalon’, ‘./locale’, unicode=True)
self.lan_en = gettext.translation(‘Notalon’, ‘./locale’, languages=[‘en’])
self.lan_fr = gettext.translation(‘Notalon’, ‘./locale’, languages=[‘fr’])
self.lan_en.install
()

Would it work if I used the wx interface to gettext? I would have been able to figure out what’s going on if the French files weren’t generated. But since they are, I am unable to narrow down the problem.

I’m probably going to have many problems with i18n, so please bear with me…thanks!

Never mind the above error - it was a silly directory mistake.

I still have a question. Let’s say I have a fully translated PO file. If I generate a new messages.pot, can I just copy in the old PO file entries into the new one? Or is there something special about the order of the entries in the PO files that might break if I copy and paste?

···

On 8/14/06, Saketh Bhamidipati saketh.bhamidipati@gmail.com wrote:

I have finally realized the need to implement internationalization in my application, so I set up gettext. However, I am getting an error when I try running my application.

Traceback (most recent call last):
File “C:\Saketh\source\Notalon\Notalon.py”, line 36, in ?
self.lan_en = gettext.translation(‘Notalon’, ‘./locale’, languages=[‘en’])
File “C:\Python24\lib\gettext.py”, line 456, in translation

raise IOError(ENOENT, 'No translation file found for domain', domain)

IOError: [Errno 2] No translation file found for domain: ‘Notalon’

I think this is because the mki18n.py does not generate the English translation MO files for some reason. Even when I use python mki18n.py -m -e (and there is a Notalon_en_EN.po file), the English translation is not generated. French files are generated fine, though.

Here’s the important part of my code:

gettext.install(‘Notalon’, ‘./locale’, unicode=True)
self.lan_en = gettext.translation(‘Notalon’, ‘./locale’, languages=[‘en’])
self.lan_fr = gettext.translation(‘Notalon’, ‘./locale’, languages=[‘fr’])

self.lan_en.install
()

Would it work if I used the wx interface to gettext? I would have been able to figure out what’s going on if the French files weren’t generated. But since they are, I am unable to narrow down the problem.

I’m probably going to have many problems with i18n, so please bear with me…thanks!

poEdit can do these things.

···

On 8/15/06, Saketh Bhamidipati <saketh.bhamidipati@gmail.com> wrote:

On 8/14/06, Saketh Bhamidipati <saketh.bhamidipati@gmail.com> wrote:
>
> I have finally realized the need to implement internationalization in my
application, so I set up gettext. However, I am getting an error when I try
running my application.
>
> Traceback (most recent call last):
> File "C:\Saketh\source\Notalon\Notalon.py", line 36, in
?
> self.lan_en = gettext.translation('Notalon', './locale',
languages=['en'])
> File "C:\Python24\lib\gettext.py", line 456, in translation
> raise IOError(ENOENT, 'No translation file found for domain', domain)
> IOError: [Errno 2] No translation file found for domain: 'Notalon'
>
> I think this is because the mki18n.py does not generate the English
translation MO files for some reason. Even when I use python mki18n.py -m -e
(and there is a Notalon_en_EN.po file), the English translation is not
generated. French files are generated fine, though.
>
> Here's the important part of my code:
>
> gettext.install('Notalon', './locale', unicode=True)
> self.lan_en = gettext.translation('Notalon', './locale', languages=['en'])
> self.lan_fr = gettext.translation('Notalon', './locale', languages=['fr'])
> self.lan_en.install ()
>
> Would it work if I used the wx interface to gettext? I would have been
able to figure out what's going on if the French files weren't generated.
But since they are, I am unable to narrow down the problem.
>
> I'm probably going to have many problems with i18n, so please bear with
me...thanks!
>
Never mind the above error - it was a silly directory mistake.

I still have a question. Let's say I have a fully translated PO file. If I
generate a new messages.pot, can I just copy in the old PO file entries into
the new one? Or is there something special about the order of the entries in
the PO files that might break if I copy and paste?

--
I like python!
My Blog: http://www.donews.net/limodou
My Django Site: http://www.djangocn.org
NewEdit Maillist: http://groups.google.com/group/NewEdit

Hi Saketh,

···

On Aug 14, 2006, at 8:09 PM, Saketh Bhamidipati wrote:

On 8/14/06, Saketh Bhamidipati saketh.bhamidipati@gmail.com wrote:

I have finally realized the need to implement internationalization in my application, so I set up gettext. However, I am getting an error when I try running my application.

Traceback (most recent call last):
File “C:\Saketh\source\Notalon\Notalon.py”, line 36, in ?
self.lan_en = gettext.translation(‘Notalon’, ‘./locale’, languages=[‘en’])
File “C:\Python24\lib\gettext.py”, line 456, in translation
raise IOError(ENOENT, ‘No translation file found for domain’, domain)
IOError: [Errno 2] No translation file found for domain: ‘Notalon’

I think this is because the mki18n.py does not generate the English translation MO files for some reason. Even when I use python mki18n.py -m -e (and there is a Notalon_en_EN.po file), the English translation is not generated. French files are generated fine, though.

Here’s the important part of my code:

gettext.install(‘Notalon’, ‘./locale’, unicode=True)
self.lan_en = gettext.translation(‘Notalon’, ‘./locale’, languages=[‘en’])
self.lan_fr = gettext.translation(‘Notalon’, ‘./locale’, languages=[‘fr’])
self.lan_en.install ()

Would it work if I used the wx interface to gettext? I would have been able to figure out what’s going on if the French files weren’t generated. But since they are, I am unable to narrow down the problem.

I’m probably going to have many problems with i18n, so please bear with me…thanks!

Never mind the above error - it was a silly directory mistake.

I still have a question. Let’s say I have a fully translated PO file. If I generate a new messages.pot, can I just copy in the old PO file entries into the new one? Or is there something special about the order of the entries in the PO files that might break if I copy and paste?

If you have msgmerge, you can do the following to automatically merge the two together:

msgmerge -N messages.po new_messages.pot > messages.po.new

mv messages.po.new messages.po

the -N is important, because otherwise msgmerge tries to do “fuzzy” matches based on existing translations (aka guesses :-), which are almost always wrong and can put erroneous translations in your .po file.

Regards,

Kevin

OK, I have the PO file merges working now.

Is there some way I can globally install gettext so that I don’t have to keep calling it within each individual file? I call the gettext installation in my Frame subclass, and import gettext in all files that use translations.

···

On 8/15/06, Kevin Ollivier kevino@tulane.edu wrote:

Hi Saketh,

On Aug 14, 2006, at 8:09 PM, Saketh Bhamidipati wrote:

On 8/14/06, Saketh Bhamidipati saketh.bhamidipati@gmail.com wrote:

I have finally realized the need to implement internationalization in my application, so I set up gettext. However, I am getting an error when I try running my application.

Traceback (most recent call last):
File “C:\Saketh\source\Notalon\Notalon.py”, line 36, in ?
self.lan_en = gettext.translation(‘Notalon’, ‘./locale’, languages=[‘en’])

File “C:\Python24\lib\gettext.py”, line 456, in translation
raise IOError(ENOENT, ‘No translation file found for domain’, domain)
IOError: [Errno 2] No translation file found for domain: ‘Notalon’

I think this is because the mki18n.py does not generate the English translation MO files for some reason. Even when I use python mki18n.py -m -e (and there is a Notalon_en_EN.po file), the English translation is not generated. French files are generated fine, though.

Here’s the important part of my code:

gettext.install(‘Notalon’, ‘./locale’, unicode=True)
self.lan_en = gettext.translation(‘Notalon’, ‘./locale’, languages=[‘en’])
self.lan_fr
= gettext.translation(‘Notalon’, ‘./locale’, languages=[‘fr’])
self.lan_en.install ()

Would it work if I used the wx interface to gettext? I would have been able to figure out what’s going on if the French files weren’t generated. But since they are, I am unable to narrow down the problem.

I’m probably going to have many problems with i18n, so please bear with me…thanks!

Never mind the above error - it was a silly directory mistake.

I still have a question. Let’s say I have a fully translated PO file. If I generate a new messages.pot, can I just copy in the old PO file entries into the new one? Or is there something special about the order of the entries in the PO files that might break if I copy and paste?

If you have msgmerge, you can do the following to automatically merge the two together:

msgmerge -N messages.po new_messages.pot > messages.po.new

mv messages.po.new messages.po

the -N is important, because otherwise msgmerge tries to do “fuzzy” matches based on existing translations (aka guesses :-), which are almost always wrong and can put erroneous translations in your .po file.

Regards,

Kevin