My application can change language at runtime. You can use the interface in English, then you can click the English flag and select German, and continue to use the interface in German. You can switch back and forth between languages at runtime like that.
The way my application is currently coded, the main dialog is destroyed when you change language, and then it is recreated from scratch in the new language.
Would it work out OK, instead of destroying the main dialog, if I were to call all the "SetText" methods on all the widgets and then try to resize them?
How to change language at runtime
Re: How to change language at runtime
That would be possible, but is it worth the effort? How often do users actually change the GUI language? Usually only once and then it shouldn't matter if they have to restart the application.Would it work out OK, instead of destroying the main dialog, if I were to call all the "SetText" methods on all the widgets and then try to resize them?
Use the source, Luke!
Re: How to change language at runtime
Two years ago I worked in a warehouse with guys from Lithuanian and Hungary. Sometimes I would have to walk into the office, look something up on the computer (which was in English) and then go back out into the warehouse. I want my application to useful in such a situation where people will be walking back and forth to a PC and can change language quickly by clicking the flag in the corner.doublemax wrote: ↑Sun Feb 09, 2020 9:59 pmThat would be possible, but is it worth the effort? How often do users actually change the GUI language? Usually only once and then it shouldn't matter if they have to restart the application.Would it work out OK, instead of destroying the main dialog, if I were to call all the "SetText" methods on all the widgets and then try to resize them?
Re: How to change language at runtime
If this approach is feasible for your application, this is the easiest way to accomplish a change of the user interface language, because applying the translations and laying out the dialogs will be done automatically.Virchanza wrote: ↑Sun Feb 09, 2020 8:09 pm My application can change language at runtime. You can use the interface in English, then you can click the English flag and select German, and continue to use the interface in German. You can switch back and forth between languages at runtime like that.
The way my application is currently coded, the main dialog is destroyed when you change language, and then it is recreated from scratch in the new language.
In principle, yes. However, for most non-trivial dialogs there is usually more to do than just changing static text. For example, for combo boxes you have to reload the list of choices, and frequently you will have to change the order of items to sort them alphabetically in the applied language, and this requires your application to be aware of the item order. Regarding the layout the best approach is to apply all language related changes first, and then call the dialog layout function for the top level widget(s) of the dialog - nested widgets will be laid out anew automatically.
So, being able to change the user interface language on the fly is a really nice feature, but it requires some extra programming effort.
Re: How to change language at runtime
Hi,
Out of curiosity - how much time it takes to re-create the dialog with the different language?
Thank you.
Out of curiosity - how much time it takes to re-create the dialog with the different language?
Thank you.
Re: How to change language at runtime
This really depends on the complexity of the dialogs. It can range from a few milliseconds (simple dialog with few static text elements) to a few seconds (for example about 2 seconds for a complex dialog with a notebook control with 3 tabs, of which each contains a treeview and associated lists with several dozens of translatable entries).
Re: How to change language at runtime
Ulrich,
I was referring to this particular application.
Thank you.
I was referring to this particular application.
Thank you.
Re: How to change language at runtime
I've written a separate function that calls "SetLabel" on all the widgets after you change language, and this works fine. It even looks okay without me resizing anything, but I might take a look at calling the proper resize functions tomorrow.
At one point my application was able to switch language in a split second (i.e. faster than a human being could care about), but now it takes 2 or 3 seconds because I load a PNG of a flag (e.g. the Union Jack for English), resize it, draw text over it and set it as the picture on a button (I have a flag in the corner for changing language). If I prepare the PNG files already-resized and already-text-overlayed then it should take a split second. But anyway I'm not destroying the whole window anymore.
At one point my application was able to switch language in a split second (i.e. faster than a human being could care about), but now it takes 2 or 3 seconds because I load a PNG of a flag (e.g. the Union Jack for English), resize it, draw text over it and set it as the picture on a button (I have a flag in the corner for changing language). If I prepare the PNG files already-resized and already-text-overlayed then it should take a split second. But anyway I'm not destroying the whole window anymore.
-
- Filthy Rich wx Solver
- Posts: 235
- Joined: Fri Sep 14, 2012 8:26 am
- Location: Kontich, Belgium
- Contact:
Re: How to change language at runtime
Hi,
You could, instead of creating the whole dialog with several wx statements, create XRC files and simply load them and display them. Then you can layout them while designing them with your wysiwig tool. Saves you a lot of coding.
with regards,
Nunki
You could, instead of creating the whole dialog with several wx statements, create XRC files and simply load them and display them. Then you can layout them while designing them with your wysiwig tool. Saves you a lot of coding.
with regards,
Nunki