Support » Plugins » A bilingual blog solution

  • Hello,
    Posting in two different languages is a feature some would like to see implemented. There is probably a rather easy way to do this server-side, but I’m still too new to PHP to do so ๐Ÿ™‚
    So I’ve made up an alternate solution, which is very easy to add, and client side. See it in action here : (or if you cant stand being framed ๐Ÿ™‚

    Basically, here is how it works.
    The posts have to be duplicated in two languages and 2 divs :
    <div lang="en">Hello this is a post</div>
    <div lang="fr">Salut c'est un billet</div>

    Two links (like “in english” and “in french”) and a few lines of javascript make divs of a given “lang” appear or disappear, and I added cookie support so that when you come back or load another page, it only displays preferred language.

    I’ve tested it with MSIE6, Firefox and Konqueror, no flaw, and it validates.
    If anyone is interested, I can make a more detailled guide to explain how to add this to your site.

Viewing 15 replies - 1 through 15 (of 16 total)
  • Yes, please write the guide!

    Ok, I’ll be adding it when I have a few minutes.
    Thanks to Michel_v who suggested to use “lang” instead of “class” as I first did.

    As promised I’ve explain the whole trick. It’s rather lengthy and detailled on my site :

    I’m posting a shorter version in the Wiki.

    1337 users online. I swear. <– LOOOL @ ozh, nice one ๐Ÿ˜‰

    MaxT has a program that warns him whenever there’s a new post in the forum ! ๐Ÿ™‚

    Called SharpReader ๐Ÿ˜‰ I just added WordPress’ RSS forum feed to it ๐Ÿ˜‰

    Fantastic! Just what I was looking for ๐Ÿ™‚

    Hmmm… have you made any bilingual posts ozh or am I going to have to set this up on my Italian/scottish blog?

    There are a few bilingual posts on my site. At the moment on the index page the first 3 posts are in english only, but scroll down or go directly to this post for an example :

    Looks really good!
    Does this cause any problems with the archives etc..?
    Gnam ๐Ÿ˜‰

    ozh: very nice!
    I’m thinking about doing something related, but not the same: a site where multiple users can blog in different languages but none of them can really be bothered to provide versions of their posts in more than one language.
    It would be nice to be able to “show posts in language x only” (rather than “show version in language x where available”, like you are doing). Or even tickboxes to select, say, two languages out of three. I’m guessing that this would need a change to the database where every post has an additional “language” property associated with it, but I don’t know enough about databases to try implementing it. Is anyone else working on such a thing, or can anyone think of an easier way to do it?
    Any pointers much appreciated…

    This is great! @ozh

    This is what I was looking for. I want to use WP with 7 languages (english/french/german/italian/portugues/spanish/chinise) and Iรขโ‚ฌโ„ขm looking a easy way to have WP on the 7 languages on a way that if you select a languages (small flag/word) all the page will be on this language (Include link Menus) and if you click on a menu it will bring you to the next page/article on the same language. I don’t need a automatic translation because I have friends that will made the translation for me of all the website+each article/news.
    Can you tell me how to change also the menus or if is a way to achive this on a easy way?

    Thank you on advance fro any help.

    I hope this will be a feature for the next version or a MOD/PLUG-IN because several people now wants to have at list 2 languages on a blog or a website.

    Lobo is right: “This is great!”.
    And I also share the same need for a double language site, including not only posts, but also navigation and the like.

    Please Luigi drop me a line on my request here to support this feature ๐Ÿ™‚ if you think it can be usefull for you. Thank you on advance.

    Requests and Feedback

    3 languages support:
    =============================== language.js =======================
    window.onload, createCookie() and readCookie() are the same as they were. Here is the relevant code: (excuse the length)

    function language(lang_on, lang_off, lang_offf) {
    /* aalex aded 1 line here */
    for (var i=0; i<document.getElementsByTagName("div").length; i++ ) {
    if (document.getElementsByTagName("div")[i].lang == lang_on) {
    if (document.getElementsByTagName("div")[i].lang == lang_off) {
    /* aalex added 3 lines here */
    if (document.getElementsByTagName("div")[i].lang == lang_offf) {
    /* aalex added 11 lines here */
    for (var i=0; i<document.getElementsByTagName("span").length; i++ ) {
    if (document.getElementsByTagName("span")[i].lang == lang_on) {
    if (document.getElementsByTagName("span")[i].lang == lang_off) {
    /* aalex also added 3 lines here */
    if (document.getElementsByTagName("span")[i].lang == lang_offf) {

    function startlanguage() {
    var notdefined;
    var lang_on = readCookie("langue_on");
    var lang_off = readCookie("langue_off");
    var lang_offf = readCookie("langue_offf");
    if (lang_on == notdefined) {
    lang_on = "en";
    if (lang_off == notdefined) {
    lang_off = "de";
    if (lang_offf == notdefined) {
    lang_offf = "fr";
    language(lang_on,lang_off, lang_offf);

    ============================ language.html (to be put in the template)============

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
    <html xmlns="" xml:lang="en">
    <title>A bilingual blog solution &laquo; WordPress Support</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <!-- fix the FOUC -->
    <script type="text/javascript" src="language.js"> </script>


    <a href="javascript:language('fr', 'en', 'de');">Fr</a>
    <a href="javascript:language('en', 'fr', 'de');">En</a>
    <a href="javascript:language('de', 'en', 'fr');">De</a>

    <div lang="de">Deutsh</div>
    <div lang="fr">Francais</div>
    <div lang="en">English</div>
    <span lang="de">Deutsh</span>
    <span lang="fr">Francais</span>
    <span lang="en">English</span>

    It would be nice to put the “off” languages in an array, and all the tags (div, span…) in an array too for the loop. Can somoeone do that ? Then, no more copy-paste code and we got our tool !!


Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘A bilingual blog solution’ is closed to new replies.