Get help with WordPress and French locale dates and times
Have you ever had to develop a WordPress-powered website in a language other than English?
WordPress has the capability to serve your pages in the language of your choice. The WordPress community has already translated it into many languages, and there are themes, translation files, and support also available in many other languages.
With a client project I'm just about to roll out, I had to present all the content in Canadian French but keep the administrative interface in English. The translation tasks mostly fell into the realms of content, interface and layout graphics, making it a fairly smooth process. However, I did come across one small hiccup regarding post meta data dates and times, and wanted to document and share the solutions here.
In particular, I needed to translate this meta data:
This entry was posted on Tuesday, June 17th, 2008 at 5:37 pm and is filed under [category].
into French:
Cette entrée a été inscrite le mardi, 17 juin 2008 à 17 h 37 et elle est classée sous [category].
It's simple enough to translate text in single.php, but what about the date and time which are generated using the WordPress function, the_time()?
First, the file wp-includes/locale.php needs to be translated to include the French names of the days of the week and months. Using the FR .po file available from the WordPress Subversion repository, I edited the locale file. This can be downloaded here, and is intended to be used with WordPress version 2.0.0.11.
Next, you'll need to edit the two instances of the time function in single.php:
<?php the_time('l, j F, Y') ?>
<?php the_time('G \h i') ?>
Along with the translated text, you should now have this in your single.php template:
Cette entrée a été inscrite le <?php the_time('l, j F, Y') ?> à <?php the_time('G \h i') ?> et elle est classée sous <?php the_category(', ') ?>.
And there you have it!
















October 6th, 2008 at 1:31 pm
Hi:
Thanks for this info . . . I have had a similar problem in Spanish - but after I changed the locale.php data the blog stayed the same . . . does the updated/changed info/file need to be reloaded in a database too? - or is it really just a matter of editing correctly.
Many thanks if you can post a reply.
October 6th, 2008 at 1:41 pm
Thanks for your comment, John.
With the site I was working on, the only thing I needed to change was how WordPress was generating the date and time. (I kept the WordPress admin in English and published French content.) All I needed to do for this was update the locale file then make those minor edits to single.php. If your requirements are similar, that should be all you need to do—no database changes.
A couple of things come to mind, and forgive me if these seem too simplistic (sometimes it's the simple things that are forgotten): 1) Did the changed files get uploaded OK? Perhaps try deleting them from the server and uploading again? 2) Do you have caching enabled?
I hope that helps! If not, feel to post back with further detail.