Skip to main content
1-Visitor
September 3, 2021
Question

Switch language preference on demand

  • September 3, 2021
  • 1 reply
  • 2167 views

Hey guys I have an application which logs in all Users as TVUsers and uses its own authentication system. I was hoping for there to be a way to switch languages on demand without setting the language preference for TVUser.

 

If that's confusing feel free to ask below. Thanks!

1 reply

5-Regular Member
September 6, 2021

Hi @AhsanKhan ,

Are you trying to change the language at Mashup Runtime?

 

Regards

Bhawna

AhsanKhan1-VisitorAuthor
1-Visitor
September 7, 2021

Yup! Is that possible? I basically want to switch the language without having to associate the language with any TW User. Is that possible?

5-Regular Member
September 8, 2021

Hi @AhsanKhan 

 

Kindly follow the steps:

  • Steps to set-up dropdown language selection:
    1. On any thing, create a service with the following line of Javascript code and two input parameters:
      • // input parameters are Username and Language, both strings
        Users[Username].SetLanguagePreferences({preferences: Language});
    2. On your mashup, add a list widget and configure it to appear as a dropdown box
    3. Import the service GetLanguages located under the entity RuntimeLocalizationFunctions in the Data tab and check the box labeled "Mashup Loaded?"
    4. Drag All Data from this to the dropdown list widget and bind it as Data
    5. Under DisplayField property, select "languageNative"
    6. Import the service created in step one in the Data tab
    7. Switch to the User tab
    8. Click and drag the name field to the Data tab so it switches back, then continue dragging down to the Username input parameter of the service created in step one
    9. Expand the Selected Row(s) section of the GetLanguages service
    10. Drag the name field to the Language input parameter of the service created in step one
    11. Drag and drop a button onto the mashup
    12. Drag the Clicked event of the button to the service created in step one
    13. Grant runtime service execute permissions to the Users group on the thing with the service created in step one
    14. Grant mashup visibility to any organizational unit which contains the Users accessing this mashup.

Let me know if this works for you.

 

Regards

Bhawna