Time Format and Month Format


#1

Hello there,

We are working on a platform using Ushahidi and we wanted to point out some of  “improvements” that we applied to the Ushahidi code.

Problem: Localizations for Dates and Time (in Albanian) were not being shown properly in:  Ushahidi_Folder/themes/default/views/reports/main.php even though the localization files are available here Ushahidi_Folder/application/i18n/sq_SQ/datetime.php and original file Ushahidi_Folder/application/i18n/en_US/datetime.php 


Original main.php file

<?php echo Kohana::lang('ui_main.showing_reports_from', array(date('M d, Y', $oldest_timestamp), date('M d, Y', $latest_timestamp))); ?$ <?php echo Kohana::lang('ui_main.change_date_range'); ?>


keep in mind: You have to change the localization file datetime.php and the original in English, where months should look like this: with CAPITAL first letter

‘November’ => array(

‘abbv’ => ‘Nën’,

‘full’ => ‘Nëntor’,

),

http://pastebin.com/cn9XTUPa &&  http://pastebin.com/Lwh6F3fA

then we go back to main.php

We changed to this:

<?php $month_old = date('F', $oldest_timestamp); $month_new = date('F',$latest_timestamp); $r_month_old = Kohana::lang('datetime.'.$month_old.'.abbv'); $r_month_new = Kohana::lang('datetime.'.$month_new.'.abbv'); $timeframe_title = str_replace($month_old,$r_month_old, date('d F, Y', $oldest_timestamp)).' '.Kohana::lang('ui_main.through').' '.str_replace($month_new, $r_month_new,date('d F, Y', $latest_timestamp)); ?> <?php echo Kohana::lang('ui_main.showing_reports_from'); ?>

<?php echo $timeframe_title; ?>

<?php echo Kohana::lang('ui_main.change_date_range'); ?>

The other one is Time Format am&pm

<?php echo Kohana::lang('ui_main.modify_date'); ?>

<?php echo Kohana::lang('ui_main.date_time'); ?>: <?php echo Kohana::lang('ui_main.today_at')." "."".$form['incident_hour'] .":".$form['incident_minute']." ".$form['incident_ampm'].""; ?> <?php if($site_timezone != NULL): ?>

(<?php echo $site_timezone; ?>)

<?php endif; ?>

This is based on your language:

<?php echo Kohana::lang('ui_main.modify_date'); ?>

<?php echo Kohana::lang('ui_main.date_time'); ?>: <?php echo Kohana::lang('ui_main.today_at')." "."".$form['incident_hour'] .":".$form['incident_minute']." ".Kohana::lang('datetime.'.$form['incident_ampm']).""; ?> <?php if($site_timezone != NULL): ?>

(<?php echo $site_timezone; ?>)

<?php endif; ?>

#2

Thanks so much. I’ll share this with the development team.

Of note,

We are localizing Ushahidi using transifex. Here are details on how it works:

https://wiki.ushahidi.com/display/WIKI/Localization+and+Translation

https://www.transifex.net/projects/p/ushahidi-localizations/

Heather


#3

Hi,

Are you managing your code in github? It’d be great to see a diff of these changes, or even better if you could send a pull request with these improvements [https://help.github.com/articles/using-pull-requests]

Localizing dates is something I looked at briefly before, its done in a couple of JS libraries already. However I haven’t had time to go further, part of the problem is that simply swapping and English month name for another language isn’t correct, as other languages often use different formats etc. There are other libraries that solve this problem, for instance Zend_Date, but theres still some work to integrate one of these.

Robbie


#4

A date and time format string defines the text representation of a DateTime .The “d” custom format specifier represents the day of the month as a number.


#5

There is a github issue on this topic. Maybe you could add notes?

 

heather