Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Serve up page languages but displaying 1 URL only

Vote:
 

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.

#53615
Sep 16, 2011 4:15
Vote:
 

Just a follow up on this inquiry. In case someone knows how. Thanks.

#53707
Sep 21, 2011 0:40
Vote:
 

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.

#53711
Sep 21, 2011 7:34
Vote:
 

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?

#53712
Sep 21, 2011 8:19
Vote:
 

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.

#53713
Sep 21, 2011 8:21
Vote:
 

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)?

#53714
Edited, Sep 21, 2011 8:39
Vote:
 

Yes, that's what I meant.

#53715
Sep 21, 2011 8:42
Vote:
 

Thanks a lot Linus!

#53942
Sep 27, 2011 1:57
Vote:
 

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?

#53943
Sep 27, 2011 5:21
Vote:
 

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.

#53944
Sep 27, 2011 7:08
Vote:
 

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.

#53948
Sep 27, 2011 8:13
Vote:
 

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.

#53949
Sep 27, 2011 8:20
Vote:
 
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;
}
}
#53950
Sep 27, 2011 9:17
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.