[py2exe.i18n] English works, German works, but not French. What do I miss?

F

F. GEIGER

When I start a py2exe-ed application I get the error

'ascii' codec can't encode character u'\xe9' in position 10: ordinal not in
range(128)

This is how I run py2exe:

setup.py py2exe -O1 --packages encodings

This is how the .po-file looks like:

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: Sun Jul 18 13:44:27 2004\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ISO8859-1\n"
"Content-Transfer-Encoding: ISO8859-1\n"
"Generated-By: pygettext.py 1.5\n"


#: ..\..\..\MainFrame.py:97
msgid "Could not connect to database: %s. "
msgstr "Impossible de se connecter à la base de données: %s. "

etc.

However, the English and German language versions works. The German version
works since I added "--packages encodings" to the call to py2exe. I thought
this would cover all Western European languages.

What do I miss?

Many thanks in advance
Franz GEIGER

P.S.:

The language switch ing in my app is done this way:

languageCode = Settings().value("GUI", "Language")
_Logger.debug(thisName + "(): Settings say language is '%s'. " %
languageCode)
try:
if "de" == languageCode:
_Logger.debug(thisName + "(): Switch messages.mo to 'de'. ")
gettext.translation('messages', 'Texts', languages=["de"],
fallback=True).install(unicode)
elif "fr" == languageCode:
_Logger.debug(thisName + "(): Switch messages.mo to 'fr'. ")
gettext.translation('messages', 'Texts', languages=["fr"],
fallback=True).install(unicode)
else:
_Logger.debug(thisName + "(): Switch messages.mo to 'en'. ")
gettext.translation('messages', 'Texts', languages=["en"],
fallback=True).install(unicode)
except Exception, e:
_Logger.exception("An exception occurred: %s. " % e)
 
H

Harald Massa

F. GEIGER said:
When I start a py2exe-ed application I get the error

'ascii' codec can't encode character u'\xe9' in position 10: ordinal
not in range(128)


encodings: prepare to spend the night.

First reading:
http://starship.python.net/crew/theller/moin.cgi/EncodingsAgain

Second:
your error msg says that you are trying to encode sth. NOT ASCII to
ASCII...

I guess:
your lokale site has another encoding configured


import sys
sys.getdefaultencoding()

-- returns sth. like Latin-1

And the py2exed application does not read siteconfig.py, and so in the
running app sys.getdefaultencoding() would be some thing different.

My approach to this is:

in the beginning of the app I write:

import sys
if hasattr(sys,"setdefaultencoding"):
sys.setdefaultencoding("latin-1")

so ... when no site-config was run, I manually set my default encoding to
latin-1

works great (together with what I described within the wiki)

Harald
 
F

F. GEIGER

Harald Massa said:
encodings: prepare to spend the night.

First reading:
http://starship.python.net/crew/theller/moin.cgi/EncodingsAgain

Second:
your error msg says that you are trying to encode sth. NOT ASCII to
ASCII...

I guess:
your lokale site has another encoding configured


import sys
sys.getdefaultencoding()

-- returns sth. like Latin-1

And the py2exed application does not read siteconfig.py, and so in the
running app sys.getdefaultencoding() would be some thing different.

My approach to this is:

in the beginning of the app I write:

import sys
if hasattr(sys,"setdefaultencoding"):
sys.setdefaultencoding("latin-1")

if hasattr() returns False, that means that site.py / sitecustomize.py has
been exec'ed and has deleted the attr 'setdefaultencoding', right?

i.e.,

import sys
if hasattr(sys,"setdefaultencoding"):
sys.setdefaultencoding("latin-1")
else:
pass # site.py did it already for us and everything should work
so ... when no site-config was run, I manually set my default encoding to
latin-1

works great (together with what I described within the wiki)

Thank you, Harald, as I am traveling right now, I'll be able to try this in
the afternoon.

Kind regards
Franz GEIGER
 
F

F. GEIGER

Harald Massa said:
encodings: prepare to spend the night.

First reading:
http://starship.python.net/crew/theller/moin.cgi/EncodingsAgain

Second:
your error msg says that you are trying to encode sth. NOT ASCII to
ASCII...

I guess:
your lokale site has another encoding configured


import sys
sys.getdefaultencoding()

-- returns sth. like Latin-1

And the py2exed application does not read siteconfig.py, and so in the
running app sys.getdefaultencoding() would be some thing different.

My approach to this is:

in the beginning of the app I write:

import sys
if hasattr(sys,"setdefaultencoding"):
sys.setdefaultencoding("latin-1")

so ... when no site-config was run, I manually set my default encoding to
latin-1

works great (together with what I described within the wiki)

Phew, that did it - works great. Thanx a lot, Harald!

Cheers
Franz GEIGER
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top