Category Archives: Blog’s life

From gengo to polylang: updating the theme

So I postponed hacking a mode with multiple languages on the same page and decided to set polylang on my production site (hem) my blog.

But Gengo was using some customized template tags so the theme was adapted to it and this needed to be changed.

With polylang it’s a lot simpler, all navigation is handled by filters, so only thing really custom had to be written:

Basically my hacked version of the_translations had to be ported. And to keep it simple it can even be part of the functions.php file in the theme and use the pll_the_languages function.
I want to display the other language title prefixed by “Language version” written in this language. As the gettext like functions would only return strings in the current language, I hardcoded those strings, but adding them in Polylang admin “strings translation” would have been nice…
So here is the code:

 $translation_title=array(
    'en' => "English version:", 
    'fr' => "Version française : ");
function my_translations() {
    global $post;
    global $translation_title;
    $post_id=$post->ID;
    if ( function_exists('pll_the_languages') ) {
        $translations = pll_the_languages(array('post_id' => $post_id, 'hide_if_no_translation'=>1, 'hide_current'=>1, 'raw'=>1));
        if(!empty($translations)) {
            foreach($translations as $tr) {
                $trid=pll_get_post($post_id, $tr['slug']);
                ?><li lang="<?php echo esc_attr($tr['slug']);?>"><?php echo $translation_title[$tr['slug']]; ?><a hreflang="<?php echo esc_attr($tr['slug']);?>" href="<?php echo esc_url($tr['url']);?>" rel="alternate"><?php echo get_the_title($trid); ?></a></li><?php
            }
        }
    }
}

Instead of porting the old theme, I did build a new one based on WordPress’ Twenty Twelve updated with my previous header and dark color scheme.
I also played with a few css3 features for more neon light effects 🙂

And here it is !

From gengo to polylang: importing data

As you might know, my blog is using gengo to enable translations.

But gengo is an old unmaintained plugin (I’m even running a custom version that I recently needed to fix again) so I’d like to migrate away.

Recently, I studied the available options (thanks to Multilingual WordPress page) and selected Polylang. This one seams to be what Gengo could have been with a rewrite: no extra database tables but using WP3 custom taxonomies. (I can’t find the message but I remember Pixline telling this would be the way to go, so…).

Anyway, I started to test Polylang, what it misses compared to Gengo, is the ability to really mix languages on the same page, so it will need some customizations before replacing Gengo here, but it will come.

It’s only a few days layer that I found the WPML to Polylang plugin.
This basically triggered the development of Gengo to Polylang a plugin to import translations informations from Gengo to Polylang.

It seams to work… I missed the Site Title and Tagline (but they are no longer translated on my blog so I don’t need it 😕 ) and I did take some shortcut for terms (tags & categories) that are the same in both languages.
UPDATE 2014-02-04: I fixed that as it caused the tag archive to contain both english and french posts so… also fixed the Title and Tagline part.

So if you still have a Gengo powered blog and want to migrate, the code could help you, but don’t just run it blindly, make a backup, setup a test instance and be prepared to hack the code ! You have been warned !

New Projects pages and Gengo update.

I’ve been adding pages for my Projects. Previously this kind of data was on Trac, but I’ve never been using it actively. And I’m mostly using git for my new development instead of subversion.

I could have used Trac with git, but for project presentation WordPress pages are good enough.

But I wanted to have comments on some pages, which meant a theme update and another Gengo fix. Also I’ve done a big history rewrite by moving my version of gengo to git. If ever Jamie Talbot is really seriously considering starting development again. Then I hope he can pick some patches from my version 😉

OpenPGP key migration

I’ve generated a new OpenPGP key, and I’m now using this new key.

See my migration message for details.

Anyway if you are using my repository and get the following error:

W: GPG error: http://silicone.homelinux.org unstable Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 8B306538D00E52B6

All you have to do is to get the new key and import it to apt again.
The key is stored as before in siliconerepositorykey.asc and you can import it with:

sudo apt-key add siliconerepositorykey.asc

moving… home and server

Well this server is home hosted over our DSL connection, so it had to move too 😉

That explain the one week offline period two weeks ago, if anyone (other than google) noticed.

So the moving has taken most of my time, I had to pack everything including my electronic stuff so the projects didn’t move much…

Also I offered myself an EeePC 1201HA, I wanted the 12 inch screen to get something more usable than the 701p. However it comes with windows 7 and the chipset is a gma500 (pouslbo) which does not help for linux, but I managed to get debian on it (still some to do, see a later post for details).

WordPress and plugin upgrade

After yesterday’s trouble, I just upgraded all my plugins.

Gengo’s URI renaming scheme with language code at the end was leading to an infinite redirect (adding fr+en/ to the URI) so I had to disable it. But doing so breaks the existing URI on your bookmarks (if you had some) and on Google…
So I hacked gengo again so that if the URI ends with a language code, it is redirected to the basic URI.
A recent reading : Cool URIs don’t change is just about keeping the URI, here I’m redirecting, that’s not as good, but at least you wont get the 404 😉

The link was on Peter Eisentraut’s Blog. I was reading his article about Remove and Purge. I was tempted to do the same, I even did for a few days. Then I read the comments, and ended using aptitude l~c view 😉 . I was previously using synaptic only for purging residual configuration…

becoming bilingual

Thanks to the Gengo plug-in my blog is becoming bilingual.

Obviously things are never that simple, Gengo is not ready for WordPress 2.7 so I had to install the development version… I justs have to check that it works!

  • French layout was kind of strange, English seams more ok… for now!

Don’t worry non-french reader’s (do I have any reader yet anyway) I will continue to write in english.

WordPress 2.7.1 !

Now that Lenny is out, testing is moving again !

So I could upgrade my wordpress debian package to the testing version and get the 2.7.1 !

Note that my system is still running lenny (stable), this is using basic apt pinning, the more basic you can do is :

  1. add
    APT::Default-Release "stable";

    in /etc/apt/apt.conf (or in one file in /etc/apt/apt.conf.d)

  2. then add the tesing distrib in your source.list !
  3. Finally
    sudo aptitude update

    and that’s it you can install some specific packages from testing.

However to use stable, testing and unstable you have to really do the pinning !

But for testing, unstable and experimental the above method with testing as default release will works. Just because experimental has NEVER automatic upgrade.