Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

How to set the language from Angular #9708


User avatar
0
brallierc created

This is not an issue, more of a question on what is the best way to do something....

The scenario is that I have a page that is sent to a guest via sms or email. The guest has a preferred language which the page reads from that repo. When the page loads I want the content to be in the language that is preferred for that guest.

I have all of the text localized so thats no issue

In my ngOnInit handler I have added code to set the cookie for the language, but once I set the cookie I have to refresh the page before it reads that cookie and then applies the language. It is kinda distracting for the user to see the page kinda load and then reload again with the correct language. Is there a way in angular to set the language without having to use that cookie?


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @brallierc

    You can tyr to set abp.localization.currentLanguage.name to the value you want.

  • User Avatar
    0
    brallierc created

    With this I still have to refresh the page for it to do anything. I was looking for a way to taggle the language on the page before it loads. See the issue is that I go to the page, it shows in english first and then from the ngOnInit handler I can set the language but the page is already showing english, so then I have to refresh the page for it to show the selected language.

    Any way around this?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @brallierc

    Nothing else comes to my mind at the moment. If this is important for you, please create an issue on GitHub and we will improve this functionality to allow your scenario.

    Thanks,