472,142 Members | 1,065 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,142 software developers and data experts.

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

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
3 2126
"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

"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

"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.

Similar topics

4 posts views Thread by Ricky Romaya | last post: by
7 posts views Thread by Andr? Roberge | last post: by
10 posts views Thread by Albretch | last post: by
66 posts views Thread by jacob navia | last post: by
13 posts views Thread by jd | last post: by
8 posts views Thread by CptDondo | last post: by
12 posts views Thread by Steve Howell | last post: by
2 posts views Thread by Norman Diamond | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.