Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > [py2exe.i18n] English works, German works, but not French. What do I miss?

Reply
Thread Tools

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

 
 
F. GEIGER
Guest
Posts: n/a
 
      08-06-2004
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(12

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 <>\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)





 
Reply With Quote
 
 
 
 
Harald Massa
Guest
Posts: n/a
 
      08-06-2004
"F. GEIGER" <> wrote in news:cev7g9$3fm$:

> 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(12



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
 
Reply With Quote
 
 
 
 
F. GEIGER
Guest
Posts: n/a
 
      08-06-2004

"Harald Massa" <> wrote in message
news:Xns953D5E610BA51cpl19ghumspamgourmet@195.20.2 24.116...
> "F. GEIGER" <> wrote in news:cev7g9$3fm$:
>
> > 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(12

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


 
Reply With Quote
 
F. GEIGER
Guest
Posts: n/a
 
      08-06-2004

"Harald Massa" <> schrieb im Newsbeitrag
news:Xns953D5E610BA51cpl19ghumspamgourmet@195.20.2 24.116...
> "F. GEIGER" <> wrote in news:cev7g9$3fm$:
>
> > 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(12

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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help-Charging German Fritzbox from German to English Nigel UK VOIP 4 01-22-2008 10:47 PM
Fritz Fon Ata - Firmware to convert German to English mackeyuk UK VOIP 5 02-01-2006 10:31 PM
Word German and English-Can they live on the same computer? Martin Computer Information 5 09-02-2004 10:06 PM
[i18n] Multilang. app in Python (English, French, German)? F. GEIGER Python 3 07-18-2004 12:19 PM
WinXP German and English .NET Framework Eric ASP .Net 1 06-22-2004 05:42 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57