Re: how to localize a common dialog box

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: how to localize a common dialog box

Public cai
Hi list,

does anybody know how to display a common dialog box such as
wxDirDialog with its strings translated to the language used by the
code calling this dialog box (in this case, German)? I could translate
the message given as parameter to wxDirDialog constructor. Also, the
title could be easily changed by using wxDialog::SetTitle(), but the
name of the buttons, how could I also translate them?...

Thanks,

Cristina.
_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

Re: Re: how to localize a common dialog box

Karsten Hilbert
On Thu, Jul 10, 2008 at 02:45:57PM +0300, Public cai wrote:

> does anybody know how to display a common dialog box such as
> wxDirDialog with its strings translated to the language used by the
> code calling this dialog box (in this case, German)? I could translate
> the message given as parameter to wxDirDialog constructor. Also, the
> title could be easily changed by using wxDialog::SetTitle(), but the
> name of the buttons, how could I also translate them?...

You need to activate the locale system.

"import locale" and wx.Locale are your friend.

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346
_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

Re: Re: how to localize a common dialog box

Werner F. Bruhin
In reply to this post by Public cai
Cristinia,

Public cai wrote:
> Hi list,
>
> does anybody know how to display a common dialog box such as
> wxDirDialog with its strings translated to the language used by the
> code calling this dialog box (in this case, German)? I could translate
> the message given as parameter to wxDirDialog constructor. Also, the
> title could be easily changed by using wxDialog::SetTitle(), but the
> name of the buttons, how could I also translate them?...
>  
Have a look at the I18N demo in the wxPython demo and at the following wiki:
http://wiki.wxpython.org/Internationalization
http://wiki.wxpython.org/ValidI18nCodes
http://wiki.wxpython.org/XRCAndI18N

Note that you can use gettext and local or wx.GetTranslation and
wx.Locale, you should use the later if you want wxPython standard
strings to be translated and when you distribute your application you
should not forget to include the appropriate language.mo files from the
wxPython version you are using.

Werner
_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

Re: Re: how to localize a common dialog box

Karsten Hilbert
On Thu, Jul 10, 2008 at 02:42:41PM +0200, Werner F. Bruhin wrote:

> Note that you can use gettext and local or wx.GetTranslation and  
> wx.Locale, you should use the later if you want wxPython standard  
> strings to be translated

Note that this is NOT a requirement for wxPython-internal
strings (such as stock button labels) to be translated. BOTH
ways work. All one needs to make sure is that the normal
Python library locale/gettext modules are imported and
initialized *before* wxPython is imported. But that would be
Good Practice anyway.

The reason being that, apparently, during its startup
wxPython detects the currently activated system locale and
adjusts itself to that. So, if the Python library module
locale.setlocale(locale.LC_ALL) was called appropriately,
wxPython will automatically be in the right locale, too.
This is perfectly sane from a software engineering point of
view as wxPython is a layer on top of Python (and other
things) so as long as Python did the right thing early
enough wxPython should, too (and it does).

> and when you distribute your application you  
> should not forget to include the appropriate language.mo files from the  
> wxPython version you are using.
That advice is prudent but only applies on Windows. On Linux
and/or Mac make sure to have the package manager install any
needed i18n dependancy packages.

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346
_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

Re: Re: how to localize a common dialog box

Werner F. Bruhin
Karsten,

Karsten Hilbert wrote:

> On Thu, Jul 10, 2008 at 02:42:41PM +0200, Werner F. Bruhin wrote:
>
>  
>> Note that you can use gettext and local or wx.GetTranslation and  
>> wx.Locale, you should use the later if you want wxPython standard  
>> strings to be translated
>>    
>
> Note that this is NOT a requirement for wxPython-internal
> strings (such as stock button labels) to be translated. BOTH
> ways work. All one needs to make sure is that the normal
> Python library locale/gettext modules are imported and
> initialized *before* wxPython is imported. But that would be
> Good Practice anyway.
>  
Thanks for putting me right, I wasn't aware of the fact that the order
was enough to get wxPython play nicely with locale/gettext.

Looking at the wiki pages I noticed that some are a bit dated, i.e.
still use the old wxPython namespace.

Will see if in the next few weeks I get around to update some of that,
at that time will add this pointer too - unless someone else is faster
then me :-) .

Werner
_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

Re: Re: how to localize a common dialog box

Karsten Hilbert
On Thu, Jul 10, 2008 at 03:35:02PM +0200, Werner F. Bruhin wrote:

> Thanks for putting me right,
You were not entirely wrong either ;-)

Just wanted to clarify a bit more.

> I wasn't aware of the fact that the order  
> was enough to get wxPython play nicely with locale/gettext.
At least that's what I observe with GNUmed on
Linux/Windows/MacOSX.

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346
_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

Re: how to localize a common dialog box

Public cai
In reply to this post by Public cai
Thanks guys for your answers!

Shame on me, but I still don't know what is wrong in my code...

Firstly, my code is C++ code and it's using wxWidgets, not wxPython. I
asked on this list because it seemed to me that I get the answer
quicker.

Secondly, my code already translates the strings it uses. Like this:
  locale.Init(wxLANGUAGE_GERMAN);
  locale.AddCatalogLookupPathPrefix(localePrefix); // localePrefix is
a local path ending with "...\lang"
  locale.AddCatalog(catalog); // this is a .mo file (we use several .mo files)

What lacks is the translation of common dialog boxes.I think it may
have to do with what you wrote:

> Note that you can use gettext and local or wx.GetTranslation and  wx.Locale, you should use the later if you want wxPython standard  strings to be translated
>> Note that this is NOT a requirement for wxPython-internal strings (such as stock button labels) to be translated. BOTH ways work. All one needs to make sure is that the normal Python library locale/gettext modules are imported and initialized *before* wxPython is imported.

Considering that I'm using wxWidgets and not wxPython, do you know
what I should do to accomplish this?

Thanks,

Cristina.
_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

Re: Re: how to localize a common dialog box

Karsten Hilbert
On Fri, Jul 11, 2008 at 12:42:20PM +0300, Public cai wrote:

> Firstly, my code is C++ code and it's using wxWidgets, not wxPython. I
> asked on this list because it seemed to me that I get the answer
> quicker.
What help is a quick answer that doesn't apply ?

> > Note that you can use gettext and local or wx.GetTranslation and  wx.Locale, you should use the later if you want wxPython standard  strings to be translated
> >> Note that this is NOT a requirement for wxPython-internal strings (such as stock button labels) to be translated. BOTH ways work. All one needs to make sure is that the normal Python library locale/gettext modules are imported and initialized *before* wxPython is imported.
>
> Considering that I'm using wxWidgets and not wxPython, do you know
> what I should do to accomplish this?
You'll have to do the C++ equivalent of what I suggested
doing with Python. Now, that doesn't help you much, I know.

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346
_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

Re: how to localize a common dialog box

Public cai
In reply to this post by Public cai
Hi list,

>> Firstly, my code is C++ code and it's using wxWidgets, not wxPython. I asked on this list because it seemed to me that I get the answer  quicker.
>What help is a quick answer that doesn't apply ?

Well, for most questions I asked on this list, the answers applied
both to wxPython as to wxWidgets. Indeed, in this particular case, it
seems to not apply.


I continued studying the problem and found out that for Windows,
- wxDirDialog actually calls SHBrowseForFolder()
- SHBrowseForFolder() is a Windows Shell API function
- seems that the Windows Shell API functions are not localized and
follow the language setting of Windows, meaning that if the user has a
German Windows installation (for example), she will see the common
dialogs translated to German. Also, this means that even when she uses
an English version of our program, she will still see the common
dialogs translated to German if she has a German Windows installation
(see: http://forums.msdn.microsoft.com/en/netfxbcl/thread/40fae6c6-1afc-4a4d-8638-88cdf69c5ee6/)

The Windows on my machine is English, I always see these common
dialogs in English (even when running a German version of our program)
and that's why I worried about this topic.

So I guess I shouldn't bother my head with common dialog localization anymore...

Regards,

Cristina.
_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

Re: Re: how to localize a common dialog box

Karsten Hilbert
On Sat, Jul 12, 2008 at 08:27:41AM +0300, Public cai wrote:

> >> Firstly, my code is C++ code and it's using wxWidgets, not wxPython. I asked on this list because it seemed to me that I get the answer  quicker.
> >What help is a quick answer that doesn't apply ?
>
> Well, for most questions I asked on this list, the answers applied
> both to wxPython as to wxWidgets.
Now, that's good news.

> I continued studying the problem and found out that for Windows,
> - wxDirDialog actually calls SHBrowseForFolder()
> - SHBrowseForFolder() is a Windows Shell API function
> - seems that the Windows Shell API functions are not localized and
> follow the language setting of Windows,
Your analysis seems correct.

> meaning that if the user has a
> German Windows installation (for example), she will see the common
> dialogs translated to German.
Verstehe.

> So I guess I shouldn't bother my head with common dialog localization anymore...
Scheinbar hat Microsoft für Dich entschieden.

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346
_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

Re: how to localize a common dialog box

Public cai
In reply to this post by Public cai
>> So I guess I shouldn't bother my head with common dialog localization anymore...
>Scheinbar hat Microsoft für Dich entschieden.

... meaning "Apparently Microsoft decided for you" (Babelfish
translation). So it seems, yes, for all of us Windows users.

Kind regards,

Cristina.
_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

Re: Re: how to localize a common dialog box

Karsten Hilbert
On Sat, Jul 12, 2008 at 06:47:34PM +0300, Public cai wrote:

> >> So I guess I shouldn't bother my head with common dialog localization anymore...
> >Scheinbar hat Microsoft für Dich entschieden.
>
> ... meaning "Apparently Microsoft decided for you" (Babelfish
> translation). So it seems, yes, for all of us Windows users.

Oops, from your name and user base methought you spake German.

Sorry,
Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346
_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

Re: Re: how to localize a common dialog box

Robin Dunn
In reply to this post by Public cai
Public cai wrote:

>
> I continued studying the problem and found out that for Windows,
> - wxDirDialog actually calls SHBrowseForFolder()
> - SHBrowseForFolder() is a Windows Shell API function
> - seems that the Windows Shell API functions are not localized and
> follow the language setting of Windows, meaning that if the user has a
> German Windows installation (for example), she will see the common
> dialogs translated to German. Also, this means that even when she uses
> an English version of our program, she will still see the common
> dialogs translated to German if she has a German Windows installation
> (see: http://forums.msdn.microsoft.com/en/netfxbcl/thread/40fae6c6-1afc-4a4d-8638-88cdf69c5ee6/)
>
> The Windows on my machine is English, I always see these common
> dialogs in English (even when running a German version of our program)

You are correct.


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

_______________________________________________
wxpython-users mailing list
[hidden email]
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Reply | Threaded
Open this post in threaded view
|

Re: Re: how to localize a common dialog box

Nando Beifiori
Hello all,
so there is not way to get dialogs translated?
Reply | Threaded
Open this post in threaded view
|

Re: Re: how to localize a common dialog box

Tim Roberts
Nando Beifiori wrote:
> Hello all,
> so there is not way to get dialogs translated?

Do you mean, automatically?  No, you have to do the translations
yourself, or hire someone to do it.  After you have the translated
strings, there are a number of ways to substitute the translations when
you create the dialog:
    http://wiki.wxpython.org/Internationalization

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en
Reply | Threaded
Open this post in threaded view
|

Re: Re: how to localize a common dialog box

Robin Dunn
In reply to this post by Nando Beifiori
On 5/10/11 12:51 PM, Nando Beifiori wrote:
> Hello all,
> so there is not way to get dialogs translated?

Not without changing the locale settings of the system.  For the most
part the common dialogs are provided by the system, not wx, and so their
content and where they pull their label text from is controlled by the
system, not wx.

OTOH, if you create your own dialog classes and use the supported i18n
techniques then the text will be pulled from your translated language
catalogs based on the current wx.Locale object, and not solely on the
system's current locale settings.

http://wiki.wxpython.org/RecipesI18n


--
Robin Dunn
Software Craftsman
http://wxPython.org

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en