Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate Datepicker #38

Merged
merged 2 commits into from
Oct 23, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions core/js/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,7 @@ function formatDate(date){
if(typeof date=='number'){
date=new Date(date);
}
var monthNames = [ t('files','January'), t('files','February'), t('files','March'), t('files','April'), t('files','May'), t('files','June'),
t('files','July'), t('files','August'), t('files','September'), t('files','October'), t('files','November'), t('files','December') ];
return monthNames[date.getMonth()]+' '+date.getDate()+', '+date.getFullYear()+', '+((date.getHours()<10)?'0':'')+date.getHours()+':'+((date.getMinutes()<10)?'0':'')+date.getMinutes();
return $.datepicker.formatDate(datepickerFormatDate, date)+' '+date.getHours()+':'+((date.getMinutes()<10)?'0':'')+date.getMinutes();
}

/**
Expand Down
8 changes: 8 additions & 0 deletions core/js/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,14 @@ OC.Share={
}

$(document).ready(function() {
$.datepicker.setDefaults({
monthNames: monthNames,
monthNamesShort: $.map(monthNames, function(v) { return v.slice(0,3)+'.'; }),
dayNames: dayNames,
dayNamesMin: $.map(dayNames, function(v) { return v.slice(0,2); }),
dayNamesShort: $.map(dayNames, function(v) { return v.slice(0,3)+'.'; }),
firstDay: firstDay
});

$('a.share').live('click', function(event) {
event.stopPropagation();
Expand Down
4 changes: 3 additions & 1 deletion core/l10n/l10n-de.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php
$LOCALIZATIONS = array(
'jsdate' => 'dd.mm.yy',
'date' => '%d.%m.%Y',
'datetime' => '%d.%m.%Y %H:%M:%S',
'time' => '%H:%M:%S' );
'time' => '%H:%M:%S',
'firstday' => 0 );
4 changes: 3 additions & 1 deletion core/l10n/l10n-en.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php
$LOCALIZATIONS = array(
'jsdate' => 'MM d, yy',
'date' => '%B %e, %Y',
'datetime' => '%B %e, %Y %H:%M',
'time' => '%H:%M:%S' );
'time' => '%H:%M:%S',
'firstday' => 0 );
4 changes: 3 additions & 1 deletion core/l10n/l10n-es.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php
$LOCALIZATIONS = array(
'jsdate' => "d 'de' MM 'de' yy",
'date' => '%e de %B de %Y',
'datetime' => '%e de %B de %Y %H:%M',
'time' => '%H:%M:%S' );
'time' => '%H:%M:%S',
'firstday' => 1 );
4 changes: 4 additions & 0 deletions core/templates/layout.user.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
var oc_current_user = '<?php echo OC_User::getUser() ?>';
var oc_requesttoken = '<?php echo $_['requesttoken']; ?>';
var oc_requestlifespan = '<?php echo $_['requestlifespan']; ?>';
var datepickerFormatDate = <?php echo json_encode($l->l('jsdate')) ?>;
var dayNames = <?php echo json_encode(array((string)$l->t('Sunday'), (string)$l->t('Monday'), (string)$l->t('Tuesday'), (string)$l->t('Wednesday'), (string)$l->t('Thursday'), (string)$l->t('Friday'), (string)$l->t('Saturday'))) ?>;
var monthNames = <?php echo json_encode(array((string)$l->t('January'), (string)$l->t('February'), (string)$l->t('March'), (string)$l->t('April'), (string)$l->t('May'), (string)$l->t('June'), (string)$l->t('July'), (string)$l->t('August'), (string)$l->t('September'), (string)$l->t('October'), (string)$l->t('November'), (string)$l->t('December'))) ?>;
var firstDay = <?php echo json_encode($l->l('firstday')) ?>;
</script>
<?php foreach($_['jsfiles'] as $jsfile): ?>
<script type="text/javascript" src="<?php echo $jsfile; ?>"></script>
Expand Down
7 changes: 6 additions & 1 deletion lib/l10n.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ class OC_L10N{
* Localization
*/
private $localizations = array(
'jsdate' => 'dd.mm.yy',
'date' => '%d.%m.%Y',
'datetime' => '%d.%m.%Y %H:%M:%S',
'time' => '%H:%M:%S');
'time' => '%H:%M:%S',
'firstday' => 0);

/**
* get an L10N instance
Expand Down Expand Up @@ -221,6 +223,9 @@ public function l($type, $data) {
setlocale(LC_TIME, $locales);
return strftime($this->localizations[$type], $data);
break;
case 'firstday':
case 'jsdate':
return $this->localizations[$type];
default:
return false;
}
Expand Down