# Language Translation in Perspective - translating sentences with dynamic labels/texts

**URL:** <https://forum.inductiveautomation.com/t/language-translation-in-perspective-translating-sentences-with-dynamic-labels-texts/72855>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [April 25, 2023, 5:28am UTC](https://forum.inductiveautomation.com/t/language-translation-in-perspective-translating-sentences-with-dynamic-labels-texts/72855 "2023-04-25T05:28:30Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rohit\_Das](https://avatars.discourse-cdn.com/v4/letter/r/a6a055/32.png) [@Rohit\_Das](https://forum.inductiveautomation.com/u/Rohit_Das)\
**Post date:** [April 25, 2023, 5:28am UTC](https://forum.inductiveautomation.com/t/language-translation-in-perspective-translating-sentences-with-dynamic-labels-texts/72855/1 "2023-04-25T05:28:30Z")

</div>

Hi,

I'm trying to translate my perspective project from English to Spanish and I'm kind of stuck on how to translate some sentences with dynamic texts/popup labels.

For eg : "Do you want to move the [item] from [HELD] state to [RUNNING] ?"

For the above sentence, words inside [square brackets] are dynamic, so how can I translate the rest of the sentence keeping the dynamic words intact?

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [April 25, 2023, 5:46am UTC](https://forum.inductiveautomation.com/t/language-translation-in-perspective-translating-sentences-with-dynamic-labels-texts/72855/2 "2023-04-25T05:46:39Z")

</div>

You can first generate your text and then perform the translation.  
[https://docs.inductiveautomation.com/display/DOC81/system.util.translate](https://docs.inductiveautomation.com/display/DOC81/system.util.translate)

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [April 25, 2023, 5:47am UTC](https://forum.inductiveautomation.com/t/language-translation-in-perspective-translating-sentences-with-dynamic-labels-texts/72855/3 "2023-04-25T05:47:22Z")

</div>

we have a simular use case with the powerchart, and we need to translate all combination....

I suppose you need to post a feature request:

> **[Inductive Automation Feedback](https://ideas.inductiveautomation.com/)**
>
> Give feedback to the Inductive Automation team so we can make more informed product decisions. Powered by Canny.

If I want to translate all possible inputs, I have to create translation for :

Last 1 hours  
Last 2 hours  
…  
Last 8 hours  
…

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/1/71bbe762b6f45f7b054cc174f70299297163fb62.png)

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [April 26, 2023, 2:52pm UTC](https://forum.inductiveautomation.com/t/language-translation-in-perspective-translating-sentences-with-dynamic-labels-texts/72855/4 "2023-04-26T14:52:00Z")

</div>

Assuming that your dropdown text is being created with an expression function, you can combine the [stringFormat()](https://docs.inductiveautomation.com/display/DOC81/stringFormat) and [translate()](https://docs.inductiveautomation.com/display/DOC81/translate) expressions to do the work for you.

Something along the lines of  
`stringFormat(translate("Last %d hours"), hours))`

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [April 26, 2023, 3:13pm UTC](https://forum.inductiveautomation.com/t/language-translation-in-perspective-translating-sentences-with-dynamic-labels-texts/72855/5 "2023-04-26T15:13:59Z")

</div>

This is for the built-in popup of the powerchart...I don't have any control on bindings

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [April 26, 2023, 5:37pm UTC](https://forum.inductiveautomation.com/t/language-translation-in-perspective-translating-sentences-with-dynamic-labels-texts/72855/6 "2023-04-26T17:37:25Z")

</div>

Hmm... I checked with the Perspective team and they are telling me that component should be translating since 8.1.3. You would need to have a translation in place for the word "Last" and one in place for the units ('hour', 'hours', 'minute', 'minutes', 'second', 'seconds')

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [April 28, 2023, 2:59pm UTC](https://forum.inductiveautomation.com/t/language-translation-in-perspective-translating-sentences-with-dynamic-labels-texts/72855/7 "2023-04-28T14:59:09Z")

</div>

**Ignition 8.1.27**

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/7/07d373f019600000bdac52b259746f0d6ce07c18.png)

**Seems not working for me. Last 5 days is only translated if I add the Full term...**

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/b/fb8c36e14d824babcf20298913c4dae0a52ae428.png)

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [April 30, 2023, 3:22am UTC](https://forum.inductiveautomation.com/t/language-translation-in-perspective-translating-sentences-with-dynamic-labels-texts/72855/8 "2023-04-30T03:22:14Z")

</div>

I have to replaced date selection and conditional filtering with simpler components. Translators cannot be relied upon on these complex components.

---

<div class="post-metadata">

**Author:** ![Tim\_Carlton](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tim_carlton/32/52835_2.png) [@Tim\_Carlton](https://forum.inductiveautomation.com/u/Tim_Carlton)\
**Post date:** [May 1, 2023, 12:32pm UTC](https://forum.inductiveautomation.com/t/language-translation-in-perspective-translating-sentences-with-dynamic-labels-texts/72855/9 "2023-05-01T12:32:21Z")

</div>

His example has multiple variables to substitute, and word order is often different in other language. This makes position based substitution unwieldy - either you have to write your own string interpolation routines or the translated phrases are pidgin rather than native.

Are there any plans to implement string interpolation (name based substitution rather than ordinal)? That would eliminate a lot of opportunities for error, and many other development environments have implemented it. Ignition uses name based lookup in many other places as well.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [May 2, 2023, 8:29am UTC](https://forum.inductiveautomation.com/t/language-translation-in-perspective-translating-sentences-with-dynamic-labels-texts/72855/10 "2023-05-02T08:29:16Z")

</div>

You can use named parameters for the `string.format` function.  
I can't think of a proper example right now, so I'll be very abstract, but let's say you have this as your translation strings:  
en:

- s: "something {foo} other thing {bar}"
- foo: "the\_foo"
- bar: "the\_bar"

fr:

- s: "quelque chose {bar} autre chose {foo}"
- foo: "le\_foo"
- bar: "le\_bar"

```python
s = translate(s)
foo = translate(foo)
bar = translate(bar)
return s.format(foo=foo, bar=bar)

```

Didn't try, but I believe this should return either  
"something the\_foo other thing the\_bar"  
or "quelque chose le\_bar autre chose le\_foo"

edit: I just tried and it works:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/d/2df748e2006c13de75893dab96d7b378f274a72c.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/3/83fb9264a35138a24a6c50b0f61430dad293804c.png)

---

<div class="post-metadata">

**Author:** ![Tim\_Carlton](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tim_carlton/32/52835_2.png) [@Tim\_Carlton](https://forum.inductiveautomation.com/u/Tim_Carlton)\
**Post date:** [May 2, 2023, 11:28am UTC](https://forum.inductiveautomation.com/t/language-translation-in-perspective-translating-sentences-with-dynamic-labels-texts/72855/11 "2023-05-02T11:28:54Z")

</div>

Cool! Thanks. I didn't get that from the IU materials.

---

<div class="post-metadata">

**Author:** ![Christoph\_Strube](https://avatars.discourse-cdn.com/v4/letter/c/db5fbb/32.png) [@Christoph\_Strube](https://forum.inductiveautomation.com/u/Christoph_Strube)\
**Post date:** [November 2, 2023, 8:05am UTC](https://forum.inductiveautomation.com/t/language-translation-in-perspective-translating-sentences-with-dynamic-labels-texts/72855/12 "2023-11-02T08:05:40Z")

</div>

We are often having similar use cases for alarm texts. If there is a device multiple times in a machine and the device is having multiple fault messages, it creates a huge variation of messages and translations. The scripting approach doesn’t really work for us because we would have these issues in lots of places and would need a more generic solution.

For example: machine with 20 frequency converters. Every converter has 30 different fault messages, it means 600 different language keys.

I think something like the following would be very beneficial to the translation system of Ignition.

It would need to have 2 Features:  
~~----------------------------------------------------------------------------------------------------------------------------------~~

- **Nesting of Translations**

the opportunity to inject one translation into another by a Variable, that is coming from a string variable. This String also represents a language key that gets injected in the place where it is specified in the Translation.

**Example:**

**Key** : FaultDevice @'VarReason'@

**English Text:** The device is faulted because {Var\_Reason}

**Key:** Reason1

**English Text:** the Voltage is too low

**PLC variable:** Var\_Reason = Reason1

**Result** : The device is faulted because the voltage is too low

~~----------------------------------------------------------------------------------------------------------------------------------~~

- **Injection of variables in Translations**

Insert a variable value in a translation, to give additional Information about a fault.

**Example:** Temperature to high. Setpoint: @Var\_Setpoint@°C Actual: @Var\_actual Temperature@°C

**PLC variable** s: Var\_Setpoint = 200°C

Var\_actual Temperature =250°C

**Result:** Temperature to high. Setpoint: 200°C Actual: 250°C

 ![TranslationConcept](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/6/e6540f72e4df77b9c0ab19492e3618eaab40fa43.png)

We already talked about this with @Marco_Keller from our local Ignition supplier. I think something like this would benefit everyone here who has such issues.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 2, 2023, 11:53am UTC](https://forum.inductiveautomation.com/t/language-translation-in-perspective-translating-sentences-with-dynamic-labels-texts/72855/13 "2023-11-02T11:53:35Z")

</div>

The nesting request is not possible, I think. (More not recursion-safe than not possible, but unlikely to be safely solvable.)

Variable substitution is possible already, using printf-style placeholders. At least, from an SDK module. You might want to write a simple add-on to expose that functionality to scripts and expressions.

---

<div class="post-metadata">

**Author:** ![Tim\_Carlton](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tim_carlton/32/52835_2.png) [@Tim\_Carlton](https://forum.inductiveautomation.com/u/Tim_Carlton)\
**Post date:** [November 2, 2023, 12:47pm UTC](https://forum.inductiveautomation.com/t/language-translation-in-perspective-translating-sentences-with-dynamic-labels-texts/72855/14 "2023-11-02T12:47:33Z")

</div>

> [@Christoph\_Strube](#):
>
> Insert a variable value in a translation, to give additional Information about a fault.

That is what was being discussed here:

> [@pascal.fragnoud](#):
>
> You can use named parameters for the `string.format` function.
