67
Views
7
Comments
Solved
Translate page titles
Question

Dear community,

I have a built a multilingual application in OutSystems P11, reactive. 

All my pages have been given a title. However, I cannot seem to find a way to translate these titles. 

They are not expressions, so GetTranslations() does not work. And I cannot add the data-trans attribute. Has anyone else encountered this challenge and found the (probably very simple) solution? 

Thank you,

Liesbeth

Rank: #224
Solution

Hi Liesbeth,

For a workaround, you can use the 'OnRender' event of Screen and can use the following JS(mentioned in the screenshot) to update the page title at the run time. 


Hope it helps

Thanks,

Sachin

Rank: #2371

Hey Sachin, 


I thought this was going to be simpler than that but I'm just happy there is a solution. 

Thank you so much, 

Liesbeth


Staff
Rank: #20

Hi Sachin, Liesbeth,

Sachin solution is right. I would just put that JavaScript inside a Client Action (e.g. called SetPageTitle) inside a Library, so I could reuse it in other places. I would also put this on the OnReady (or on the OnAfterFetch, if I need data from the server in the title), instead of the OnRender. OnRender runs too many times and should be used as little as possible.

Cheers,
Tiago Simões




Staff
Rank: #20

Hi Sachin,

You are right, it needs to go on the OnRender. To make it work on the OnReady you would need to change the code to 

setTimeout(function(){document.title = $parameters.ScreenTitle;}, 0);


You should do it on the OnAfterFetch of a Data Action or Screen Aggregate only if you need to put text from the database in the title.

Cheers,
Tiago Simões