473,574 Members | 2,666 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[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"
#: ..\..\..\MainFr ame.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().valu e("GUI", "Language")
_Logger.debug(t hisName + "(): Settings say language is '%s'. " %
languageCode)
try:
if "de" == languageCode:
_Logger.debug(t hisName + "(): Switch messages.mo to 'de'. ")
gettext.transla tion('messages' , 'Texts', languages=["de"],
fallback=True). install(unicode )
elif "fr" == languageCode:
_Logger.debug(t hisName + "(): Switch messages.mo to 'fr'. ")
gettext.transla tion('messages' , 'Texts', languages=["fr"],
fallback=True). install(unicode )
else:
_Logger.debug(t hisName + "(): Switch messages.mo to 'en'. ")
gettext.transla tion('messages' , 'Texts', languages=["en"],
fallback=True). install(unicode )
except Exception, e:
_Logger.excepti on("An exception occurred: %s. " % e)

Jul 18 '05 #1
3 2227
"F. GEIGER" <f.******@vol.a t> 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.getdefaulte ncoding()

-- returns sth. like Latin-1

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

My approach to this is:

in the beginning of the app I write:

import sys
if hasattr(sys,"se tdefaultencodin g"):
sys.setdefaulte ncoding("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*********@sp amgourmet.com> wrote in message
news:Xn******** *************** ***********@195 .20.224.116...
"F. GEIGER" <f.******@vol.a t> 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.getdefaulte ncoding()

-- returns sth. like Latin-1

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

My approach to this is:

in the beginning of the app I write:

import sys
if hasattr(sys,"se tdefaultencodin g"):
sys.setdefaulte ncoding("latin-1")


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

i.e.,

import sys
if hasattr(sys,"se tdefaultencodin g"):
sys.setdefaulte ncoding("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*********@sp amgourmet.com> schrieb im Newsbeitrag
news:Xn******** *************** ***********@195 .20.224.116...
"F. GEIGER" <f.******@vol.a t> 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.getdefaulte ncoding()

-- returns sth. like Latin-1

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

My approach to this is:

in the beginning of the app I write:

import sys
if hasattr(sys,"se tdefaultencodin g"):
sys.setdefaulte ncoding("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
2335
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 special letters for some language (i.e. french) are not captured. The '\w+' works fine, but it also include numerics, which I don't want. TIA
3
1374
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 str(MyTextDict('e', "errorOnDbStore")) or print str(MyTextDict('f', MyTextDict._ErrorKey_ErrorOnDbStore))
7
1844
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 Robot (great program!) so that my kids could learn the basics of programming. Apparently it is set up to work in French under *nix, but not under...
10
2971
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 (basically from everywhere) store it and properly serve it back to users, . . .? . Can you point me to info on this? I would preferably use...
66
3272
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 the C language with "uninitialized memory". Word flags this as a spelling error and tells me that the correct spelling is
13
2774
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 French decimal number 1.234,567 to the English equivalent of 1,234.567. std::locale oFrenchLocale( "French_Canada.1252" ); std::string oS =...
8
3196
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 the pages are PHP generated. Ideally, I'd like for the PHP backend to serve up the language based a) the user's locale, and if that is not set, its...
12
2729
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 these mostly as food for thought, but I do make my own continent-by-continent recommendations at the bottom of the email. (My own linguistic...
2
3296
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 third party's DLLs I get what they supplied. When I link to Microsoft's CRT and MFC, um... Well anyway, at execution time it seems to be working,...
0
7730
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8058
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7820
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6456
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5624
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3742
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3753
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2249
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.