Author Topic: change language on labels and buttons  (Read 1040 times)

Holmux

  • Newbie
  • *
  • Posts: 34
    • View Profile
change language on labels and buttons
« on: May 17, 2020, 04:31:09 PM »
Hi
I have a project where I need to be able to change the language and have been searching for the best solution, the perfect solution would be a setup where the customer would be able to edit the translation, for example in a text file.

Or do i make a local db and use the databinding setup ?

/Holmux

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5268
    • View Profile
    • AdvancedHMI
Re: change language on labels and buttons
« Reply #1 on: May 17, 2020, 05:09:43 PM »
Several years ago I did a project that required switching between languages. The method I used was a text file that had a row for every translation. The for format was English then a comma and the translation. I had written an elaborate piece of code that searched all objects for phrases that were in the translation file and switched the text.

.NET has a built in feature called localization for multi-lingual applications. The idea is to have multiple DLLs with forms for each language. This is all compiled so the user cannot change the translations.

Holmux

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: change language on labels and buttons
« Reply #2 on: May 17, 2020, 06:03:42 PM »
Thanks Archie

I had a feeling it would not be that easy :)

This project is for a customer in France and they are very picky with the translation, I am sure no mater how much work I put into it, they will have some corrections.
The next machine will be Germany, so I am ready to put some work into a good solution

I have a feeling that must of the words I need to translate er not going to be in the list in .net, so I am leaning against a text solution or local DB.

Thanks again

Gene T.

  • Newbie
  • *
  • Posts: 42
    • View Profile
Re: change language on labels and buttons
« Reply #3 on: July 15, 2020, 10:43:13 PM »
I have a need for this as well. I created a user defined Data type(I called Language) with 72 different string variables. I then created three tags(Language as type)... Display_Text, English_Text, Spanish_Text. Then I assigned the string values to each tag ie English_Text.SystemPressure is assigned System Pressure. The Spanish_Text.SystemPressure is assigned the translated text for System Pressure. Then anywhere I want to use System Pressure as my label text I set the plcaddressvalue to Display_Text.SystemPressure. Also created a boolean tag called Alternate_Text. A few lines of code in the PLC....
IF Not Alternate_Text Then
    Display_Text := English_Text;
Else
    Display_Text := Spanish_Text;
End_If;

I am not sure if this is a valid solution or not as I am still testing to see if any problems arise. The one problem I found that seems to be the deal breaker for me, is if the need for Chinese, Korean, or any similar language is needed.
Maybe someone has done been here so feel free to stop me if I am on the wrong path.