Problems, need help? Have a tip or advice? Post it here.
7 posts Page 1 of 1
Hello KK! And hello Forum!

I plan to make a multilanguage site as explaind in the thread from 2011
http://www.couchcms.com/forum/viewtopic.php?f=8&t=74

I want to use the 2nd example, with this site structure:
Code: Select all
site_root
  |_couch (folder)
  |_en (folder)
  |   |_index.php
  |   |_about.php
  |   |_news.php
  |_de (folder)
  |   |_index.php
  |   |_apropos.php
  |   |_neuigkeiten.php
  |_index.php

The index.php site should automatically recognize the browser language settings and redirect the user to available language or to default english version. If I understand right that thread, the code in the 3rd example of how to make a multi language site is doing something else.
Would it be possible to provide such code?

Thanks in advance

Tanja

p.s Dear KK, I do webpages occasionally, but each time I have an opportunity, the very idea of what I can do with Couch makes me sooooo happy. I really love Couch!!!! You are a genius!!!
Hi Tanja,

To begin with, thank you for the compliment.
Though I am certainly undeserving of it, I must say, you made my day :) Thanks.

Coming to the problem you mentioned -
The index.php site should automatically recognize the browser language settings and redirect the user to available language or to default english version.

- the following snippet if placed within the main 'index.php' should do the trick
Code: Select all
<cms:php>
    $lang = substr( $_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2 );
    if( $lang ){
        global $CTX;
        $CTX->set( 'my_lang', strtolower($lang), 'global' );
    }
</cms:php>

<cms:if my_lang!='en' &&  my_lang!='de'>
    <cms:set my_lang='en' 'global' />
</cms:if>

<cms:if my_lang='en' >
    <cms:redirect url="<cms:link masterpage='en/index.php' />" />
<cms:else />
    <cms:redirect url="<cms:link masterpage='de/index.php' />" />
</cms:if>

Hope this helps.
Please let me know.
YES!!!! That is exactly what I meant.....The snippet works perfectly!!!!!!
Thanks a lot again for your support beyond any support that is known to be, and for the Couch itself!!!!!!!

with appreciation
Tanja
You are welcome, Tanja :)
On trying to use this script, when I load my website, it shows me the error this website has too many redirect loops and the website doesn't load.
Is there any fix for this ?
@richie, Have you placed the snippet within 'en/index.php' or 'de/index.php'?
That would lead to an infinite loop.

The snippet was meant to be placed on a separate 'index.php' that marshals the visitor to either of the two above-mentioned templates.
Alright i didn't know that. Thanks.
7 posts Page 1 of 1
cron