You are viewing the PKP Support Forum | PKP Home Wiki

Reordering interface text for localization

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
Developer Resources:

Documentation: The OJS Technical Reference and the OJS API Reference are both available from the OJS Documentation page.

Git: You can access our public Git Repository here. Comprehensive Git usage instructions are available on the wiki.

Bugzilla: You can access our Bugzilla report tracker here.

Search: You can use our Google Custom Search to search across our main website, the support forum, and Bugzilla.

Questions and discussion are welcome, but if you have a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a technical support question, try the OJS Technical Support subforum.

Reordering interface text for localization

Postby mark » Thu Oct 09, 2008 2:22 am

I'm decided to add some date functionality to OJS but have encountered a problem when localizing the presentation of dates for the interface.

I store dates as YYYY-MM-DD and want it to present as Month Name DD, YYYY (e.g., April 5, 2003). For French this would be Avril 4, 2003. To do this, a first guess would be add MonthNumber-to-MonthName conversion funcationality in the locale.xml file:

in the locale.xml file is
Code: Select all
        <message key="month.number.1">Jan</message>
        <message key="month.number.2">Feb</message>
        <message key="month.number.3">Mar</message>
        <message key="month.number.4">Apr</message>
        <message key="month.number.5">May</message>
        <message key="month.number.6">Jun</message>
        <message key="month.number.7">Jul</message>
        <message key="month.number.8">Aug</message>
        <message key="month.number.9">Sep</message>
        <message key="month.number.10">Oct</message>
        <message key="month.number.11">Nov</message>
        <message key="month.number.12">Dec</message>

And then in the application layer tease the YYYY and MM and DD from the date,
Code: Select all
$date = 5;
$month = 4;
$year = 2003;
$templateManager->assign('date', $date);
$templateManager->assign('year', $year);
$templateManager->assign('month', $month);

And in the template file, do the following:
Code: Select all
{translate key="month.number.$month"} {$date}, {$year} 

This works, so all is fine to this point, but there is (or may be) a glitch. What if in some countries/locally, there is preference for date to be in the form: 2008-April-05 or 5 April 2008? At first glance it seems smarty templates and the translate routine of OJS effectively hard code the format. I may be pushing the translate routine beyond its original design. But has anyone encountered something like that (i.e., localization that requires not simply a translate-lookup but an actually reordering of interface text)?

Posts: 31
Joined: Fri Jul 11, 2008 10:57 am

Re: Reordering interface text for localization

Postby jmacgreg » Thu Oct 09, 2008 11:14 am

Hi Mark,

Your config.inc.php has a section on how to display short and long date formats, which you may want to take a look at. There's a good breakdown of date formatting here: viewtopic.php?f=13&t=3511&p=13213&hilit=date+php#p13213 -- it deals with delivering dates in different formats by manipulating config.inc.php, and also talks about how different locales are handled by PHP's formatting tools.

Posts: 4191
Joined: Tue Feb 14, 2006 10:50 am

Return to OJS Development

Who is online

Users browsing this forum: No registered users and 1 guest