View previous topic :: View next topic |
Author |
Message |
uw
Joined: 20 Nov 2017 Posts: 2 Location: Germany
|
Posted: Mon Nov 20, 2017 3:12 pm Post subject: Translation of external texts |
|
|
Right now I´m evaluating Globalizer if it fits our needs for translation.
We are running a WPF application and have to show texts from an external control (plc).
Is it possible to translate texts we are getting from a control using resx files ? |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Nov 20, 2017 9:34 pm Post subject: |
|
|
Do you mean the text is coming from a Programmable Logic Controller (PLC)?
Do you have any control over the text that it produces? If so the easiest solution is to have it send a short resource key instead of the actual text - then you use that to look up the text to display.
If the PLC is sending (for example) English text and you can't change that then one possible solution is to use the String.Hash function to create a unique key for each piece of text and then use the Hash as a resource key to lookup other languages. This will only work if the text is static - if it changes because, for instance, the PLC inserts times or names into the text then this won't work. In this case you would have to try a more sophisticated approach, for example using Regular Expressions to extract the static text, then translating that and reinserting the dynamic text. _________________ Infralution Support |
|
Back to top |
|
|
uw
Joined: 20 Nov 2017 Posts: 2 Location: Germany
|
Posted: Tue Nov 21, 2017 7:58 am Post subject: |
|
|
Infralution wrote: | Do you mean the text is coming from a Programmable Logic Controller (PLC)?
Do you have any control over the text that it produces? If so the easiest solution is to have it send a short resource key instead of the actual text - then you use that to look up the text to display.
If the PLC is sending (for example) English text and you can't change that then one possible solution is to use the String.Hash function to create a unique key for each piece of text and then use the Hash as a resource key to lookup other languages. This will only work if the text is static - if it changes because, for instance, the PLC inserts times or names into the text then this won't work. In this case you would have to try a more sophisticated approach, for example using Regular Expressions to extract the static text, then translating that and reinserting the dynamic text. |
Yes we are talking about a "Programmable Logic Controller". We receive an invariant text and have to translate it. The PLC is not able to send us a resource key. How can we handle such an scenario with Globalizer ? We are able to put all PLC texts in a resource or XML file. How do we get the translated text if we only have the invariant text from the PLC ? |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Nov 21, 2017 9:55 am Post subject: |
|
|
Does the invariant text ever change (or parts of it change)?
If it is always the same then you can take a list of all the possible text and then for each use the String.Hash() function to create a unique key for each possible text eg
Code: | string invariantText = "This is some text";
string resourceKey = invariantText.Hash().ToString();
|
You can then create a resources file with the resourceKey and Invariant Text which you will be able to translate using Globalizer.
When you receive a message from the PLC you can then retrieve the localized resource by doing something like:
Code: | string invariantText = PLC.GetText();
string resourceKey = invariantText .Hash().ToString();
string localizedText = Properties.Resources.ResourceManager.GetString(resourceKey); |
If your text changes or has things that vary in it (like dates, times etc) then it is a bit more complicated. _________________ Infralution Support |
|
Back to top |
|
|
|