-
WordPress Dual Language 03.06.09
Today I’ve been looking at building a WordPress site that supports dual languages (English and German). I couldn’t find anything on Wordpress.org that cut it, so I’ve written a small snippet of code that’ll allow you to display posts in English, then switch to German as and when you need it.
For the below example, the PHP is just looking for ?german in the URL, but you could change this to detect a cookie etc.
<?php if((isset($_GET['german']))&&(get_post_meta($post->ID, ‘german’, true)!=NULL)) { ?>
<p><?php echo get_post_meta($post->ID, ‘german’, true); ?></p>
<? } else { ?>
<?php the_content(‘<p>Read the rest of this entry »</p>’); ?>
<? } ?>View a demo of this technique here
So to set that up, all you have to do is add a Custom Field with the Name ‘german’ and the Value of whatever the translated text is. Obviously you’re going to have to overcome any problems like formatting etc yourself, but this is a start – and a pretty good solution for simple blocks of text, especially if you use Custom Fields often!
wanna say something?
If you've got an opinion about WordPress Dual Language - then why not say something? You can even subscribe to these comments via RSS!