Forum Migration Notice
We're transitioning to a more modern community platform by beginning of next year. Learn about the upcoming changes and what to expect.

Is it possible to combine a key and literal constant?

I want to use the translation function for parts of the text in a label so I dont have to translate the same word more than once.

For example.
I want to show 4 texts to show the status of Vacuum 1 - 4, but I do not want to have 4 translation keys. It does not seem to be possible to use !!Vacuum!! 1 and so on.
//Markus Näslund
Tagged:

Best Answer

  • yitong
    yitong
    edited December 2025 Answer ✓

    Hi, do you want to use code to parse the current multilingual entries in AppStudio?

    You've noticed that App Studio uses !! + key name + !! as the multilingual key, but if you want to dynamically retrieve its value, you can use TComponents.Component_A.t('key name') to get its value.

    like:

    const stringTest = TComponents.Component_A.t('vacuum') + String(index);


    AppStudio is about to release a new version. In the new version, you can get help by referring to the API Documentation. Hope this helps 😆.

    TComponents.Component_A.html#.t

    Post edited by yitong on

Answers

  • Hi, you can use classic approach to build custom strings. Like for example: const stringTest = `${string1} ${string2}`; Or you can just add two strings like const stringTest = translatedString + String(index);
  • Hi,

    I don't think you have fully understood my question.
    I know how to combine strings in javascript. What I want is to do it without breaking the translation function in AppStudio. 

    I have been trying to combine a translation key with additional text, but so far I have not been able to get the key to translate when it is concatenated with other strings.

    If there is a supported way to combine a !!key!! with other values (for example, an index or suffix), I would really appreciate seeing a concrete code example that demonstrates how this should be done.

    For reference, the following does not work in my case, as !!vacuum!! is not replaced with its translated value:

    const stringTest = "!!vacuum!!" + String(index);
    

    Thank you in advance for any clarification or guidance you can provide.

    //Markus Näslund
  • Thank you! That is exactly what I’m looking for. 
    //Markus Näslund
  • What did I miss here?  It doesn't work and then it does?
    Lee Justice
  • lemster68 said:
    What did I miss here?  It doesn't work and then it does?
    The response from yitong answered my question, it popped to the top as is was marked best answer
    //Markus Näslund
  • Oh, I see.  Thanks for clarifying that.  👍
    Lee Justice