loserboy Posted April 3, 2009 Report Share Posted April 3, 2009 Hi All, I've read a bazillion posts, and help pages in the last two days and noone has directly answered the question on how to traverse through a front panels controls and save them to a text file for translation in a multi-lingual app. There's a BEAUTIFUL commercial toolkit (translate.vi) offered for 290 Euros at www.rofa.at, and another "toolkit" from another company for $4000 that does on the fly import and export, but i'd like to do something open source. Using the rofa idea, that's the direction i'd like to go in. There aren't alot of descriptive help docs on NI for dealing with generic references surprisingly and the best/only way to learn it is to see an example... Thanks to Stefan K. over on the NI forums for this little nugget http://forums.ni.com/ni/board/message?boar...d=266695#M74953 It was kinda the final brick in the wall... Attached is a rough working sample of the direction i think this vi has to go in... and with my feeble LV skills, maybe you guys can help point me in the right direction. This vi is only the front end, which will collect the refnums using the 'TRef Get All FP References.vi' and sort through the returned array of refnums using a huge case statement selected by 'ClassId' (please advise on this). Once we get the captions, (or text values in the cases of boolean ctrls), parsed out to a tab delineated text file, you'll have to do the manual translation. The import is going to be reading the text file strings and doing alot of string compares with the FP refnum caption/text properties. We'll worry about that once we get the front done. i'm thinking 'Read from spreadsheet.vi'. Have a look and see what i'm missing, or if i'm off track... Quote Link to comment
Yair Posted April 6, 2009 Report Share Posted April 6, 2009 Your example is missing the translate subVI. Also, you probably want to specify the format of the file better. I haven't done something like this myself, but I would try a tab delimeted text file for each language with the following columns: Label,Class ID, Caption, Strings... The key here is that the strings section changes based on the control class, as you've shown in your example. There is also a need to decide how much you keep (e.g. do you keep the strings in trees, listboxes and combo boxes?) as that may require a more complex architecture for saving. Also, note that I suggested using the label (for a lookup). This is safer than just using the order as you did, but can still break if the user changes the control label. Then, you need to decide how to translate the captions. If you have a tab delimited text file, you can simply let the user edit it manually, but that has potential for errors. You could write a GUI for this which would basically have a listbox and a subpanel with the list of controls. Then, selecting a control loads an appropriate VI into the subpanel for editing the strings for that control. If you want, you can use LVOOP for this which would simplify some of the saving and loading issues. Quote Link to comment
crelf Posted April 6, 2009 Report Share Posted April 6, 2009 Try this out - it's from one of our old internal reuse libraries. The dat file is "=" delimited text-based. It's not something we've done much work on in a long time and I know it's not feature complete, but it might help you find the direction you're looking for. It just searches through FP nodes for English labels and then replaces their respective captions with the corresponding selected language's equivalent. As with all the code I upload here: all care, no responssibility, so use it at your own risk. Quote Link to comment
loserboy Posted April 8, 2009 Author Report Share Posted April 8, 2009 QUOTE (crelf @ Apr 5 2009, 12:59 PM) Try this out - it's from one of our old internal reuse libraries. The dat file is "=" delimited text-based. It's not something we've done much work on in a long time and I know it's not feature complete, but it might help you find the direction you're looking for. It just searches through FP nodes for English labels and then replaces their respective captions with the corresponding selected language's equivalent. As with all the code I upload here: all care, no responssibility, so use it at your own risk. Thanks Guys, I knew ONE of the Maestros would give me a response! But Two, wow, my lucky day. :worship: This is a neat app Crelf, it's awesome how you had this "lying" around. I'll tell you now that i can see pilfering some of this code later... Using the Panel.Controls[] array in Translate GUI Elements.vi won't get you the refnums of nested controls like Tab Controls without setting up your own handler. The app that i've inherited is one big tab control. Using the traverseref.llb -> TRef Get All FP References.vi will get you everything. (Got that from a Jim Kring reference in one of those bazillion posts mentioned above). But then you have to deal with generic obj references. Quote Link to comment
loserboy Posted April 8, 2009 Author Report Share Posted April 8, 2009 QUOTE (Yair @ Apr 5 2009, 12:17 PM) QUOTE Your example is missing the translate subVI. Sorry! That vi wasn't supposed to still be there, it wasn't needed. I'll upload a more better one. Noob mistake! QUOTE There is also a need to decide how much you keep (e.g. do you keep the strings in trees, listboxes and combo boxes?) I think you'd want to save/export, translate, and import anything viewable to the user. Including front panels of any Vi's marked "Show Front Panel when called" or "Show Front Panel when loaded", although i don't know how to surf through the Vi heirarchy to find that property yet... QUOTE Also, note that I suggested using the label (for a lookup). This is safer than just using the order as you did, but can still break if the user changes the control label. We should export everything viewable w/o care of whether the labels or captions change. I regularly change odd labels that i run across from previous developers. (They were spanish, so i have to translate labels sometimes). Here's a scenario, The application has English captions. Export all the visible English strings to a tab delineated text file, Column 0, and remove all duplicate entries. If there are 50 buttons with OK (to be translated to "Comprende") we only need to know the OK -> Comprende relationship once. The user will HAVE to manually translate this column into column 2 (i.e. Spanish), or column 3 (i.e German). There are to many dialect differences to do it programmatically. So, English = Column 0, Spanish = Column 1 German = Column 2 ... With Ring control and Flag icons to choose which Language/column you want imported. QUOTE You could write a GUI for this which would basically have a listbox and a subpanel with the list of controls. Then, selecting a control loads an appropriate VI into the subpanel for editing the strings for that control. I found this little app on NI that does something of what your saying, it uses the XML import/export string function... could maybe plunder some ideas from this: http://zone.ni.com/devzone/cda/epd/p/id/2906 Quote Link to comment
crelf Posted April 8, 2009 Report Share Posted April 8, 2009 QUOTE (loserboy @ Apr 7 2009, 08:48 AM) This is a neat app Crelf, it's awesome how you had this "lying" around. I'll tell you now that i can see pilfering some of this code later... Using the Panel.Controls[] array in Translate GUI Elements.vi won't get you the refnums of nested controls like Tab Controls without setting up your own handler. The app that i've inherited is one big tab control. No worries - anytime. It should be pretty straightforward to expand it to include traversing tab control containers. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.