[opencms-dev] multi-language pages in 5.3.4

Martin Kuba makub at ics.muni.cz
Thu May 13 18:04:01 CEST 2004


Alexander Kandzior wrote:
> Maybe you don't really need this. The xmlPage mechanism supports "fallback"
> to default locales in case a requested locale is not available. This works
> like standard Java locales at first, so if you request an "en_US" locale but
> there is only content for "en" available, this is used instead. 
> 
> What's a bit different from the Java standard is the handling in case there
> is no matching locale found at all.We found the concept of the "empty"
> locale creates some issues, like you don't really know what the default is
> etc. So we have a set of configured default locales in opencms-system.xml:
> 
> <localesdefault>
> 	<locale>en</locale>
> 	<locale>de</locale>		
> </localesdefault>
> 
> This means if no content with a matching locale was found on a requested
> page, the page is checked for content in the provided default locales, and
> the first matching content that is available in the page is delivered. 
> 
> So instead of checking the content of the page, you should consider using
> that default fallback mechanism. 

That would not work for more than two languages. Suppose you understand
German and English, so you browser reports:

Accept-Language: de,en;q=0.5

and the server is configured with

<localesdefault>
    <locale>cs</locale>
    <locale>en</locale>
    <locale>de</locale>
</localesdefault>

and you try to access a page, which is available in Czech and English.
So the correct response would be in English, because it is available
and your browser accepts it.

But if the LocaleHandler selects just "de" locale as the best matching
between Accept-Language and default locales, the page will not be 
available in German. So the fallback mechanism will select the first
from default locales, which is Czech, so the page will be displayed
in Czech, which you don't understand.

The problem is obviously that the fallback machanism should use
the prefered order of the user (Accept-Language) and not
the order specified in opencms-system.xml




> If you really must check the content from the page, you should try it like
> this:
> 
> -----------
> CmsObject cms; // needs to be initialized somehow
> String filenmae = "/some/opencms/file/uri.html";
> CmsFile file = cms.readFile(filename)
> CmsXmlPage xmlpage = CmsXmlPage.read(cms, filename);
> List supportedLocales = xmlpage.getLocales();

OK, that works perfectly, I have the LocaleHandler
finished. I can send it to you for puuting it into CVS
if you want.

The only problem is when broser requests
a directory, so some default index.(html|jsp)
file is used. Then the page is null, I have to use
default locales, which can meet the problem described above.

Is there a way to find the index file for a directory ?

Best regards

Martin
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Supercomputing Center Brno             Martin Kuba
Institute of Computer Science    email: makub at ics.muni.cz
Masaryk University             http://www.ics.muni.cz/~makub/
Botanicka 68a, 60200 Brno, CZ     mobil: +420-603-533775
--------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3415 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20040513/5663b4c3/attachment.bin>


More information about the opencms-dev mailing list