logo
Ask your WordPress questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$12
Different languages

Hello I would like to add different languages to my wordpress site.

The base language is English, the site is built and working well and is installed on a .co.uk domain.

I also have the domains with .fr and .es endings.

I am capable of doing the translations myself for the content and menus of the site.

Ideally when someone visits mydomain.co.uk they will get English language, when they visit mydomain.fr they will get French language and mydomain.es they will get Spanish language throughout the site. Posts, Pages and Menus etc.

Also with the ability to change language via some links in the header e.g: 'En | Fr |Sp' or flags.


Can someone tell me whats the best way to do this? Is there a plugin out there that anyone has used before?


I ideally don't want to have to create mirror sites for each language, so it would be nice to be able to create a new post in English and to be able to add a translated version in French and Spanish on the same post via a custom field or something.


Thank you

This question has been answered.

Ross Gosling | 11/25/11 at 11:56am Edit


(7) Possible Answers Submitted...

See a chronological view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    11/25/11
    12:02pm
    Sébastien | French WordpressDesigner says:

    http://wpml.org/

    but i think that a multisite installation is a good solution

    Previous versions of this answer: 11/25/11 at 12:02pm

  • avatar
    Last edited:
    11/25/11
    12:01pm
    Gabriel Reguly says:

    Hi Ross,

    Why not try qTranslate?

    Regards,
    Gabriel

    • 11/25/11 12:02pm

      Gabriel Reguly says:

      Download qTranslate from http://www.qianqin.de/qtranslate/

    • 11/25/11 12:45pm

      Gabriel Reguly says:

      Hi,

      John Cotton solution seems to be a good one. Just add some plugin to do the poedit task inside WordPress and it will be better.

      Unfortunately I can't find that plugin right now, but I know that there is one.

      Regards,
      Gabriel

    • 11/25/11 12:52pm

      Gabriel Reguly says:

      Francisco also has an interesting option.

      The downside is you will have to set up a multisite install, but I can help you with that.

      Be warned that you will need replicate all content and navigation and plugins, but adding content is the easiest one and the most common task - so that should not scare you.

      Regards,
      Gabriel

  • avatar
    Last edited:
    11/25/11
    12:04pm
    Ryan Riatno says:

    You can use WPML http://wpml.org/ . But I don't know if this can use another domain for differnt language. You can use subdomain or subdirectory for example fr.mydomain.com or mydomain.com/fr.

  • avatar
    Last edited:
    11/25/11
    12:06pm
    John Cotton says:

    I've done this on several sites. A good example is here: www.begobi.com.

    By default, the site is in English, but it will detect browser language preference and display in French if requested. The visitor can also switch language using the flags at the top of the page.

    It's not a plugin, just some language detection code in functions.php:


    // must be called before load_theme_textdomain()
    function begobi_localised($locale) {
    if ( isset($_GET['l']) ) {
    $locale = $_GET['l'];

    } else if ( isset( $_COOKIE["begobi_locale"] ) ) {
    $locale = $_COOKIE["begobi_locale"];

    } else {
    if( strlen($_SERVER['HTTP_ACCEPT_LANGUAGE']) >= 2 ) {
    $header = substr( $_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2 );
    $locale = strtolower($header) . '_' . strtoupper($header);
    }
    }

    setlocale(LC_ALL, $locale );

    return $locale;
    }
    add_filter( 'locale', 'begobi_localised' );


    Then I have this call in my ini function:

    function begobi_init() {
    // code removed....

    load_theme_textdomain( 'begobi.com', TEMPLATEPATH . '/languages' );
    }
    add_action('init', 'begobi_init');


    Finally, all text displayed is wrapped in translation functions, e.g.

    $prefix = __('I love this Gobicard! - ', 'begobi.com');


    Once the code is ready, just run it through POEdit, create a language file for each language you want - job done!

    • 11/25/11 5:47pm

      John Cotton says:

      The points made about page content are good ones - and I didn't explain how that was done.

      Essentially, all pages are duplicated - one for each language. That means, of course, that the permalinks change. No problem as any hard codeed/menu permalinks are inside translation tags (so the POEdit file contains the correct link effectively), and anything inside the page can be set to whatever you want anyway.

      Have a look at the menu in the two languages and see how the links change - that's just done with a dynamic nav menu....

  • avatar
    Last edited:
    11/25/11
    12:17pm
    Francisco Javier Carazo Gil says:

    Hi Ross,

    The second speech in WordCamp Seville 2011 was about your problem.

    The speaker was Rafael Poveda from Mecus (the best WordPress developer bussiness in Spain and collaborators of Automattic) and the final option was the next one.

    The solution is to create a network with different blogs. All plugins have a problem and at the end, the best one to create, administrate and write is this option.

    You can create a network reusing themes and plugins, and then write the content separately.

    You can contact with Mecus.

  • avatar
    Last edited:
    11/25/11
    6:36pm
    Julio Potier says:

    Hello

    Just ti say that i'm Web Security Consultant and i read this code from John :

    // must be called before load_theme_textdomain()
    function begobi_localised($locale) {
    if ( isset($_GET['l']) ) {
    $locale = $_GET['l'];

    } else if ( isset( $_COOKIE["begobi_locale"] ) ) {
    $locale = $_COOKIE["begobi_locale"];

    } else {
    if( strlen($_SERVER['HTTP_ACCEPT_LANGUAGE']) >= 2 ) {
    $header = substr( $_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2 );
    $locale = strtolower($header) . '_' . strtoupper($header);
    }
    }

    setlocale(LC_ALL, $locale );

    return $locale;
    }
    add_filter( 'locale', 'begobi_localised' );

    Sorry but this is not secure.
    $locale from $_GET is dangerous, look at this code iused in twentyten template for example :
    $locale = get_locale();
    $locale_file = get_template_directory() . "/languages/$locale.php";
    if ( is_readable( $locale_file ) )
    require_once( $locale_file );

    You filter is used in "get_locale", so a LFI vulnerability is here.

    FYI ;)

    Previous versions of this answer: 11/25/11 at 6:36pm

  • avatar
    Last edited:
    11/26/11
    5:06am
    senlin says:

    Your solution is definitely WPML. Unlike other people suggest, WPML does not work on multisite, so that is not an option.

    I have been working with WPML almost since the beginning and know many ins and outs, more information at http://wpml.org/documentation/support/wpml-contractors/

    Previous versions of this answer: 11/26/11 at 5:05am | 11/26/11 at 5:06am

This question has expired.



Gabriel Reguly, Ross Gosling, Julio Potier voted on this question.



Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.