A bilingual blog solution (17 posts)

  1. Ozh
    Posted 12 years ago #

    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 : http://planetozh.com (or http://frenchfragfactory.net/ozh/index.php 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.

  2. anatman
    Posted 12 years ago #

    Yes, please write the guide!

  3. Ozh
    Posted 12 years ago #

    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.

  4. Ozh
    Posted 12 years ago #

    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.

  5. MaxT
    Posted 12 years ago #

    1337 users online. I swear. <-- LOOOL @ ozh, nice one ;)

  6. Ozh
    Posted 12 years ago #

    MaxT has a program that warns him whenever there's a new post in the forum ! :)

  7. MaxT
    Posted 12 years ago #

    Called SharpReader ;) I just added WordPress' RSS forum feed to it ;)

  8. gnam
    Posted 12 years ago #

    Fantastic! Just what I was looking for :)

  9. gnam
    Posted 12 years ago #

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

  10. Ozh
    Posted 12 years ago #

    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 : http://frenchfragfactory.net/ozh/archives/2004/05/02/planetozh-v300/

  11. gnam
    Posted 12 years ago #

    Looks really good!
    Does this cause any problems with the archives etc..?
    Gnam ;)

  12. eric
    Posted 12 years ago #

    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...

  13. Lobo
    Posted 11 years ago #

    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.

  14. LuigiMartini
    Posted 11 years ago #

    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.

  15. Lobo
    Posted 11 years ago #

    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

  16. aalex
    Posted 11 years ago #

    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" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" 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 !!


  17. Harvey
    Posted 11 years ago #

    I am interested in creating a bilingual site as well powered by WP. I would like it so each post could be created in both languages, and the users could click a small icon to switch the post to the other language. Will keep an eye on the boards for any cool solutions!

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.