relatively_random
relatively_random

Reputation: 5186

How to localize TwinCAT PLC project's string literals?

You can easily translate TwinCAT PLC's visualizations by just adding a translation to a text list and then editing the table. Unfortunately, this doesn't seem to work for string literals embedded in PLC code. For instance, formatted error messages with embedded descriptions like part counts, locations etc. At least I couldn't figure out how to access text lists from the PLC code.

I ran into project localizations which looked promising at first. You can generate standard gettext .pot templates and translate them with Poedit or whatever. You can then switch the language and voila, the whole project is translated. Unfortunately, this is apparently just a cosmetic change which doesn't affect the execution at all and variables still contain untranslated strings. You can't even login while translated.

Do I just not know how to properly use text lists and/or project localizations or are they really as half-baked as they seem?

Upvotes: 1

Views: 340

Answers (2)

Fred
Fred

Reputation: 7015

Obviously, I do not know your use case, but in my projects the answer to "How to localize TwinCAT PLC project's string literals?" is that you don't because there are no string literals containing natural language in the code.

Text intended to be read by humans resides at the presentation layer. The presentation layer can receive some kind of identifier (error code, error object path) that can then be used to retrieve a text element in the appropriate presentation language (which the PLC knows nothing about). If there is additional data, it is conveyed as structured data (read by the presentation layer), not as strings already prepared by the PLC.

Upvotes: 1

Roald
Roald

Reputation: 3007

As mentioned by Fred, that shouldn't be something in your PLC code. Instead, it should be in your HMI/presentation layer. An example on how to create localized texts in your HMI is on InfoSys.

Upvotes: 0

Related Questions