Hi Jan!
I think that a globalized web site could work in your case. I would look into doing the actual selection of the "language" which in your case would be regions. Perhaps you can use Visitor Groups and try doing a regional match to see which "language" you should choose for the user. I think you can use ContentLanguage.SetCulture([the selected language]) here and this should be done early in the request life cycle to get before the built in language selection.
Hi Linus,
Thanks for the reply.
Does that mean that I'll drop the .nz, and .au (language) pages and just use visitor groups instead?
No, my idea was based on that the three different regions have similar site structures. You set up three langauge branches for your web site structure. But instead of having the user to select their region their selves you could use visitor groups to select the language for them when entering the site.
So a user from NZ enters site.com, using visitors group API to detect origin, I then set Culture to en-NZ for example and site.com would display contents supposedly for site.co.nz. Did I get it right?
And although they're still seeing and browsing site.com, contents displayed would be for NZ (site.co.nz)?
Was playing around with the suggestion but not able to make it work yet.
Aside from automatically loading the actual language page based on user location, we still need to have a language/location selection.
So I created a code with a dropdownlist for testing:
protected void Region_SelectedIndexChanged(object sender, EventArgs e)
{
CultureInfo culture = CultureInfo.CurrentCulture; //testing
switch (region.SelectedValue)
{
case ("NZ"):
ContentLanguage.PreferredCulture = new CultureInfo("en-NZ");
//ContentLanguage.Instance.SetCulture("en-NZ");
break;
case ("AU"):
ContentLanguage.PreferredCulture = new CultureInfo("en-AU");
//ContentLanguage.Instance.SetCulture("en-AU");
break;
default: // ("US")
ContentLanguage.PreferredCulture = new CultureInfo("en-US");
//ContentLanguage.Instance.SetCulture("en-US");
break;
}
}
None of the culture setting works. The page reloads all right, but the content is still in US regardless of what language is selected.
Maybe I'm doing something wrong?
So this will do the trick:
ContentLanguage.Instance.SetCulture("en-NZ")
If I put that exact code on the OnLoad event, it would definitely display the NZ page.
But If I put that code on a dropdownlist event, it will not serve up the NZ page on postback for whatever reason.
I have no idea why.
By the way, from the CMS 6 Globalization Tech Note:
3. To implement a language selection option for the site visitors, see code in the Public Templates package.
Does anybody know where I can find this public templates package? This language selection option is exactly what I need.
The public template package was replaced with the Allow template package but this uses the URL:s to change language so that will probably not help you.
Thanks Linus.
Got a workaround to make it work. I'm sure there's a much elegant way to fix this but this sure works.
protected void Region_SelectedIndexChanged(object sender, EventArgs e)
{
Language = region.SelectedValue;
Response.Redirect(Request.UrlReferrer.AbsoluteUri);
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
string language = Language;
ContentLanguage.Instance.SetCulture(language);
}
private string Language
{
get
{
if (Session["Language"] == null)
{
Session["Language"] = "en-US"; // set default
}
return Session["Language"] as string;
}
set
{
Session["Language"] = value;
}
}
Hi,
We have an existing site with 3 domains:
1. site.com
2. site.com.au
3. site.co.nz
Now, we want to redirect .au and .nz to .com but still keep track of their geographic location.
We want them to just use site.com, and depending on their location, we will serve up the .au, .nz, or .com pages.
Having a language selector on the site is also an option.
We just want to promote site.com and we've just upgraded to CMS 6.
Is it at all possible to do this? Any ideas on how to do it?
Cheers.