02-05-2010 02:01 PM
Hi,
I need to adapt my CVI application to multiple languages. But I have to be able to do this on the fly. The Localizer is great for all the panel objects and this works great. But I was wondering what the best method is for all the dialog box text? Right now I'm using const char defines for the text. For exampl:
const char *CONST_NO_STRING = "No";
Is there a simple method, or best practice method, to load different language dialog text at run time or on the fly?
Thanks,
Andy
02-08-2010 04:26 PM
What kind of "Dialog Box" are you using?
One suggestion would be to create a new Panel to resemble your Dialog Box then call LoadLocalizedPanel() to load the localized version of this new panel.
There is an example in the CVI Example Finder for reference:
Help>>Find Examples...>>Search for "localization">>intgraph.cws
Let me know if this helps.
Regards,
02-10-2010 12:35 PM
I think Andy is more concerned with the content that he puts into controls (list boxes, text, etc.). All that text is specific to his application and what it needs to report to the user - not simply a control label which can be handled by functions like LoadLocalizedPanel.
I'm very interested in further responses to his question.
--Ian
02-11-2010 03:07 AM - edited 02-11-2010 03:15 AM
Well, since I do not know of any reliable auto-translator, someone has to hand-write them.
To have them accessible by the code there would be 2 trivial options for me:
- Write all language strings inside code
- Write them in a text file (all in one file or one file for each language)
The first approach is not maintainable and it becomes a pain to update the executable for each single change in a string.
So it is logic to choose the second option.
I have seen many programs, not specificly of CVI origin, that use this method (and requests user to submit a file for his/her native language if none available in community) to give multilanguage support.
To simplify the file parsing one can use the INI-file library of CVI.
02-11-2010 03:50 AM
I second ebalci in his anaisys. External file approach is more flexible and easier to maintain over time.
By the way, this methods appears at the basis of user interface localizer: if you happen to look into the generated .LWL files you will see all UI elements translations in a ini-style fashion.
02-11-2010 05:28 AM
I think that an external text file is the best approach.
The only problem is when you want to load multibyte languages from the text file into controls...
(With CVI 9.0 it's easy to use multibyte languages with the localizer)
I think it could be done (as some documents in the knowledgebase explain) but it's an hard job....
Am I right?
02-11-2010 04:36 PM
Not sure if Andy's original concern was settled... but let's try and button this up:
- The UI Localizer does use a text file with manually-written translated strings for each supported language
- From the Localizer help: this will only aid in translating the panel labels.
Use this instrument driver to easily display user interfaces in different languages. When loading a panel or menu bar, you can specify a language file that contains translations for all the labels on the panel and all the menu items. You can create different language files for the user interfaces by translating them with the User Interface Localizer utility (localui.exe).
- If you have additional content to be translated (like the text inside a drop down box), manually loading from .lwl, or similar, files and programmatically setting those dialog box entries would be the solution.
- Looks like CVI should handle multibyte languages just fine (see below), though I have never used them.
To close, these 2 devzones are good references:
http://zone.ni.com/devzone/cda/tut/p/id/4036
http://zone.ni.com/devzone/cda/tut/p/id/3841
Regards,