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

Discussion in 'Python' started by F. GEIGER, Aug 6, 2004.

  1. F. GEIGER

    F. GEIGER Guest

    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 <>\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)
     
    F. GEIGER, Aug 6, 2004
    #1
    1. Advertising

  2. F. GEIGER

    Harald Massa Guest

    "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(128)



    encodings: prepare to spend the night.

    First reading:
    http://starship.python.net/crew/theller/moin.cgi/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
     
    Harald Massa, Aug 6, 2004
    #2
    1. Advertising

  3. F. GEIGER

    F. GEIGER Guest

    "Harald Massa" <> wrote in message
    news:Xns953D5E610BA51cpl19ghumspamgourmet@195.20.224.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(128)

    >
    >
    > encodings: prepare to spend the night.
    >
    > First reading:
    > http://starship.python.net/crew/theller/moin.cgi/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
     
    F. GEIGER, Aug 6, 2004
    #3
  4. F. GEIGER

    F. GEIGER Guest

    "Harald Massa" <> schrieb im Newsbeitrag
    news:Xns953D5E610BA51cpl19ghumspamgourmet@195.20.224.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(128)

    >
    >
    > encodings: prepare to spend the night.
    >
    > First reading:
    > http://starship.python.net/crew/theller/moin.cgi/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
     
    F. GEIGER, Aug 6, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Royal

    Dynamic English/French links

    Jim Royal, Jan 12, 2005, in forum: HTML
    Replies:
    6
    Views:
    466
    Jim Royal
    Jan 13, 2005
  2. F. GEIGER
    Replies:
    3
    Views:
    371
    F. GEIGER
    Jul 18, 2004
  3. Pater Maximus
    Replies:
    1
    Views:
    347
    Ian Parker
    Oct 20, 2004
  4. Tim Golden
    Replies:
    1
    Views:
    340
    Pater Maximus
    Oct 20, 2004
  5. Tinman
    Replies:
    1
    Views:
    75
    Ingo Menger
    Jan 25, 2006
Loading...

Share This Page