Can't get wx.Locale to work

I can't get the attached example to translate strings correctly.
It works flawlessly with Python's gettext but I can get it to work with wx.Locale.

And I need wx.Locale to work because many of the strings I'm translating are in XRC that does the translation automatically via wx's current locale.

I'm probably missing something really simple, right?

Windowx XP SP2
Python 2.4.2
wxPython 2.8.0.1

wxtrans.py (394 Bytes)

es.mo (373 Bytes)

es.po (361 Bytes)

Hi Eli,

Eli Golovinsky wrote:

I can't get the attached example to translate strings correctly.
It works flawlessly with Python's gettext but I can get it to work with wx.Locale.

And I need wx.Locale to work because many of the strings I'm translating are in XRC that does the translation automatically via wx's current locale.

I'm probably missing something really simple, right?

See attached, you might also want to look at the i18n demo in the 2.8 wxPython demo.

Werner

wxtrans.py (452 Bytes)

Eli Golovinsky wrote:

I can't get the attached example to translate strings correctly.
It works flawlessly with Python's gettext but I can get it to work with wx.Locale.

And I need wx.Locale to work because many of the strings I'm translating are in XRC that does the translation automatically via wx's current locale.

I'm probably missing something really simple, right?

Yep.

def wx_setup():
    app = wx.PySimpleApp()

    locale = wx.Locale(wx.LANGUAGE_SPANISH)
    locale.AddCatalog('es')
    __builtin__._ = wx.GetTranslation

You need to save a reference to the locale object.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Doesn't work either.

I made the silly mistake of letting the Locale object get collected by the GC, but your code doesn't work as well.

Werner F. Bruhin wrote:

···

Hi Eli,

Eli Golovinsky wrote:

I can't get the attached example to translate strings correctly.
It works flawlessly with Python's gettext but I can get it to work with wx.Locale.

And I need wx.Locale to work because many of the strings I'm translating are in XRC that does the translation automatically via wx's current locale.

I'm probably missing something really simple, right?

See attached, you might also want to look at the i18n demo in the 2.8 wxPython demo.

Werner

------------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

And the demo doesn't work either - shows nothing where the translation should appear.

This is happening on two separate computers - my office one and here at home. Both have a similar setup though (WinXp SP2, Python 2.4.2, wxPython 2.8.0.1).

Werner F. Bruhin wrote:

···

Hi Eli,

Eli Golovinsky wrote:

I can't get the attached example to translate strings correctly.
It works flawlessly with Python's gettext but I can get it to work with wx.Locale.

And I need wx.Locale to work because many of the strings I'm translating are in XRC that does the translation automatically via wx's current locale.

I'm probably missing something really simple, right?

See attached, you might also want to look at the i18n demo in the 2.8 wxPython demo.

Werner

------------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

You're right of course, but that doesn't seem to help either.
Here's a revised sample where I'm calling wx,GetTranslation right after AddLocale in the same scope.

Robin Dunn wrote:

es.mo (373 Bytes)

es.po (361 Bytes)

wxtrans.py (475 Bytes)

···

Eli Golovinsky wrote:

I can't get the attached example to translate strings correctly.
It works flawlessly with Python's gettext but I can get it to work with wx.Locale.

And I need wx.Locale to work because many of the strings I'm translating are in XRC that does the translation automatically via wx's current locale.

I'm probably missing something really simple, right?

Yep.

def wx_setup():
    app = wx.PySimpleApp()

    locale = wx.Locale(wx.LANGUAGE_SPANISH)
    locale.AddCatalog('es')
    __builtin__._ = wx.GetTranslation

You need to save a reference to the locale object.

I've been lazy and didn't try to run it with wxPython 2.6.
I've just installed 2.6.3.3 and my samples runs fine. So something happened between 2.6.3.3 and 2.8.1.1.

The files are attached again for your convenience, including the wxversion trick.

Robin Dunn wrote:

es.mo (373 Bytes)

es.po (361 Bytes)

wxtrans.py (544 Bytes)

···

Eli Golovinsky wrote:

I can't get the attached example to translate strings correctly.
It works flawlessly with Python's gettext but I can get it to work with wx.Locale.

And I need wx.Locale to work because many of the strings I'm translating are in XRC that does the translation automatically via wx's current locale.

I'm probably missing something really simple, right?

Yep.

def wx_setup():
    app = wx.PySimpleApp()

    locale = wx.Locale(wx.LANGUAGE_SPANISH)
    locale.AddCatalog('es')
    __builtin__._ = wx.GetTranslation

You need to save a reference to the locale object.

Eli Golovinsky wrote:

You're right of course, but that doesn't seem to help either.
Here's a revised sample where I'm calling wx,GetTranslation right after AddLocale in the same scope.

You need to do two things. You need to structure your language catalogs in one of the standard directory structures, such as <lang>/<domain>.mo and then you need to add the parent of these language dirs to the catalog lookup paths, (if it doesn't happen to be in a system standard location.) I'm not sure exactly what changed between 2.6 and now, but IIRC this is the standard way it was always supposed to work, and this way does work in both current 2.6 and 2.8 releases.

eli.tar.gz (869 Bytes)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Just tried to do that.
Both methods work well with 2.6 but not with 2.8.

Guess I'll have to dig deeper into the C++ code and see what's going on there exactly. It seems the AddCatalog function is returning false. Must be some reason it's doing that.

Robin Dunn wrote:

···

Eli Golovinsky wrote:

You're right of course, but that doesn't seem to help either.
Here's a revised sample where I'm calling wx,GetTranslation right after AddLocale in the same scope.

You need to do two things. You need to structure your language catalogs in one of the standard directory structures, such as <lang>/<domain>.mo and then you need to add the parent of these language dirs to the catalog lookup paths, (if it doesn't happen to be in a system standard location.) I'm not sure exactly what changed between 2.6 and now, but IIRC this is the standard way it was always supposed to work, and this way does work in both current 2.6 and 2.8 releases.

------------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Disregard my last message.

I failed to notice that you've attached a working example. I've mixed up AddCatalog and AddCatalogLookupPathPrefix.

Thanks a lot for your help.

Robin Dunn wrote:

···

Eli Golovinsky wrote:

You're right of course, but that doesn't seem to help either.
Here's a revised sample where I'm calling wx,GetTranslation right after AddLocale in the same scope.

You need to do two things. You need to structure your language catalogs in one of the standard directory structures, such as <lang>/<domain>.mo and then you need to add the parent of these language dirs to the catalog lookup paths, (if it doesn't happen to be in a system standard location.) I'm not sure exactly what changed between 2.6 and now, but IIRC this is the standard way it was always supposed to work, and this way does work in both current 2.6 and 2.8 releases.

------------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Hi Eli,

Eli Golovinsky wrote:

I've been lazy and didn't try to run it with wxPython 2.6.
I've just installed 2.6.3.3 and my samples runs fine. So something happened between 2.6.3.3 and 2.8.1.1.

I tested on 2.6. Yes, on 2.8 there seems to be a change.

The directory structure has to be:
locale\es\LC_MESSAGES

I believe this is the recommended structure, but it seems that one has to follow this in 2.8.

"locale" can be anything as long as you do "wx.Locale.AddCatalogLookupPathPrefix(r'locale')"

Werner

I see you got it already going.

One should look a few message further up, before one creates noise on this list :-[

Werner

Hi All

Can anybody tell me how to use “wxTopLevelWindow”
or show me sample code for wxTopLevelWindow.

thanks

Amit tandial

*********************** Aricent-Unclassified ***********************

"DISCLAIMER: This message is proprietary to Aricent and is intended solely for the use of the individual to whom it is addressed. It may contain privileged or confidential information and should not be circulated or used for any purpose other than for what it is intended. If you have received this message in error, please notify the originator immediately. If you are not the intended recipient, you are notified that you are strictly
prohibited from using, copying, altering, or disclosing the contents of this message. Aricent accepts no responsibility for loss or damage arising from the use of the information transmitted by this email including damage from virus."

Hi Amit,

Why do you need to use a wx.TopLevelWindow? Why not a wx.Frame or a wx.Dialog?

Peter.

···

On 2/13/07, Amit15.Kumar@aricent.com Amit15.Kumar@aricent.com wrote:

Hi All

Can anybody tell me how to use “wxTopLevelWindow”
or show me sample code for wxTopLevelWindow.

thanks

Amit tandial

*********************** Aricent-Unclassified ***********************

"DISCLAIMER: This message is proprietary to Aricent and is intended solely for the use of
the individual to whom it is addressed. It may contain privileged or confidential information and should not be
circulated or used for any purpose other than for what it is intended. If you have received this message in error,
please notify the originator immediately. If you are not the intended recipient, you are notified that you are strictly

prohibited from using, copying, altering, or disclosing the contents of this message. Aricent accepts no responsibility for
loss or damage arising from the use of the information transmitted by this email including damage from virus."



There is NO FATE, we are the creators.

Peter .

this is also possible …but i would
like to have child window that will always be use as full screen.

"Peter Damoc"
pdamoc@gmail.com

02/13/2007 01:13 PM

Please respond to

wxPython-users@lists.wxwidgets.org

To

wxPython-users@lists.wxwidgets.org
cc

Subject

Re: [wxPython-users] : How
to use wxTopLevelWindow

Hi Amit,
Why do you need to use a wx.TopLevelWindow?
Why not a wx.Frame or a wx.Dialog?
Peter.

···

On 2/13/07, Amit15.Kumar@aricent.com Amit15.Kumar@aricent.com wrote:

Hi All

Can anybody tell me how to use “wxTopLevelWindow” or show me
sample code for wxTopLevelWindow.

thanks

Amit tandial

*********************** Aricent-Unclassified ***********************
`"DISCLAIMER: This message
is proprietary to Aricent and is intended solely for the use of

the individual to whom it is addressed. It may contain privileged or confidential
information and should not be

circulated or used for any purpose other than for what it is intended.
If you have received this message in error,

please notify the originator immediately. If you are not the intended recipient,
you are notified that you are strictly

prohibited from using, copying, altering, or disclosing the contents of
this message. Aricent accepts no responsibility for

loss or damage arising from the use of the information transmitted by this
email including damage from virus."

`

There is NO FATE, we are the creators.

*********************** Aricent-Unclassified ***********************

"DISCLAIMER: This message is proprietary to Aricent and is intended solely for the use of the individual to whom it is addressed. It may contain privileged or confidential information and should not be circulated or used for any purpose other than for what it is intended. If you have received this message in error, please notify the originator immediately. If you are not the intended recipient, you are notified that you are strictly
prohibited from using, copying, altering, or disclosing the contents of this message. Aricent accepts no responsibility for loss or damage arising from the use of the information transmitted by this email including damage from virus."

Why not use ShowFullScreen on a wx.Frame?

···

On 2/13/07, Amit15.Kumar@aricent.com < Amit15.Kumar@aricent.com> wrote:

Peter .

this is also possible …but i would
like to have child window that will always be use as full screen.

“Peter Damoc”
pdamoc@gmail.com

02/13/2007 01:13 PM

Please respond to

wxPython-users@lists.wxwidgets.org

To

wxPython-users@lists.wxwidgets.org
cc

Subject

Re: [wxPython-users] : How
to use wxTopLevelWindow

Hi Amit,
Why do you need to use a wx.TopLevelWindow?
Why not a wx.Frame or a wx.Dialog?
Peter.
On 2/13/07, Amit15.Kumar@aricent.com > > Amit15.Kumar@aricent.com > wrote:

Hi All

Can anybody tell me how to use “wxTopLevelWindow” or show me
sample code for wxTopLevelWindow.

thanks

Amit tandial

*********************** Aricent-Unclassified ***********************
`"DISCLAIMER: This message
is proprietary to Aricent and is intended solely for the use of

the individual to whom it is addressed. It may contain privileged or confidential
information and should not be

circulated or used for any purpose other than for what it is intended.
If you have received this message in error,

please notify the originator immediately. If you are not the intended recipient,
you are notified that you are strictly

prohibited from using, copying, altering, or disclosing the contents of
this message. Aricent accepts no responsibility for

loss or damage arising from the use of the information transmitted by this
email including damage from virus."

`

There is NO FATE, we are the creators.

*********************** Aricent-Unclassified ***********************

"DISCLAIMER: This message is proprietary to Aricent and is intended solely for the use of
the individual to whom it is addressed. It may contain privileged or confidential information and should not be
circulated or used for any purpose other than for what it is intended. If you have received this message in error,
please notify the originator immediately. If you are not the intended recipient, you are notified that you are strictly

prohibited from using, copying, altering, or disclosing the contents of this message. Aricent accepts no responsibility for
loss or damage arising from the use of the information transmitted by this email including damage from virus."



There is NO FATE, we are the creators.

You can't instantiate wx.TopLevelWindow directly. Use a frame or a dialog.

···

On 2/12/07, Amit15.Kumar@aricent.com <Amit15.Kumar@aricent.com> wrote:

Hi All
Can anybody tell me how to use "wxTopLevelWindow" or show me sample code for wxTopLevelWindow.

thanks
Amit tandial

wx.TopLevelWindow is simply the common base class for wx.Frame and wx.Dialog. It is not intended to be used directly.

···

Amit15.Kumar@aricent.com wrote:

Hi All
Can anybody tell me how to use "wxTopLevelWindow" or show me sample code for wxTopLevelWindow.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!