Multi-language button
AlainApplied
Posts: 2
Hi guys, I need to give the user the ability to switch the language of the text on my buttons. For example, the user will have the choice of either French or English for the text displayed on the buttons. What would you recommend as best method for achieving that? I am thinking of using a MSB with 4 states. First two for English text and last two for French text. My question, though, is how I will define that level 3 correspond to the OFF state and level 4 should be the ON state?
Thank you
Thank you
0
Comments
Multi-state bargraphs are more like what you want as you can manipulate the level in code and the multi-state bargraph can be drawn as a button with each state gioving the required feedback. To see a multi-state bargraph like this, open the system page template in TPD4 and look at the properties of the connection status indicator (red circle).
This can be driven from code as a level, but creating a level for each and every button, then manipulating that level for feedback depending on language selection will be too complicated, especially when you have multiple panels on a system.
I would look at creating an function that sets the button text based on selected language whenever the user chooses their preferred language, if you have a lot of buttons to send the commands to, create a "loading" page that shows for a couple of seconds while the entire panel is re-written and then periodically update the panel on no activity as well as on the ONLINE event so the panel language is synced in a multiple panel system.
I do this for the most part anyway since I fill things like TP navigation, source selection, lists of stuff, channel favorites, zone names, etc... all dynamically from code. It may sound a bit daunting but honestly, once you write the code for it, it's really easy. (and flexible)
If you are using this method, make sure you have "Enable _WC Preprocessor (Unicode)" enabled in the netlinx compiler options.
Then I used code like this to set up the language arrays:
I originally tried using the foreign characters in the netlinx code, but they didn't seem to encode properly all the time, so I would put the strings into TPD4 and copy back out the premade unicode strings that show up in the lower section of the text editing popup.
Also of note, make sure to do some queuing of the send commands to the touch panels, I had a lot more than just the 14 language resource elements listed here and it becomes easy to flood the interpreter or the panel if you loop around and try to send all those commands from one event.
And if you resend the strings in an online event, sometimes forcing a ton of commands out the second you see a panel show up can make it drop back off in an endless cycle.
All button state are recall from that file.
The file syntax look like this
[Channel][tab][inactive text][tab][active text][crlf]
Or
[Channel][tab][text][crlf]
If you need to correct syntax, update the files in the processor and press language button to load it.
Thanks everyone for taking the time to share your thought!