From a20676101ec3acf34e0deadc36e359fc198d416a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 28 May 2013 13:17:26 +0200 Subject: [PATCH] Use template functions of WCF.Language.get for WCF.Like See WoltLab/com.woltlab.wcf.like#21 --- wcfsetup/install/files/js/WCF.Like.js | 4 ++-- wcfsetup/install/files/js/WCF.js | 8 +++++++- wcfsetup/install/lang/de.xml | 4 ++-- wcfsetup/install/lang/en.xml | 3 ++- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.Like.js b/wcfsetup/install/files/js/WCF.Like.js index 592b994a3c..1bfe8496fc 100644 --- a/wcfsetup/install/files/js/WCF.Like.js +++ b/wcfsetup/install/files/js/WCF.Like.js @@ -392,7 +392,7 @@ WCF.Like = Class.extend({ // update tooltip var $likes = this._containerData[containerID].likes; var $dislikes = this._containerData[containerID].dislikes; - $badge.data('tooltip', eval(WCF.Language.get('wcf.like.tooltip'))); + $badge.data('tooltip', WCF.Language.get('wcf.like.tooltip', { likes: $likes, dislikes: $dislikes })); } }, @@ -408,7 +408,7 @@ WCF.Like = Class.extend({ for (var $userID in $users) $userArray.push($users[$userID].username); var $others = this._containerData[containerID].likes - $userArray.length; - this._containerData[containerID].summary.children('span').html(eval(WCF.Language.get('wcf.like.summary'))); + this._containerData[containerID].summary.children('span').html(WCF.Language.get('wcf.like.summary', { users: $userArray, others: $others })); } }, diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index f6883db3ca..b331335c8f 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -3844,7 +3844,13 @@ WCF.Template = Class.extend({ template = "$output += '" + template + "';"; - this.fetch = new Function("v", "var $output = ''; " + template + ' return $output;'); + try { + this.fetch = new Function("v", "var $output = ''; " + template + ' return $output;'); + } + catch (e) { + console.debug("var $output = ''; " + template + ' return $output;'); + throw e; + } }, /** diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 85ddb56562..7c0c923b63 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1608,11 +1608,11 @@ Erlaubte Dateiendungen: {', '|implode:$attachmentHandler->getAllowedExtensions() - 0 ? ($likes + " Like" + ($likes != 1 ? "s" : "") + ($dislikes > 0 ? ", " : "")) : "") + ($dislikes > 0 ? ($dislikes + " Dislike" + ($dislikes != 1 ? "s" : "")) : "")]]> + - 0 ? (" und " + $others + (" weitere" + ($others > 1 ? "n" : "m"))) : "") + " gefällt das."]]> + 1} und {/if}{@$users.slice(-1)[0]}{else}{@$users.join(", ")} und {if $others == 1}einem{else}{#$others}{/if} weitere{if $others > 1}n{else}m{/if}{/if} gefällt das.{/literal}]]> diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 582a607501..9b2b27e23a 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -1606,11 +1606,12 @@ Allowed extensions: {', '|implode:$attachmentHandler->getAllowedExtensions()}]]> - 0 ? ($likes + " Like" + ($likes != 1 ? "s" : "") + ($dislikes > 0 ? ", " : "")) : "") + ($dislikes > 0 ? ($dislikes + " Dislike" + ($dislikes != 1 ? "s" : "")) : "")]]> + 0 ? (" and " + $others + (" other" + ($others > 1 ? "s" : ""))) : "") + " like" + ($userArray.length == 1 ? "s" : "") + " this."]]> + 1} and {/if}{@$users.slice(-1)[0]}{else}{@$users.join(", ")} and {if $others == 1}one{else}{#$others}{/if} other{if $others > 1}s{/if}{/if} like{if $users.length == 1}s{/if} this.{/literal}]]> -- 2.20.1