By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,359 Members | 1,495 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,359 IT Pros & Developers. It's quick & easy.

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

P: n/a
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 <LL@li.org>\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)

Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"F. GEIGER" <f.******@vol.at> wrote in news:ce**********@newshispeed.ch:
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/thel...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
Jul 18 '05 #2

P: n/a

"Harald Massa" <cp*********@spamgourmet.com> wrote in message
news:Xn**********************************@195.20.2 24.116...
"F. GEIGER" <f.******@vol.at> wrote in news:ce**********@newshispeed.ch:
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/thel...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.

Harald


Kind regards
Franz GEIGER
Jul 18 '05 #3

P: n/a

"Harald Massa" <cp*********@spamgourmet.com> schrieb im Newsbeitrag
news:Xn**********************************@195.20.2 24.116...
"F. GEIGER" <f.******@vol.at> wrote in news:ce**********@newshispeed.ch:
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/thel...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

Harald

Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.