Improve Expressions for Multi Languages
619
Views
4
Comments
On our RadarOn our Radar
Frontend (App Interfaces)

Would be nice to be possible to have expressions like this "some text {0} some other text", variable1

This would help us when taking care of translations since the text would be all together and beside that the variable can change place depending on the language. 

2014-02-07 17-02-43
Vasco Pessanha
Changed the category to
Frontend

Yes, definitely! I frequently use things like Replace("There are {0} items available", "{0}", NumItems). Would be nice to have this natively!

Changed the status to
On our RadarOn our radar

Hi Marcelo,

Indeed, having some kind of string interpolation would help in translations. Although we have no current plans to address this, we're adding it to our radar so we can consider it in the future.

Thanks a lot,
Tiago Simões

Definitely a must have with at least two improvements from what is currently possible:

  • It can improve the construction of expressions interpolated with variables, instead of the tedious and error-prone method of "Some text " + Variable + " some other text".
    • I constantly forget to place some of the spaces before/after the variable;
    • While constructing (usually bigger) expressions, keeping track of all the quotation marks (" ") and plus signs (+) requires needless mental effort from me.
  • It can improve the capability of translating the text. Right now, translators will see, in the example I gave, two things to translate: "Some text " and " some other text".
    • Often they don't understand the context when receiving this list of translations and takes them more time to translate than necessary or the translation is not what is intended, which the name of the Variable could clarify imediatelly (requires the developers to be cautious with naming variables, which is a good practice regardless);
    • Some languages have the entire structure of the sentence reversed and seeing the translation of "Some text " in the place of " some other text" (and vice-versa) to compensate for that causes a lot of confusion and is error-prone;
    • They always forget to place the spaces correctly in the end of the first part and the beginning of the second.


Since OutSystems is moving towards ReactJS, you could even implement it similarly to what JavaScript has with template literals (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals), where backticks (` `) are used to define the beginning and end of an expression and the dollar sign and curly braces as placeholders for an expression (${expression}). In the previous example, it would become: `Some text ${Variable} some other text`.

This similar implementation would avoid having different methods to construct variables in different parts of the platform, as it would only add more confusion to the developers.