
Ken's stuck in time calendar
Our theme on the English side and the Japanese side are the same. And by that I mean, we only have one copy of the theme files that is used for both sides. For this to work, it has to be fully localised and independant. One thing that is quite different in the two languages is the formatting of dates. A date like Dec 13th 2009 might be formatted as 2009年12月13日
Chapp worked from a theme that had the date formats hard coded into the theme. As in:
<?php the_time('F jS, Y'); ?>
If we left that in, the Japanese side’s dates wouldn’t be right, but if we took out the ‘F jS, Y’ part, it defaulted to outputting the time. As a workaround, we used:
<?php the_date(); ?>
which does fetch and use the right formatted date on both sides. Yay! But… when WordPress generated archive pages, we found an unexpected behaviour of date(). It only outputs a certain date once. So if two posts were written on the same day, only one post would have the date. I think somewhere in the theme there is an ugly workaround involving an array. But this is a better approach:
<?php the_time(get_option('date_format')); ?>
What this is doing is fetching the date format string that is set in Settings > General > Date Format and using that. Which for the record is F jS, Y on the English side, and Y年n月j日 on the Japanese side. I know it may sound obvious but at the time it had us scratching our collective heads.
And while not many installations will be using the same set of theme files for two or more languages at the same time (except for WordPress MU themes), localizing the theme this way lets you or your users to just set the date format in the General Settings screen.
Related posts:
- Thoughts on the GPL and WordPress themes Why the GPL doesn’t matter WordCamp Kyoto 2009 was...
- How to fix WordPress automatic upgrades and plugin installs on XAMPP If you’ve ever had problems with WordPress automatic updates...
- How to create a single wp-config file for local and remote WordPress development If you are developing WordPress sites, themes or plugins, you...
Related posts brought to you by Yet Another Related Posts Plugin.


英語
日本語
Entries
Comments