LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Application localization in one function

Hi. I want to localize my application.
 
It has some menus and panels. They are all loaded in different functions of program.
 
Help says:
 
Complete the following steps to localize a user interface.
  1. Create a language resource file (.lwl) for each language with the User Interface Localizer utility. For example, you might want to create files such as ui_English.lwl, ui_Spanish.lwl, and ui_German.lwl.
  2. Add code to determine which language resource file to use based on the Windows regional settings. For example, you can use the GetLocaleInfo SDK function with the values LOCALE_SYSTEM_DEFAULT and LOCALE_SENGLANGUAGE to get the full English name of the Windows default language.
  3. Call LoadLocalizePanel or LocalizePanel in your application with the correct language resource file.
 
I made Language Resource File for all panels and menus. As I understand, I should call LocalizePanel with LoadPanel or LoadLocalizePanel every time I want to call panel.
 
But I want to translate all panels once in one function and after that call this localized versions in all places of program.
 
How can I do this?
 
 
0 Kudos
Message 1 of 19
(5,059 Views)
If I understand correctly, then you should be able to simply call just LoadPanel / DisplayPanel when you want to first display the original panel, and in the function that you're referring to, you could simply call LoadLocalizePanel and pass it the same panel handle that you got back from LoadPanel. After that point, all controls should display in the localized language. Would this work for you?

Luis
0 Kudos
Message 2 of 19
(5,045 Views)
The question was how to save the state of the panel (Function SavePanelState doesn't helpful in this case.).
 
I decided to replace all callings of function LoadPanel to my own function manually.
May be it is not the best idea but I don't know another way to do it.


Message Edited by stskr on 07-16-2008 12:10 PM
0 Kudos
Message 3 of 19
(5,040 Views)

I faced one more problem. In some panels some fonts are used that are not represented in Russian like NIDialog, NIApp etc..

So I have translated all texts in CVI GUI Localization Utility in Russian, but the texts in such fonts are displayed in English.

How can I replace all fonts into smth like Arial or Times New Roman fonts in one place (or may be function)?

(I don't want to remake all the controls manually!)

0 Kudos
Message 4 of 19
(5,021 Views)

If you are using CVI 8 or later you can select multiple controls and edit the common attributes of them in one step only. This works for controls of the same type (i.e. all buttons can be edited at a time, next string controls, numeric controls and so on).

If you re using a previous version of cvi there is no built-in functionality to obtain this. One way of avoiding manual editing of each control is to:

  • Save panel in text format (Options >> Save in text format... menu function)
  • Edit the .TUI files with a text editor for example replacing the "NIDialog" with "Arial" in a single step
  • Reload edited texts and check the results (Options >> Load from test format... menu function)


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 19
(5,016 Views)
Thank you. I use CVI 8.
 
I made this three steps. But it doesn't work. Smiley Sad
After loading .tui file the fonts remain the same.
0 Kudos
Message 6 of 19
(5,008 Views)
You could be setting an incorrect font: I suggest you create a small panel with a few controls with correct fonts and a few with built-in fonts like NI DIalogue: examining the generated tui file you can see the exact spelling of the font names and operate consequently on your panels.
 
But if you are using CVI8 manual editing of controls in blocks can be the best compromise (less effort and max user control on modifications).
 
 
Edit: I checked the CVI version when this function was introduced: it can be found from CVI 8.1 on, as noted in this CVI Tip. You may want to see if upgrading to version 8.1 or later can be an option for you (I seem to remember that some upgrades are free of charge: I don't know if this is the case but looking for it can be worth the time)


Message Edited by Roberto Bozzolo on 07-17-2008 02:34 PM


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 7 of 19
(5,006 Views)

Could be this problem because of using Predefined fonts such as VAL_DIALOG_FONT in .tui file?

I tried to change strings in userint.h such way

#define VAL_DIALOG_FONT                  "Courier"

instead of

#define VAL_DIALOG_FONT                  "NIDialog"

But it doesn't help.

0 Kudos
Message 8 of 19
(4,997 Views)

Hello stskr,

Since you didn’t see any change in behavior after changing the header file’s VAL_DIALOG_FONT, odds are you are changing the wrong thing (either the wrong constant or the wrong header file).  I would recommend trying out what Roberto Bozzolo said in his previous post:

You could be setting an incorrect font: I suggest you create a small panel with a few controls with correct fonts and a few with built-in fonts like NI DIalogue: examining the generated tui file you can see the exact spelling of the font names and operate consequently on your panels.

The key is to find out exactly what must be changed in the tui file.  If you create a simple small panel, as suggested above, this will be easier to do.

Also, just in case you didn’t know already, control fonts can be changed programmatically, using the SetCtrlAttribute() function.  This should keep you from having to rebuild your entire UI with a new default font.

Chris_G
Sr Test Engineer
Medtronic, Inc.
0 Kudos
Message 9 of 19
(4,968 Views)
I made another project with one panel. Controls with NIDialog and NIApp fonts are displayed correctly in Russian in it.
 
I discovered that in the first project only controls of some types (like text message) are displayed incorrectly.
After that I added to the panel control of the same type with NIApp font and it displayed correctly in Russian. Smiley Surprised
 
May be it is a glitch. I think that the single right decision would be to recreate all problem controls.
 
 
0 Kudos
Message 10 of 19
(4,926 Views)