Jump to content


Photo
- - - - -

Multilangugae User Interface of VI


  • Please log in to reply
26 replies to this topic

#1 Techie

Techie

    Very Active

  • Members
  • PipPipPip
  • 61 posts
  • Version:LabVIEW 8.6
  • Since:2000

Posted 19 September 2009 - 10:04 AM

Hi,
Is anybody have experience to create MUI(multilanguage User Interface) in LabVIEW? Can you please share?
Broaden the machine vision an automation way

#2 ShaunR

ShaunR

    LabVIEW Archetype

  • Members
  • PipPipPipPipPipPip
  • 2,224 posts
  • Version:LabVIEW 2009
  • Since:1994

Posted 19 September 2009 - 11:48 AM

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, 19 September 2009 - 12:10 PM.

A positive attitude may not solve all your problems, but it will annoy enough people to make it worth the effort. (Herm Albright 1876-1944).

Founder and general mischief maker on www.labview-tools.com.
SQlite aficionado and websocket zealot.
If it 'aint in LabVIEW, then you 'aint got a clue!

#3 Techie

Techie

    Very Active

  • Members
  • PipPipPip
  • 61 posts
  • Version:LabVIEW 8.6
  • Since:2000

Posted 19 September 2009 - 12:27 PM

Hi ShaunR,

Your option is exactly what I thought before.

I try to use the captions of controls and indicators to show different language to user, while use the labels to identify them.

But how can I iterate through all labels in a vi? this puzzeled me for days and I belive this is last step for me to finalize my application.
Broaden the machine vision an automation way

#4 gleichman

gleichman

    Very Active

  • Members
  • PipPipPip
  • 140 posts
  • Location:Plymouth, Michigan
  • Version:LabVIEW 2011
  • Since:1993

Posted 19 September 2009 - 01:00 PM

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?

Control Refs.png
Attached File  Control Refs.vi   16.7K   197 downloads

Edited by gleichman, 19 September 2009 - 01:27 PM.


#5 Jean-Marc

Jean-Marc

    I want a LabVIEW icon under my name!

  • Members
  • 3 posts

Posted 19 September 2009 - 04:05 PM

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


I modified Get All Controls reference.vi (http://zone.ni.com/d...a/epd/p/id/2902) to obtain the references in the pane.


Jean-Marc

Attached Files



#6 Techie

Techie

    Very Active

  • Members
  • PipPipPip
  • 61 posts
  • Version:LabVIEW 8.6
  • Since:2000

Posted 20 September 2009 - 12:55 AM

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.
Attached File  mul.vi   23.08K   245 downloads
Broaden the machine vision an automation way

#7 Jean-Marc

Jean-Marc

    I want a LabVIEW icon under my name!

  • Members
  • 3 posts

Posted 20 September 2009 - 03:09 PM

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.
Attached File  mul.vi   23.08K   245 downloads


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

Attached Files



#8 ShaunR

ShaunR

    LabVIEW Archetype

  • Members
  • PipPipPipPipPipPip
  • 2,224 posts
  • Version:LabVIEW 2009
  • Since:1994

Posted 20 September 2009 - 10:52 PM

The other way of course is to have one file for each language and your software just switches between files.
This makes life a lot easier for the translators, but means you have to coordinate updates to multiple files.
A positive attitude may not solve all your problems, but it will annoy enough people to make it worth the effort. (Herm Albright 1876-1944).

Founder and general mischief maker on www.labview-tools.com.
SQlite aficionado and websocket zealot.
If it 'aint in LabVIEW, then you 'aint got a clue!

#9 crelf

crelf

    I'm a LAVA, not a fighter.

  • V I Engineering, Inc.
  • 5,742 posts
  • Version:LabVIEW 2012
  • Since:1993

Posted 21 September 2009 - 03:22 AM

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

Attached Files


post-181-1170858537.png


#10 Jean-Marc

Jean-Marc

    I want a LabVIEW icon under my name!

  • Members
  • 3 posts

Posted 01 October 2009 - 01:37 PM

I saw that a few people have downloaded the files. Do you have any comments or suggestions to improve them?

Thanks

Jean-Marc

#11 crelf

crelf

    I'm a LAVA, not a fighter.

  • V I Engineering, Inc.
  • 5,742 posts
  • Version:LabVIEW 2012
  • Since:1993

Posted 01 October 2009 - 02:07 PM

I saw that a few people have downloaded the files. Do you have any comments or suggestions to improve them?

If ya'll think it's worthwhile enough, I'm happy for someone to toss it into the LAVA Code Repository.

post-181-1170858537.png


#12 GoGators

GoGators

    Very Active

  • NI
  • 68 posts
  • Location:Austin, TX
  • Version:LabVIEW 8.6
  • Since:2006

Posted 01 October 2009 - 02:39 PM

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.
I love it when a plan comes together.

#13 hooovahh

hooovahh

    The 500 club

  • Members
  • PipPipPipPipPip
  • 777 posts
  • Version:LabVIEW 2011
  • Since:2004

Posted 01 October 2009 - 03:04 PM

Very cool, I know internally we had a multilingual tool but it was only used once or twice, it isn't often we need to write interfaces. This looks much more refined.

"Maybe Hoovah is really Crelf's alter-ego, which he uses to irk people?" - Gary Rubin

"Seemingly minor changes....can mean the difference between a working app and a quivering heap of unresponsive code." - David Boyd


#14 ShaunR

ShaunR

    LabVIEW Archetype

  • Members
  • PipPipPipPipPipPip
  • 2,224 posts
  • Version:LabVIEW 2009
  • Since:1994

Posted 01 October 2009 - 04:58 PM

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
A positive attitude may not solve all your problems, but it will annoy enough people to make it worth the effort. (Herm Albright 1876-1944).

Founder and general mischief maker on www.labview-tools.com.
SQlite aficionado and websocket zealot.
If it 'aint in LabVIEW, then you 'aint got a clue!

#15 GoGators

GoGators

    Very Active

  • NI
  • 68 posts
  • Location:Austin, TX
  • Version:LabVIEW 8.6
  • Since:2006

Posted 01 October 2009 - 06:39 PM

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.
I love it when a plan comes together.

#16 ShaunR

ShaunR

    LabVIEW Archetype

  • Members
  • PipPipPipPipPipPip
  • 2,224 posts
  • Version:LabVIEW 2009
  • Since:1994

Posted 01 October 2009 - 07:13 PM

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?
A positive attitude may not solve all your problems, but it will annoy enough people to make it worth the effort. (Herm Albright 1876-1944).

Founder and general mischief maker on www.labview-tools.com.
SQlite aficionado and websocket zealot.
If it 'aint in LabVIEW, then you 'aint got a clue!

#17 GoGators

GoGators

    Very Active

  • NI
  • 68 posts
  • Location:Austin, TX
  • Version:LabVIEW 8.6
  • Since:2006

Posted 01 October 2009 - 07:21 PM

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.
I love it when a plan comes together.

#18 crelf

crelf

    I'm a LAVA, not a fighter.

  • V I Engineering, Inc.
  • 5,742 posts
  • Version:LabVIEW 2012
  • Since:1993

Posted 01 October 2009 - 08:38 PM

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).

post-181-1170858537.png


#19 ShaunR

ShaunR

    LabVIEW Archetype

  • Members
  • PipPipPipPipPipPip
  • 2,224 posts
  • Version:LabVIEW 2009
  • Since:1994

Posted 01 October 2009 - 09:05 PM

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, 01 October 2009 - 09:09 PM.

A positive attitude may not solve all your problems, but it will annoy enough people to make it worth the effort. (Herm Albright 1876-1944).

Founder and general mischief maker on www.labview-tools.com.
SQlite aficionado and websocket zealot.
If it 'aint in LabVIEW, then you 'aint got a clue!

#20 ShaunR

ShaunR

    LabVIEW Archetype

  • Members
  • PipPipPipPipPipPip
  • 2,224 posts
  • Version:LabVIEW 2009
  • Since:1994

Posted 03 October 2009 - 09:40 PM

Same here. ;)
Watch this space.

Watch this space insted.

PassaMak
A positive attitude may not solve all your problems, but it will annoy enough people to make it worth the effort. (Herm Albright 1876-1944).

Founder and general mischief maker on www.labview-tools.com.
SQlite aficionado and websocket zealot.
If it 'aint in LabVIEW, then you 'aint got a clue!