Offline multilingual posts with WordPress and qTranslate

Sometimes you feel like posting, including sharing a photo, but the signal is weak or non-existent. Those who write in one language only have an easy life. There’s quite a few offline blog editors for most of the common blogging platforms.

The trouble is when you want to write multilingual offline posts. No editor is ready for that. And since we are getting ready to cast off soon and will be without regular internet connection for days at a time, I started to look for a solution that would enable us to write full blog posts offline and upload them immediately when we get signal, without the need to login to WordPress admin environment and finalize the post for publishing as we did so far.

We want to write and we want to spend as little time formatting, uploading pictures etc.

The simplest and most convenient solution came to me the last. That sometimes happens to me. I wanted to use Windows Live Writer for preparing the posts offline, because after few experiments I found that WLW is most likely the best. Personally I like ScribeFire as well, but it’s useless offline, because it requires instant upload of pictures.

After few hours of studying Windows Live API and playing with Visual Studio Express I had a plugin for WLW, which worked, more or less anyway, but unfortunatelly is seems impossible to send the markup in title required by qTranslate, because WLW escapes all the markup into HTML entites.

Well, at least I got acquainted with C# and VS2012.

Then I’ve spent little time digging around ScribeFire sources, but to rewrite their handling of images seemed like too much work. And I would have to check that my patch still works with new versions.

Finally it occured to me that it would much simpler send few innocent tags that wouldn’t be escaped to HTML entities and write a WordPress plugin that would convert such a post into a markup expected by qTranslate.

This solution will also free us to use any editor we wish to. The plugin is hardcoded to process Czech and English in this order. The double double colon is used as a delimiter of languages.

Post title:

Český napis :: English title

Post content:

 Český text :: English text

If you wish to insert pictures do the following. Insert the images at the end of the post and separate them by another double double-colon delimiter. The put the following placeholder to where you want the picture to appear in the text.

Image in the text

:photo..Image caption:

The complete post would look something like the follows. (All editors have a special field for post title, so the title would naturally be entered there.)

Český napis :: English title

Český text bla bla kolem a kolem

:photo..Západ slunce:

další povídání a tak dále

::

English text blah blah

:photo..Sunset:

and on and on, etc.

<img src=”…” alt=”” />

You can use as many pictures as you want. You can naturally insert pictures directly into the text, but in multilingual post you would have to insert two copies and both copies would be uploaded to the server. This seems wasteful to me.

WordPress plugin source code: qtranslate_offline.zip

Leave a Reply