[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.
[en]
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.
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:
- Basic Bilingual
- Basic Bilingual Plugin
- Website Pro Day 3: Results!
- Basic Bilingual 0.4
- Nasty Problem With Basic Bilingual Plugin
- Basic Bilingual and Bunny’s Technorati Tags Plugins Updated for WordPress 2.1
- Requirements for a Multilingual WordPress Plugin
- Call to WordPress Plugin Developers
- Two Plugin Updates: Basic Bilingual 0.32 and Language Linker 0.2
- Ridding WordPress Plugins of Template Tags











Quelques balises HTML pour blogueurs
[en]
A few HTML tags for bloggers. Don't use the visual editor is my recommendation. It sometimes creates hairy problems.
[fr]
Je recommande en général de ne pas utiliser “l’éditeur visuel” lorsqu’on écrit des billets dans WordPress. L’éditeur visuel vous montre directement, dans le texte que vous écrivez, le gras en gras, les listes sous forme de liste avec des petits points devant, les liens en bleu souligné, etc. Malheureusement les éditeurs visuels sont imparfaits et génèrent souvent plus de problèmes qu’ils n’en résolvent.
Pour désactiver l’éditeur visuel, allez sous “Users/Utilisateurs” et puis sous “Your Profile/Votre Profil”. Tout en bas de cette page, il y a une case à cocher. Vérifiez qu’elle soit décochée, et mettez à jour les réglages.
Votre éditeur de billets est maintenant décoré d’une rangée de boutons un peu différente d’avant: sélectionnez du texte, cliquez sur le bouton approprié, et des caractères étranges apparaîtront de part et d’autre du texte que vous aviez sélectionné. C’est du HTML. HTML?! Pas de panique, c’est pas si compliqué. Voici ce que vous avez besoin de savoir:
Exemple:
Ce qui est entre parenthèses angulaires < et > ne va pas s’afficher dans votre texte. Ce sont juste des indications que va interpréter le navigateur web. En l’occurence, il mettra le texte ci-dessus en italiques.
Voici quelques balises que vous rencontrerez en utilisant les boutons de WordPress:
<em> ... </em>met le texte qu’elles délimitent en italiques<strong> ... </strong>en gras<a href="http://quelquechose.com"> ... </a>crée un lien qui nous enverra sur http://quelquechose.com si on clique dessus<ul> ... </ul>,<ol> ... </ol>et<li> ... </li>sont utilisés pour faire des listes (explications ultérieures).Similar Posts: