473,419 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 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 2214
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ricky Romaya | last post by:
Hi, Anybody could show me a regex for capturing words (alphas, without numerics) in languages other than english (languages with special characters i.e. french, german)? I've tried '+' but the...
3
by: F. GEIGER | last post by:
Is there a way to do this in a professional manner? For now I only can think of having all strings in a file, read them into a dict at startup and then access them like so: print...
7
by: Andr? Roberge | last post by:
In short: I'm looking for a *simple* example of how to write a program that can have its GUI in at least two languages under Windows ... using only Python, of course! I've downloaded Guido van...
10
by: Albretch | last post by:
.. Can you define the Character Set for particular tables instead of databases? . Which DBMSs would let you do that? . How do you store in a DBMS i18n'ed users' from input, coming over the web...
66
by: jacob navia | last post by:
The english word "Initialized" exists. (Cambridge dictionary finds it). The word "Uninitialized" doesn't seem to exist, and no dictionary has it. I am using that word very often in my tutorial of...
13
by: jd | last post by:
I have just spent the past week reading up on locales in books by Josuttis and Stroustrup. As a simple test of locales, I prepared the following source code below. The purpose is to convert the...
8
by: CptDondo | last post by:
I have a small, embedded app that uses a webserver to serve up pages showing status, etc. Right now all the pages are hard-coded in English. We need to provide multi-lingual support. All of...
12
by: Steve Howell | last post by:
The never-ending debate about PEP 3131 got me thinking about natural languages with respect to Python, and I have a bunch of mostly simple observations (some factual, some anecdotal). I present...
2
by: Norman Diamond | last post by:
My C# code is I18N'ed by appropriately naming and editing .resx files. At execution time, it works. My C++ code is somewhat I18N'ed. When I put UI code in C++ I use .rc files. When I link to a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.