Jump to content

Multilangugae User Interface of VI


MViControl

Recommended Posts

Hi,

Is anybody have experience to create MUI(multilanguage User Interface) in LabVIEW? Can you please share?

We use some vis that enable dynamically changing between certain languages like english, French, German etc. I canot share the code because they are owned by the company but (as I wrote them) I can tell you how they work. There may be others who are not restricted to share. The key is really not to "hard-code" strrings into the diagrams and takes a little bit more thought but is fairly easy to do. don't talk to me about Japanese or Chinese however...lol.

They take advantage of labels and captions for controls and indicators. The Label is used as the "tag" and the Caption is what is displayed to the user. Display strings are a bit more complicated, but not much.

A create language file vi is used to iterate through all labels in the app and save them to a" bar" separated spreadsheet file. We use the bar "|" symbol because it then allows the use of commas, semicolons etc in the text. This file is then sent off to the translators and they add the words (or phrases) for the other languages on the same line for each language (first column English, second French, third German....etc).

A change language file vi is used to load the file and iterate through all the labels changing the captions to the specific language. You have to check the control type as for things like boolean indicators, its not the caption the user sees. Job done for controls and indicators. This can be invoked at any time and the current language is saved to a config file so that the software starts up in the last used language.

Display strings in the code are always preceded with a get language file vi that takes a string as an arguement (the tag as described above) and outputs the corresponding word/phrase in whatever language is chosen to be active. I've been meaning to get around to including a digram search for these tags so they can automagically be added with the create language file vi, but I've more important fish to fry.

Thats basically it. It shouldn't take you very long to write something yourself, or I suspect others on this forum have similar tools that they can share.

Edited by ShaunR
Link to comment

Argh! Are ye wantn' to convert yer language to Pirate? Today is the official talk like a pirate day!

To get a list of yer controls:

  • Connect a property node to a refernece of the VI and select "Panel"
  • Take the "Panel" ref out to a second property node and select "Controls"
  • Now you can use the "Controls" refs to read the label and set the caption.

Some things to consider.
  • Do you have controls inside controls? - Clusters, Tabs
  • Do you want to display a caption for each control? - Tab Conrol?
  • Do you have enough area to display the translated text?
  • Will your text grow in the correct direction?

post-151-125336674226_thumb.png

Control Refs.vi

Edited by gleichman
Link to comment

Thanks Mates,

It has been proved that the option is a good one.

I had create a very simple vi try to indicate the idea( gleichman and Jean-Marc, I haven't use your great code in the example yet, but it will support the real develope later:).

In the example:

1) when if case is true, the vi will create a "test.ini" to save all label and its caption, while the label is a tag;

2) after translate the "test.ini" to other language(even Chinese and Japanese:), shift the if case to false to load the language.

as gleichman mentioned, when creating a complicated application which include cluster, array etc ,then the iterate function need to be optimized.

mul.vi

Link to comment

Thanks Mates,

It has been proved that the option is a good one.

I had create a very simple vi try to indicate the idea( gleichman and Jean-Marc, I haven't use your great code in the example yet, but it will support the real develope later:).

In the example:

1) when if case is true, the vi will create a "test.ini" to save all label and its caption, while the label is a tag;

2) after translate the "test.ini" to other language(even Chinese and Japanese:), shift the if case to false to load the language.

as gleichman mentioned, when creating a complicated application which include cluster, array etc ,then the iterate function need to be optimized.

mul.vi

I function much like ShaunR. I have a text file translation (spreadsheet): the first column corresponds to tags (full names in my case), the second column is the Language 1 (French), the third column is the language 2 (English), etc.. When the main VI starts, it reads this text file and the default language (first line of the spreadsheet file). The file is transfered in a 3D array. The cell "i,0,0" contains a tag associated with a particular VI (a VI who needs translation).

When I call a VI, if translation is needed, I send to him the corresponding 2D array.

This part is not included in the attachment.

For all VIS who need translation, I read the references of the controls (visible in the pane). I search in the 2D array to find the tag and I write the text in the proper caption, ring text, tab caption, XY Graph axes, etc.

This second part is included in the attachment.

Jean-Marc

TraductionLV86.zip

Link to comment

Here's some pretty old stuff that I did that should do what you want. I used the same method (get a ref to the UI element, get the label, look up the label in a file, change the caption of the UI element to the new language). One thing is missing though - I don't see the language file. I'm pretty sure it was a tab-delimited text file with a header that had "English" as the first item then each language named as the columns, then each line was a translation with the English as the first column. eg:

English <tab> French <tab> Spanish <cr+lf>

Where is the toilet? <tab> Ou sont les toilettes? <tab> ¿Dónde está el baño? <cr+lf>

I like eggs <tab> J'aime les oeufs <tab> Me gustan los huevos <cr+lf>

Do not press this button <tab> Ne pas appuyer sur ce bouton <tab> No presione este botón

Programming.Dialog_&_User_Interface.Translate.zip

Link to comment
  • 2 weeks later...

I made a Localization Configuration Editor and for NI week this year.

http://zone.ni.com/d...a/epd/p/id/6257

It helps you to create/edit a resource file with all your translations. Then there is a library that helps you pull the information from the resource file into your application. Its all open source if you want to give it a try.

Looks like your doing it the hard way :P

Link to comment

Looks like your doing it the hard way :P

It certainly took some effort to make the editor. Hopefully it gets some use. The nice thing about a single file is transportability. Also grouping translations into resources helps with accessing data if you want to change the language setting at run-time. Plus the editor helps you organize resources into folders, so all the controls for a single VI can go into folder. Just makes it pretty.

Link to comment

It certainly took some effort to make the editor. Hopefully it gets some use. The nice thing about a single file is transportability. Also grouping translations into resources helps with accessing data if you want to change the language setting at run-time. Plus the editor helps you organize resources into folders, so all the controls for a single VI can go into folder. Just makes it pretty.

Indeed. From the usage point of view it look on the face of it to be nice and easy to access from within the code and you certainly have created a sleek interface.

I'm not sure how time consuming it would be to create 5 translations for 300-400 controls though. Also, what if (as in my case) the developer is not the translator?

Link to comment

I'm not sure how time consuming it would be to create 5 translations for 300-400 controls though. Also, what if (as in my case) the developer is not the translator?

Well, it is not really translations of controls, so much as resources. Naming the resource and control the same thing makes it easier on the developer though. Looking at the article would probably clear that up. The translator and the developer can be different people, as long as they have agreed upon the resource naming convention. I assume that's how most applications provide run-time translations.

Link to comment
I'm not sure how time consuming it would be to create 5 translations for 300-400 controls though. Also, what if (as in my case) the developer is not the translator?

The last job I did that required translations had a bunch of them, and the file format our translation code uses was compatible with the output we got from the translation services (they would give us an Excel file, we would save it as tab-delimited ASCII and we were done).

Link to comment

The last job I did that required translations had a bunch of them, and the file format our translation code uses was compatible with the output we got from the translation services (they would give us an Excel file, we would save it as tab-delimited ASCII and we were done).

Same here. ;)

Watch this space.

Edited by ShaunR
Link to comment

Link is borken. wink.gif

I think it needs to be approved or something. It doesn't appear in my file list but I can see it in the repository and edit/download etc (and its a different colour to the others). If I click on the link its there, so must be just the uploader until its approved.

Edited by ShaunR
Link to comment
I think it needs to be approved or something. It doesn't appear in my file list but I can see it in the repository and edit/download etc (and its a different colour to the others). If I click on the link its there, so must be just the uploader until its approved.

That's right - your submission has to be reviewed and approved by a "LAVA Certified" team member. It's one of the strengths of the LAVAcr over other forum reposotories - we only let code in that meets the LAVAcr standards.

Link to comment

That's right - your submission has to be reviewed and approved by a "LAVA Certified" team member. It's one of the strengths of the LAVAcr over other forum reposotories - we only let code in that meets the LAVAcr standards.

And these " LAVAcr standards" are documented where?

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.