Quote from: kongo09 at Dec 31, 2009, 02:20 PM
Conclusion
I feel the automatic URL rewriting doesn’t work correctly. The "current, else browser" rule seems to be more a "URL, else current, else browser" rule. Without proper rewriting of the URL on monolingual pages, this will fails.
I also believe that the cookie is not correctly evaluated when moving from a monolingual page to a multilingual page. This seems to be associated with an empty root name for the default language - coinciding with the server name for monolingual pages.
Any thoughts, suggestions, solutions, analysis?
Happy new year!
Happy New Year to you too kongo09!
Thanks for your report. I’ve read through it carefully. I don’t agree with you that YAMS is functioning incorrectly. I think that there is just a misconception about how YAMS works. YAMS is designed to work in a search engine friendly way whereby each URL is associated with the same unique and specific content on each request. I think the misunderstanding could be related to poor or incorrect documentation and to the fact that this is a tricky topic. If you think the documentation is confusing or misleading anywhere then please let me know which text so that I can improve it.
Here’s my analysis. Lets take your scenario point by point:
Quote from: kongo09 at Dec 31, 2009, 02:20 PM
When I go there [edit:to www.mysite.com] with browser set to "de", still the English version is displayed and the cookie is set to "en". That’s wrong. I would expect it to switch to German instead.
Actually, YAMS only does redirection when it’s not possible to uniquely determine the required document and language from the URL. This could occur, for example, if a standard MODx URL is supplied that doesn’t happen to coincide with a multilingual URL, or if root names are used for all languages but the site root
http://www.mysite.com/ is visited. In your example above the root name for English is blank, so
http://www.mysite.com/ is a valid URL for the English site start document. Therefore there is no need to do redirection. Displaying English is correct. This is a good thing. It means search engines know exactly what to index. If it were the case that sometimes when you visit an URL it provides English content and other times it redirects to a different page to display content in a different language then search engines would get confused about which URL and content to index. You really don’t want this happening for your site start document.
Quote from: kongo09 at Dec 31, 2009, 02:20 PM
Interesting enough, when the configuration is set to use a root name of "en" for English as well, then www.mysite.com correctly redirects to www.mysite.com/de/ and sets the corresponding cookie yams_lang to "de".
In this case (root names for all languages)
http://www.mysite.com/ is not a valid (multilingual) URL. YAMS identifies that this is a valid standard MODx URL for the site start document. It doesn’t know which language was intended, so it uses the user specified logic to determine it, which in your case is ’current else browser’. Since no cookie has been set, the browser is used to determine the language - which in this case selects German. So, it redirects to the German variant of the site start document, which is
http://www.mysite.com/de/
Quote from: kongo09 at Dec 31, 2009, 02:20 PM
Going back to the original setting without root name for "en", I click on a link to the sub-page www.mysite/next/ (which is monolingual). The page correctly displays in its language (in that case also English, but that doesn’t matter). The cookie remains set to "de". On the page is a link back to the start page, created via (yams_site). It goes back to www.mysite.com and not to www.mysite.com/de/ although I’m in "current else browser" mode. That’s also wrong.
No. It’s not. According to
the definition of [tt](yams_site)[/tt], when on a monolingual document and server mode is off the output is the same as [tt][(site_url)][/tt] - which is
http://www.mysite.com/ - which is what you got. In general, if you want to create a link to the site start document, then you should use [tt](yams_doc:[(site_start)])[/tt].
In this case however, even if you did use [tt](yams_doc:[(site_start)])[/tt], then a link to the English version of the site start page would be created - which again would be
http://www.mysite.com/. This is because monolingual documents are always parsed as if they are in the default language (English in your case).
I think you were expecting that the link from the monolingual document to a multilingual document would take you to the language of the last visited multilingual document (which in this case would be German). However this would lead to the situation whereby the document would contain different links dependent on the last visited page - which again would be very search engine unfriendly.
What all this is pointing to is the fact that that you should be using a multilingual document in this situation - not a monolingual document. If you use a multilingual document then the English version would contain links to English resources, German to German etc. (even if the actual text used for each language was the same and written in either English or German).
Monolingual documents are normally used to list content in multiple languages (using the [tt][[YAMS? &get=`repeat` ... ]][/tt] snippet call) rather than displaying content in a single (the default) language. For example; a landing page that allows you to select which language you want, or a multilingual site map that lists all documents in all languages. In that sense, monolingual is probably not a good name for such documents!
Quote from: kongo09 at Dec 31, 2009, 02:20 PM
Clicking it, the cookie doesn’t seem to be evaluated and I stay on www.mysite.com without a redirect to www.mysite.com/de/ and the cookie is changed to "en". Not good!
See above. This is a good thing. If you browse to a valid multilingual URL you stay on it and this is used to set the current language.
Quote from: kongo09 at Dec 31, 2009, 02:20 PM
The same test with "en" set as root name for English still doesn’t rewrite the link of (yams_site) to the German www.mysite.com/de/ as expected, but at least it redirects from www.mysite.com to www.mysite.com/de/ which gives the right result.
As described above, [tt](yams_site)[/tt] evaluates to
http://www.mysite.com/ in this case - which is not a valid (multilingual) URL, so with your setup ’current else browser’ redirection takes place - which takes you to the German page:
http://www.mysite.com/de/
Quote from: kongo09 at Dec 31, 2009, 02:20 PM
Expectation
- If the system doesn’t have a current language set (via cookie or via URL) then the browser language should be used - or if not available the default language
I claim that YAMS does this when in ’current else browser’ mode - but only when it is not clear from the URL which language was intended.
Quote from: kongo09 at Dec 31, 2009, 02:20 PM
- If the URL defines a language, that one should be used, unless the cookie indicates that the user before has already chosen another current language. Browser language is not relevant then.
- In effect, the rule would be "cookie, else URL, else browser" - which I understand should be covered by "current, else browser"
I disagree. YAMS currently does "URL, else user specified redirection mode", or, in other words: "If the URL defines a language then the document should be displayed in that language. Otherwise use the specified redirection mode to select a language variant of the document. This could be: default, current (else default), current else browser, browser etc."
If your scheme was used, then a user could browse to an URL for an English document and then decide that they actually wanted the French version - but when they try to browse to the URL for the French document they would keep being redirected back to the English version - which would be very annoying. As mentioned earlier, it would also be search engine unfriendly.
I hope the explanation above will help you achieve a better understanding of how YAMS works. Let me know if there is a specific set-up or behaviour that you are trying to achieve. I might be able to help you achieve it.