Hello,
I would like the user to be able to select his preferred language.
My current solution redirects the user upon login to a landing page in his preferred language. This is working, but when I later try to get the area language, it is pointing on another language.
Example:
PageView.Current().Area.get_Value("areaecomlanguageid");
I expected it to return the ecom language id of the current page. Instead it is returning 'LANG2' for no obvious reason.
I tried to set the language with PageView.Current().Area.set_Value(), but this does not work.
As the site must handle both logged in users and anonymous users, I cannot fetch the preferred language on each page load.
Thank's for any help!
Developer forum
E-mail notifications
User selectable language
Jon Lennryd
Posted on 31/08/2011 17:51:08
Replies
Nicolai Høeg Pedersen
Posted on 01/09/2011 09:44:40
Use eCommerce.Common.Context.Language or eCommerce.Common.Context.LanguageID
Jon Lennryd
Posted on 02/09/2011 09:46:48
Hello Nicolai, I tried your idea, but the code below still returns the 'old' language id after a page reload:
PageView currentView = PageView.Current();
DebugMessage("Current language: " + (string)currentView.Area.get_Value("areaecomlanguageid"));
I want the area/website module to understand that I want to 'enter' the, in this case, Swedish area.
PageView currentView = PageView.Current();
DebugMessage("Current language: " + (string)currentView.Area.get_Value("areaecomlanguageid"));
I want the area/website module to understand that I want to 'enter' the, in this case, Swedish area.
Jon Lennryd
Posted on 02/09/2011 10:02:52
But as far as it concerns eCommerce, yes, your code above is working.
Nicolai Høeg Pedersen
Posted on 02/09/2011 10:08:47
You are asking for the property "areaecomlanguageid" which is the default ecommerce language for that area. That value will never change unless you do it from administration. Changing it affects all users on that area.
Context.LanguageID is the ecommerce language of the current user in the current context.
So - what are you actually trying to achieve? Change the eCommerce language or the website language? If it is the latter, redirect to another areaid.
Context.LanguageID is the ecommerce language of the current user in the current context.
So - what are you actually trying to achieve? Change the eCommerce language or the website language? If it is the latter, redirect to another areaid.
Jon Lennryd
Posted on 02/09/2011 14:51:54
I try to change the website language. So how do I redirect to another areaid?
And when I have redirected to another areaid, does the property "areaecomlanguageid" change accordingly? If not, which property should I look for?
And when I have redirected to another areaid, does the property "areaecomlanguageid" change accordingly? If not, which property should I look for?
Jon Lennryd
Posted on 02/09/2011 16:09:46
Sorry, I was a bit unclear. I understand now what you are saying about the 'areaecomlanguageid'. It's fine the way it is, the connection between eCommerce and Area/Website is working fine.
What I want to do is simply to change the website language. I tried to redirect user to a page into the area/website, which works. What I can't seem to find out is where I should look to find the current area/website id? Since 'areaecomlanguageid' is wrong, which property should I look for?
Procedure:
1. Redirect user to a page in the new area/website.
2. On the new page I have a module. This module wants to know which area/website is the current. How do I get this?
What I want to do is simply to change the website language. I tried to redirect user to a page into the area/website, which works. What I can't seem to find out is where I should look to find the current area/website id? Since 'areaecomlanguageid' is wrong, which property should I look for?
Procedure:
1. Redirect user to a page in the new area/website.
2. On the new page I have a module. This module wants to know which area/website is the current. How do I get this?
Nicolai Høeg Pedersen
Posted on 05/09/2011 12:39:58
Pageview.Current.Area.ID contains the ID of the website/area
Pageview.Current.Area.get_Value("AreaCulture") contains the culture as set in regional options under website properties.
Pageview.Current.Area.get_Value("AreaCulture") contains the culture as set in regional options under website properties.
You must be logged in to post in the forum