The problem is that when I go to www.domain2.com/en it still uses the danish dictionary items. If I remove the hostname from the site2 node, the dictionary items shows up corretly, but then if I type in www.domain2.com in the browser, I'm redirected to site1.
I am not sure how you're setting the current language, but when you go to www.domain2.com/en, the Thread.CurrentThread.CurrentUICulture value should be en-GB and umbraco.library.Session("lang") should be "en".
Domains (umbraco.library.GetCurrentDomains(node.Id);) Name: www.domain2.com/en/ Language name: English (United Kingdom) Language id: 3 Language alias: en-GB
Session lang:
Thread lang:da-DK
If I take a look at the umbdebugshowtrace, the last line in pre-init says default.aspx Culture changed to da-DK
I don't know how you implemented the multilanguage functionality, so I tell you how I did it. Maybe it helps.
In the page load event of every page ( in the main master page) :
1. I get the language from the query string ( I also have domain/language and I use UrlRewriting to set the query string value for language - if you're not using any rewriting, you can parse the url)
2. I call a function that sets the current language and mainly does this:
Thread.CurrentThread.CurrentUICulture = currentCulture; //currentCulture = the culture corresponding to the language from the query string
If you do this from an xslt (it's an example I've found online), create a template that calls this function call it in the head of the main master page.
That seems like quite a workaround for something that ought to just work.
I've taken a look at the umbraco source code and to me the following code seems to be the problem. It's in page.cs in \umbraco\presentation
public string GetCulture() { if (Domain.Exists(HttpContext.Current.Request.ServerVariables["SERVER_NAME"])) { Domain d = Domain.GetDomain(HttpContext.Current.Request.ServerVariables["SERVER_NAME"]); return d.Language.CultureAlias; } else { for (int i = splitpath.Length - 1; i > 0; i--) { if (Domain.GetDomainsById(int.Parse(splitpath[i])).Length > 0) { return Domain.GetDomainsById(int.Parse(splitpath[i]))[0].Language.CultureAlias; } } } return ""; }
If you take a llok at that it first checks to see if the hostnames contains the current ServerVariables["SERVER_NAME"]. Because of this check my culture will always be set to da-DK in this example and makes it almost impossible to use directory based hostname setup. Seems like a bug to me?
The multilingual site that I created has a different structure. I didn't want 2 different domains, so the document types had properties for each language. This was it was easier to get the same page in each language.
What I did see is that those 2 (Thread.CurrentThread.CurrentUICulture and Session("lang") have to be set correctly to get the correct dictionary items.
Multiple sites and multilanguage
Hi
I've got a problem with a multilingual site. The dictionary items aren't show correctly
Site structure
content
-site1 (www.domain1.com - da-DK)
--page1
--page2
--etc
-site2 (www.domain2.com - da-DK (language selector))
--da (www.domain2.com/da - da-DK)
----page1
----page2
----page3
--en (www.domain2.com/en (en-GB)
----page1
----page2
----page3
The problem is that when I go to www.domain2.com/en it still uses the danish dictionary items. If I remove the hostname from the site2 node, the dictionary items shows up corretly, but then if I type in www.domain2.com in the browser, I'm redirected to site1.
Does anybody have an idea on what to do?
/RALY
I am not sure how you're setting the current language, but when you go to www.domain2.com/en, the Thread.CurrentThread.CurrentUICulture value should be en-GB and umbraco.library.Session("lang") should be "en".
Is it like this?
No, this is what I get in Page_Load
Domains (umbraco.library.GetCurrentDomains(node.Id);)
Name: www.domain2.com/en/
Language name: English (United Kingdom)
Language id: 3
Language alias: en-GB
Session lang:
Thread lang:da-DK
If I take a look at the umbdebugshowtrace, the last line in pre-init says
default.aspx Culture changed to da-DK
I think it doesn't change the session language.
I don't know how you implemented the multilanguage functionality, so I tell you how I did it. Maybe it helps.
In the page load event of every page ( in the main master page) :
1. I get the language from the query string ( I also have domain/language and I use UrlRewriting to set the query string value for language - if you're not using any rewriting, you can parse the url)
2. I call a function that sets the current language and mainly does this:
Thread.CurrentThread.CurrentUICulture = currentCulture; //currentCulture = the culture corresponding to the language from the query string
umbraco.library.setSession("lang", currentCulture.TwoLetterISOLanguageName);
If you do this from an xslt (it's an example I've found online), create a template that calls this function call it in the head of the main master page.
I hope it helps and that I explained well.
That seems like quite a workaround for something that ought to just work.
I've taken a look at the umbraco source code and to me the following code seems to be the problem. It's in page.cs in \umbraco\presentation
public string GetCulture()
{
if (Domain.Exists(HttpContext.Current.Request.ServerVariables["SERVER_NAME"]))
{
Domain d = Domain.GetDomain(HttpContext.Current.Request.ServerVariables["SERVER_NAME"]);
return d.Language.CultureAlias;
}
else
{
for (int i = splitpath.Length - 1; i > 0; i--)
{
if (Domain.GetDomainsById(int.Parse(splitpath[i])).Length > 0)
{
return Domain.GetDomainsById(int.Parse(splitpath[i]))[0].Language.CultureAlias;
}
}
}
return "";
}
If you take a llok at that it first checks to see if the hostnames contains the current ServerVariables["SERVER_NAME"]. Because of this check my culture will always be set to da-DK in this example and makes it almost impossible to use directory based hostname setup. Seems like a bug to me?
It does seem like a bug.
The multilingual site that I created has a different structure. I didn't want 2 different domains, so the document types had properties for each language. This was it was easier to get the same page in each language.
What I did see is that those 2 (Thread.CurrentThread.CurrentUICulture and Session("lang") have to be set correctly to get the correct dictionary items.
Sorry I can't help you more with this.
Please go and vote: http://umbraco.codeplex.com/workitem/23342
is working on a reply...