diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2012-10-18 08:09:58 -0700 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2012-10-18 08:09:58 -0700 |
commit | e4c0bb59e52a2cc7be21cdc4180a7f1aa64b18b5 (patch) | |
tree | 1a308bbbe6f474b83a581107b3c24dc0a6439a5b | |
parent | e307bf31c801b554a44afddd37e8e6f425fab567 (diff) | |
parent | d8eb62232e2b3003925c87b316b66ed6b39ff100 (diff) | |
download | nextcloud-server-e4c0bb59e52a2cc7be21cdc4180a7f1aa64b18b5.tar.gz nextcloud-server-e4c0bb59e52a2cc7be21cdc4180a7f1aa64b18b5.zip |
Merge pull request #39 from scambra/date-l10n-fixes
Date l10n fixes
-rw-r--r-- | apps/files/js/files.js | 9 | ||||
-rw-r--r-- | core/l10n/l10n-de.php | 6 | ||||
-rw-r--r-- | core/l10n/l10n-en.php | 5 | ||||
-rw-r--r-- | core/l10n/l10n-es.php | 5 | ||||
-rw-r--r-- | lib/l10n.php | 11 | ||||
-rwxr-xr-x | lib/util.php | 4 |
6 files changed, 26 insertions, 14 deletions
diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 6715e3fec60..549204e8572 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -843,20 +843,19 @@ function relative_modified_date(timestamp) { var diffhours = Math.round(diffminutes/60); var diffdays = Math.round(diffhours/24); var diffmonths = Math.round(diffdays/31); - var diffyears = Math.round(diffdays/365); if(timediff < 60) { return t('files','seconds ago'); } - else if(timediff < 120) { return '1 '+t('files','minute ago'); } - else if(timediff < 3600) { return diffminutes+' '+t('files','minutes ago'); } + else if(timediff < 120) { return t('files','1 minute ago'); } + else if(timediff < 3600) { return t('files','{minutes} minutes ago',{minutes: diffminutes}); } //else if($timediff < 7200) { return '1 hour ago'; } //else if($timediff < 86400) { return $diffhours.' hours ago'; } else if(timediff < 86400) { return t('files','today'); } else if(timediff < 172800) { return t('files','yesterday'); } - else if(timediff < 2678400) { return diffdays+' '+t('files','days ago'); } + else if(timediff < 2678400) { return t('files','{days} days ago',{days: diffdays}); } else if(timediff < 5184000) { return t('files','last month'); } //else if($timediff < 31556926) { return $diffmonths.' months ago'; } else if(timediff < 31556926) { return t('files','months ago'); } else if(timediff < 63113852) { return t('files','last year'); } - else { return diffyears+' '+t('files','years ago'); } + else { return t('files','years ago'); } } function getMimeIcon(mime, ready){ diff --git a/core/l10n/l10n-de.php b/core/l10n/l10n-de.php index f3084b05df8..976f8ce3c51 100644 --- a/core/l10n/l10n-de.php +++ b/core/l10n/l10n-de.php @@ -1,5 +1,5 @@ <?php $LOCALIZATIONS = array( - 'date' => 'd.m.Y', - 'datetime' => 'd.m.Y H:i:s', - 'time' => 'H:i:s' ); + 'date' => '%d.%m.%Y', + 'datetime' => '%d.%m.%Y %H:%M:%S', + 'time' => '%H:%M:%S' ); diff --git a/core/l10n/l10n-en.php b/core/l10n/l10n-en.php new file mode 100644 index 00000000000..3a050d477ce --- /dev/null +++ b/core/l10n/l10n-en.php @@ -0,0 +1,5 @@ +<?php +$LOCALIZATIONS = array( + 'date' => '%B %e, %Y', + 'datetime' => '%B %e, %Y %H:%M', + 'time' => '%H:%M:%S' ); diff --git a/core/l10n/l10n-es.php b/core/l10n/l10n-es.php new file mode 100644 index 00000000000..b81464b491a --- /dev/null +++ b/core/l10n/l10n-es.php @@ -0,0 +1,5 @@ +<?php +$LOCALIZATIONS = array( + 'date' => '%e de %B de %Y', + 'datetime' => '%e de %B de %Y %H:%M', + 'time' => '%H:%M:%S' ); diff --git a/lib/l10n.php b/lib/l10n.php index 4eb4c323d88..26611537175 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -58,9 +58,9 @@ class OC_L10N{ * Localization */ private $localizations = array( - 'date' => 'd.m.Y', - 'datetime' => 'd.m.Y H:i:s', - 'time' => 'H:i:s'); + 'date' => '%d.%m.%Y', + 'datetime' => '%d.%m.%Y %H:%M:%S', + 'time' => '%H:%M:%S'); /** * get an L10N instance @@ -216,7 +216,10 @@ class OC_L10N{ case 'time': if($data instanceof DateTime) return $data->format($this->localizations[$type]); elseif(is_string($data)) $data = strtotime($data); - return date($this->localizations[$type], $data); + $locales = array(self::findLanguage()); + if (strlen($locales[0]) == 2) $locales[] = $language.'_'.strtoupper($language); + setlocale(LC_TIME, $locales); + return strftime($this->localizations[$type], $data); break; default: return false; diff --git a/lib/util.php b/lib/util.php index 5771b89f265..880a519d347 100755 --- a/lib/util.php +++ b/lib/util.php @@ -162,8 +162,8 @@ class OC_Util { $offset=$clientTimeZone-$systemTimeZone; $timestamp=$timestamp+$offset*60; } - $timeformat=$dateOnly?'F j, Y':'F j, Y, H:i'; - return date($timeformat,$timestamp); + $l=OC_L10N::get('lib'); + return $l->l($dateOnly ? 'date' : 'datetime', $timestamp); } /** |