Developer forum

Forum » Development » User able to set preferred language

User able to set preferred language

Jon Lennryd
Reply
Hello!

Which is the simplest way to set the language in dynamicWeb? I would like to have a field in the user's profile where he can set his preferred langugage. The default way to handle languages in dw is, as I know of, as a parameter in the adress field.
I could use OnNotify() with the appropriate notifier, f ex. pageload. But this would mean a redirect on each page load! Is there any session-variable I can set once upon login I don't know of?

Thank's for any help!


Replies

 
Morten Snedker
Reply
This post has been marked as an answer
 Hi Jon,

If it is upon user login you may want to use the notification for user login:

 [Subscribe(Dynamicweb.Notifications.Standard.User.OnExtranetLogin)]
    public class NotificationSubscriber1 : NotificationSubscriber
    {
        public override void OnNotify(string notification, Dynamicweb.Extensibility.NotificationArgs args)
        {
            Dynamicweb.Notifications.Standard.User.OnExtranetLoginArgs userArgs = (Dynamicweb.Notifications.Standard.User.OnExtranetLoginArgs)args;
            
            switch(userArgs.User.get_Information("PreferedLanguage").ToString())
            {
                //your stuff
            }
        }
    }

Best regards
Morten Snedker


Votes for this answer: 0

 

You must be logged in to post in the forum