Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

Bilingual website

edited May 2012 in I18n

Hi! Just found ElefantCMS a couple of days ago and I like it. I have a question though... How can I create a bilingual website. I searched the docs and tutorials but couldn't find any instructions about it.

Can anyone help? Thanks!

Norboo

Comments

  • I've been meaning to put a tutorial on setting up multilingual sites together for a while. The steps I would use are:

    1. Create a separate index page for each language, e.g., /index-es /index-fr etc.

    2. Add each language under Tools > Languages so the site knows they're available

    3. Create additional pages for that language and place them under the appropriate index page in Tools > Navigation

    4. Set up any dynamic navigation elements as sections based on the site tree in step 3, instead of a top-level site menu. For example, a dynamic menu in your layout template might use this tag: {! navigation/section?section=index-fr !}

    5. Create a custom bootstrap.php file in the root of the site that contains roughly the following:

    <?php
    
    if ($_SERVER['REQUEST_URI'] === '/' || $_SERVER['REQUEST_URI'] === '/index') {
        $this->redirect ('/index-' . $i18n->language);
    }
    
    ?>
    

    This will cause requests to the homepage to automatically redirect to their preferred language's homepage based on the visitor's browser language preferences.

    One likely minor limitation is that if you're viewing a French page but your language settings chose Spanish, then the page itself will of course be French, but the surrounding text that's translated through the Tools > Language area would appear in Spanish since the language isn't being switched by the page.

    This is likely minor because visitors would tend to stick to the language that they've set as preferred anyway, so they would start at the Spanish index and browse Spanish pages (with surrounding text in Spanish) and never see the French pages. Similarly, a French visitor would be directed to the French homepage with links to the other French pages (with surrounding text in French based on their browser preference).

    Hope that helps you get started :)

  • Just posted a more detailed tutorial here:

    http://www.elefantcms.com/wiki/Multilingual-website-setup

    Cheers!

  • What to do when there is no Tools/Language ? in admin panel ?

  • Ah, forgot to mention in the docs that that's new to the 1.3.x releases.

  • Hello Guys, I'm new to this cms/framework. First I want to congratulate to this great work and I want to say thanks you for providing it as opensourse too. I'm seriously thinking about using it for the next project.

    However I need to ask this: Should I use the version 2 Beta 6 for Production?

    I'm trying to setup a multilingual site, but I'm having some errors: I've followed the steps in this tutorial http://www.elefantcms.com/wiki/Multilingual-website-setup I'm in step 4 and I can't move on. When I turn the multilingual function to On (multilingual = On), the main Menu disappears. What am I doing wrong? Thank you in advance

  • I've been using the betas in production for a while myself. It's been a fairly natural evolution from Elefant 1.x so the framework itself should be pretty stable. The next update will probably be a release candidate once I'm back from a bit of travel this next week :)

    If you set the pages up to match your language codes in step 3, the navigation/top handler should read the sub-pages of the current language from the site tree. What does your site tree look like? Should be something like this:

    en
        about
        etc
    es
        etc
    

    So when 'en' is the language of the current request, you should see 'about, etc' as the menu. It also expects the top-level page IDs to match the language codes in order to match them up.

  • edited May 2013

    Hello Johnny, thank you for your help. It's working now! I forgot to create the subpages, that's why the menu was disappearing. And then i did the adjust negotiation_method and everything worked like a charm. Thank you

    Here is some screenshots:

    http://www.clipular.com/c?5621227=hOs3i8lW2X7gIrRbYRagyRKhUNs&f=.png

    http://www.clipular.com/c?5529295=kxIfxCrapQvMBUb9xmVE03XN5Lo&f=.png

    http://www.clipular.com/c?5918028=SGeavc3nGMEfvKXrOWkr78tWNUI&f=.png

  • I am trying to do what hailton_silva managed to do! A bilingual site (el -greek- and en). My problem is, after adding the greek language and creating the two top pages with IDs el and en and four more pages, 2 for each language , I fail to build the navigation tree. I do not know where to put the Multilanguage Dynamic Object. In the 2 top pages? in all the pages ? somewhere else? Any help welcome

    Thanks Petros

  • Hi Petros,

    You should only need to add the multilingual homepage redirect to the main 'index' page. All it does is redirect requests for the current page to the default language of the site. The purpose is just to automatically redirect / to /el for new visitors.

    Also note that you only need to use that when you've set negotiation_method=url in your config. I tend to leave it to default to http which uses the browser/system language preferences of the visitor to choose the best language for them automatically.

    From there, you should be able to use the regular navigation handlers such as {! navigation/top !} the same as you would on a non-multilingual site.

    Hope that helps!

  • Hi JB! i'm very new here, I would like to ask > How to create a new language from existing similar language? Thank You

  • Good question! There's no "duplicate" button, but here's how you can duplicate a language:

    • Copy the original to the new language code: cp lang/fr.php lang/fr_ca.php`
    • Edit the new file and change the language code on line 3
    • Go to Tools > Languages and add the language like normal

    When you edit the new language, all the existing translations should be waiting for you.

  • edited March 2014

    Thank ya JB, simplicity always ruleZ ;)

    one more question > i want 2 langs on mydom.com, En + Cz. Cz page must be default language > En is optional, my config.php >

    [I18n]

    ; Turn this on if your site is multilingual. This will change ; the behaviour of the site navigation so that the appropriate ; language's section of the site tree is shown, depending on ; the user's language choice.

    multilingual = On

    ; This is the method for determining which language to show the ; current visitor. Options are: url (e.g., /fr/), subdomain ; (e.g., fr.example.com), http (uses Accept-Language header), ; or cookie.

    negotiation_method = url

    Everything works like a charm, but now i have duplicate content pages >

    mydom.com/home and mydom.com/cz/home

    is there som way to prevent duplicate content?

    Thank you, srry 4 my english ;) have a Nice Day

  • The regular page links will continue to work for the default language (so /home will resolve to the page with ID "home"), but there are few things that you can do to minimize this:

    1) Edit the "index" page, click on the Dynamic Objects icon and choose "Multilingual Homepage Redirect" which will automatically redirect new visitors to /cz. Once the visitor is on the /cz page, the dynamic navigation should automatically include the language, so /home will become /cz/home.

    2) A number of apps don't include the language code prefix, but you can use this gist to force all internal links to have one:

    https://gist.github.com/jbroadway/9467440

    The comment in the file explains how to set it up.

    With those two in place, users and search bots should only ever see the links with the language codes included :)

  • Thank You! amazing support <3

Sign In or Register to comment.