Basic Bilingual 0.3 for Multilingual Blogging

[fr] Une mise à jour de mon plugin "Basic Bilingual" qui permet de rendre WordPress bilingue. Modification majeure: il n'y a plus besoin de bidouiller son template pour faire apparaître l'extrait du billet dans "l'autre langue". Par contre, c'est toujours nécessaire pour rajouter les attributs lang.

Long overdue, an upgrade of my plugin Basic Bilingual. Grab the tgz archive or check out the code.

Some explanations. First, you all know of my long-standing interest in all things multilingual and in multilingual blogging in particular.

Years ago, I switched to Movable Type and then to WordPress because I was blogging in two languages. Movable Type allowed me to assign more than one category to each post — so I used two huge categories, fr and en, to indicate what language I was blogging in. This soon made the rebuilds a real pain in the neck, and WordPress allowed me first of all to happily hack it into being multilingual, and then actually write a plugin to do it in a cleaner way. The plugin hasn’t changed much since, and this upgrade isn’t a major one, but it’s a step in the right direction.

Ideally, I’d like people to be able to use the plugin without having to modify their templates at all. I’d also like the plugin to allow filtering out one language if that is what the reader desires. I still hope that WordPress will one day “see the light” and let us define language at post-level (Matt saw the light for tagging ;-) , so I do have hope). By the way, I stumbled upon this Ajax Language Switcher for Basic Bilingual earlier today, and it will probably greatly interest those courageous ones of you who tend to have translations of each post or page.

Back to the plugin. It installs normally (unzip everything in the /plugins directory). If you’re using other languages than French and English, you’ll have to manually change the language codes in the plugin file (not very difficult, you don’t have to know PHP to do it; just look for “en” and “fr” and put the language codes for your languages instead).

I’ve fixed an annoying problem with slashes that popped up at some point (somebody else gave me the fix, but I can’t remember who — let me know!).

But most of all, I’ve made the “other language excerpt” appear automatically in the post content. Yes, you hear me: no need to add <php bb_the_other_excerpt(); ?> in your templates anymore. Yay! Added bonus: it will show up in the feeds, too — for that reason, I’ve added a text separator between the excerpt and the post so that there is a separation between the languages.

Basic Bilingual in Google Reader

Obviously, you’ll want to hide these separators and style your posts a little. Here is roughly what I’m using right now:

.other-excerpt {
font-style: italic;
background: #fff;
padding-left: 1em;
padding-right: 1em;
border: 1px solid #ccc;
}

.other-excerpt:lang(fr) p.oe-first-child:before {
content: "[fr] ";
font-weight: bold;
}

.other-excerpt:lang(en) p.oe-first-child:before {
content: "[en] ";
font-weight: bold;
}

.bb-post-separator {
display: none;
}

div.hentry:lang(fr) .entry-title:after {
    content: " [fr] ";
    vertical-align: middle;
    font-size: 80%;
    color: #bbb;
}

div.hentry:lang(en) .entry-title:after {
    content: " [en] ";
    vertical-align: middle;
    font-size: 80%;
    color: #bbb;
}

Now, notice there is fancy stuff in there which relies on the lang attribute. If you’re mixing languages on a page, you should use the lang attribute to indicate which language is where. This means (unfortunately, until I become buddies with PHP’s ob_start() function) that you need to touch your template. It’s not that hard, though.

Find the outermost <div> for each post in the template (it should have the CSS class hentry, by now). Add this inside the tag: lang="<?php bb_the_language(); ?>". Do so on every theme template which produces posts. With the Sandbox theme, it would look like this:

<div id="post-<?php the_ID() ?>" class="<?php sandbox_post_class() ?>" lang="<?php bb_the_language(); ?>">

That’s it!

If you’re using this plugin, please leave a link to your blog. I’m also always interested in hearing of other examples of multilingual blogging or multilingualism online.

Similar Posts:

This entry was posted in Language Geekiness, Social Media and the Web, Wordpress and tagged basic bilingual, blogging, code, css, hatom, html, Kit du blogueur, lang, languages, Languages / Linguistics, multilingual, plugin, upgrade, Weblog Technology. Bookmark the permalink.

11 Responses to Basic Bilingual 0.3 for Multilingual Blogging

  1. Stephanie says:

    I’ve been having some weird, non-reproducible problems with “other-excerpts” disappearing after they were recorded. Keep an eye open and do let me know if you notice anything unusual.

    It seems to have calmed down now — unless you notice that this post has no French excerpt, in which case it’s back again, oh heck!

  2. Stephanie says:

    I've been having some weird, non-reproducible problems with “other-excerpts” disappearing after they were recorded. Keep an eye open and do let me know if you notice anything unusual.


    It seems to have calmed down now — unless you notice that this post has no French excerpt, in which case it's back again, oh heck!

  3. Pingback: Climb to the Stars (Stephanie Booth) » Ridding Wordpress Plugins of Template Tags

  4. Pingback: Climb to the Stars (Stephanie Booth) » Nasty Problem With Basic Bilingual Plugin

  5. Pingback: Climb to the Stars (Stephanie Booth) » November 2007 Recap

  6. Pingback: Climb to the Stars (Stephanie Booth) » Website Pro Day 3: Results!

  7. Jan says:

    thank you so much for this plugin Stephanie! I have already configured it on my blog. Check it out :P

  8. Dirk says:

    Hi, I just noticed when viewing your plugin in Firefox (3.0.7) your language tag is printed out on screen:

    e.g.: [fr] Une mise à jour de mon plugin…

    in IE6 it vanished when using your recommended style sheet.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>