From fef32fb1d468e9c5af1cdd4fe00cf7bace729c62 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 28 May 2013 13:33:59 +0200 Subject: [PATCH] Use template functions of WCF.Language.get for WCF.Date As eval is no longer used the scope can be minified more efficiently --- wcfsetup/install/files/js/WCF.js | 8 ++++---- wcfsetup/install/lang/de.xml | 6 +++--- wcfsetup/install/lang/en.xml | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index b331335c8f..fa90168160 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -2805,23 +2805,23 @@ WCF.Date.Time = Class.extend({ // timestamp is less than 60 minutes ago (display 1 hour ago rather than 60 minutes ago) else if (this._timestamp < ($timestamp + 3540)) { var $minutes = Math.max(Math.round((this._timestamp - $timestamp) / 60), 1); - $element.text(eval(WCF.Language.get('wcf.date.relative.minutes'))); + $element.text(WCF.Language.get('wcf.date.relative.minutes', { minutes: $minutes })); } // timestamp is less than 24 hours ago else if (this._timestamp < ($timestamp + 86400)) { var $hours = Math.round((this._timestamp - $timestamp) / 3600); - $element.text(eval(WCF.Language.get('wcf.date.relative.hours'))); + $element.text(WCF.Language.get('wcf.date.relative.hours', { hours: $hours })); } // timestamp is less than a week ago else if (this._timestamp < ($timestamp + 604800)) { var $days = Math.round((this._timestamp - $timestamp) / 86400); - var $string = eval(WCF.Language.get('wcf.date.relative.pastDays')); // get day of week var $dateObj = WCF.Date.Util.getTimezoneDate(($timestamp * 1000), $offset); var $dow = $dateObj.getDay(); + var $day = WCF.Language.get('__days')[$dow]; - $element.text($string.replace(/\%day\%/, WCF.Language.get('__days')[$dow]).replace(/\%time\%/, $time)); + $element.text(WCF.Language.get('wcf.date.relative.pastDays', { days: $days, day: $day, time: $time })); } // timestamp is between ~700 million years BC and last week else { diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 7c0c923b63..cf8e2cb78d 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1366,9 +1366,9 @@ Erlaubte Dateiendungen: {', '|implode:$attachmentHandler->getAllowedExtensions() - 1) ? $minutes + ' Minuten' : 'einer Minute' )]]> - 1) ? $hours + ' Stunden' : 'einer Stunde' )]]> - 1) ? '%day%' : 'Gestern' ) + ', %time%']]> + 1}{#$minutes} Minuten{else}einer Minute{/if}{/literal}]]> + 1}{#$minutes} Stunden{else}einer Stunde{/if}{/literal}]]> + 1}{$day}{else}Gestern{/if}, {$time}{/literal}]]> diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 9b2b27e23a..63f01361f1 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -1364,9 +1364,9 @@ Allowed extensions: {', '|implode:$attachmentHandler->getAllowedExtensions()}]]> - 1) ? $minutes + ' minutes' : 'A minute') + ' ago']]> - 1) ? $hours + ' hours' : 'An hour' ) + ' ago']]> - 1) ? '%day%' : 'Yesterday' ) + ', %time%']]> + 1}{#$minutes} minutes{else}A minute{/if} ago{/literal}]]> + 1}{#$hours} hours{else}An hour{/if} ago{/literal}]]> + 1}{$day}{else}Yesterday{/if}, {$time}{/literal}]]> -- 2.20.1