SV: [opencms-dev] Multilanguage pages

Stefan Uldum Grinsted stefan at e-nation.dk
Mon Nov 13 15:47:18 CET 2006


Oh, but you can... Of course there is an issue with what sibling in the
specific language to choose from, but it's not that big.

Since the locale property of /da/bar/foo/dims123shownwitanothertemplate.html
is still Danish, you wouldn't link to it as the "parallel" English version.
You would only link to a sibling which actually has another locale than the
specified. Furthermore you could do a comparison of the template-property,
and ultimately only link to other locales with the same template.

I'm not saying it is worth the effort, I'm merely pointing out that to the
url's usually make more sense if they are also localized.

If I'm dealing with several languages, I usually just link to the front page
of each other locale. That's even easier. 
I have created a root index file to determine the language of the browser
and redirect accordingly. See below.

Cheers, Stefan

<%@page import="org.opencms.file.CmsProperty"%>
<%@page import="org.opencms.jsp.CmsJspNavElement"%>
<%@ page contentType="text/html; charset=utf-8" language="java" %><%@ 
page import="org.opencms.file.CmsObject" %><%@ 
page import="org.opencms.jsp.CmsJspActionElement" %><%
	CmsJspActionElement cms = new CmsJspActionElement(pageContext,
request, response);
	CmsObject cmso = cms.getCmsObject();

	String resource = "/" + request.getLocale().getLanguage();
	
	boolean redir = false;
	if (cmso.existsResource(resource)) {
		CmsJspNavElement element = new CmsJspNavElement(resource,
CmsProperty.toMap(cmso.readPropertyObjects(cmso.readResource(resource),
false)));
		if (element.isInNavigation()) {
			response.sendRedirect(cms.link(resource));
			redir = true;
		}
	}
	if (!redir) {
	
response.sendRedirect(cms.link(cms.property("default-file")));
	}
	
%>

-----Oprindelig meddelelse-----
Fra: opencms-dev-bounces at opencms.org
[mailto:opencms-dev-bounces at opencms.org] På vegne af Carl Alex Friis Nielsen
Sendt: 13. november 2006 15:25
Til: The OpenCms mailing list
Emne: RE: [opencms-dev] Multilanguage pages

-----Original Message-----
From: opencms-dev-bounces at opencms.org@KB On Behalf Of "Stefan Uldum
Grinsted" <stefan at e-nation.dk>

> To make the linking between versions available on the site, you should use
> the readSiblings(...) method of CmsObject to determine other language
> versions of the file.

This approach only works if siblings are only used to create versions
in different locales and nothing else.

E.g. if you have a /da/foo/bar/dims123.html and a
 /da/bar/foo/dims123shownwitanothertemplate.html which
are siblings there is no way you can figure out which
one should corespond to /en/foobar/thing123showninenglish.

Since we can't assume that this isn't going to happen we can't
take that approach.

To improve page ranking we use keyword- and description metatags
which are localized.

cheers,

Carl

_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev




More information about the opencms-dev mailing list