Hi everyone,
when i change the language of my application the common blocks are not translated correctly. Attached you will find various screenshots that may be useful to you.
Do you happen to know what the problem could be?
A thousand thanks
Giacomo
ok,
these are the players in the game :
1) so the switcher block is just an example, you don't need it, whatever logic you already have in place to allow the user to choose a locale, or your application to choose a locale at start, IN THAT PLACE, you should update the client variable. So whenever the locale changes, update client variable.
2) that small OnChange block is a smart little helper to allow other screens or blocks to react to changes in any data inside their scope they are interested in. How it works is : It has an input, and whenever the value of that input changes, it detects that in it's OnParametersChanged, and it fires the Changed event to notify it's parent block that that particular variable has changed.
3) So the Listener has as only content that OnChange block (2), passing into it that client variable(1). The only logic it has : it passes the change event of that OnChange block up as a CurrentLocaleChanged event to it's own parent.
4) Any block or screen that uses text from a static entity to display, can put this listener block(3) on it's canvas, and handle the CurrentLocaleChanged event by refreshing the aggregate or DataAction retrieving the static entity.
here's how it unfolds in action :
Dorine
are you talking about the steps 1 - 2 - 3 - 4 at the left of the screen ?
maybe these are coming from a static entity ? In that case, you need to refresh your data everytime the language changes.
Hi Dorine,
The step on the left come from static entity.
How can I refresh it every time? The change language happened into another block..
Thanks
Ok,
so that's the reason.
You'll have to make sure that all blocks (or at least those showing labels of static entities) currently visible in the screen get notified of a change in locale, and react to it by refreshing their static entity aggregates/dataactions.
With the normal event triggering of Outsystems (you already have an OnLanguageChange trigger defined for that) passing up with events to the screen level, then passing down with OnParametersChanged to all underlying blocks.
Or if that's too much of a hassle because of the complexity of your screen and all it's parts, some DIY eventing / listening system.
See as a possible example how you could brew your own listening pattern for locale changes, look at blocks CurrentLocaleSwitcher, CurrentLocaleListener and OnChange, in combination with a CurrentLocale client variable.
This means you have to put a listener block in every scope (screen or block) that retrieves static entities, so you can go ahead and refresh those in the handler of that block's CurrentLocaleChanged event.
Hi Dorine, sorry but I'm having a hard time understanding how it works...
In the CurrentLocalSwitcher block I change the variable with the selected language.
I don't understand how CurrentLocaleChanged inside a CurrentLocaleListner can intercept the change... and why local listener have inside only OnChange block
I tried to follow the instructions and this is the result. I don't know what to put in the handler, see the attachment.
so you are going with the option to use the normal eventing system of Outsystems ? Yes ?
In that case, if your event is mandatory, all the parents of that menu block (i.e. all screens) will need to define a handler. I would not set it mandatory, you only need to handle it on those screens that have static entities somewhere.
I think you just added the DataChanged event for it, I don't understand, you already had the LanguagesChanged event ??
So on the screen with your wizard, you will add a handler for the event (i.e. attach an (existing or new) action to the event)
If your aggregate is in the screen, just refresh it in that handler action you just created.
If your actual aggregate is not in the screen, but in a block holding that wizard, you will need a way to pass the information that language has changed, into that block. Unfortunately, you can't use events for that, but the OnParametersChanged action of that block.
So one possibility :
You can see that the normal mechanism of Outsystems is a bit worthy / messy, especially if you have blocks several levels deep, I prefer to use my own.
As for the errors that were shown, it was because I had confused and created two identical events. Now the event propagates to all screens but I can't get it to the blocks used in the different screens. Is there a way or not?
yes, see all the bullet points under "So one possibility"
also, if this is overwhelming, make sure to (re)visit learning material on OnParametersChanged
Thanks, now it work!