From 7812d93e74dc1f76ae989454f9b746e3ac74ca15 Mon Sep 17 00:00:00 2001 From: mluto Date: Fri, 25 Jan 2013 10:32:09 +0100 Subject: [PATCH 1/3] Fixed "unnamed" and "enter your name" in userlist --- src/static/js/pad_editor.js | 6 ++++++ src/static/js/pad_userlist.js | 5 ++--- src/templates/pad.html | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/static/js/pad_editor.js b/src/static/js/pad_editor.js index f4778802..b828711e 100644 --- a/src/static/js/pad_editor.js +++ b/src/static/js/pad_editor.js @@ -78,6 +78,12 @@ var padeditor = (function() html10n.bind('localized', function() { $("#languagemenu").val(html10n.getLanguage()); + $('input[data-l10n-id]').each(function(key, input) + { + input = $(input); + if(input.hasClass("editempty")) + input.val(_(input.attr("data-l10n-id"))); + }); }) $("#languagemenu").val(html10n.getLanguage()); $("#languagemenu").change(function() { diff --git a/src/static/js/pad_userlist.js b/src/static/js/pad_userlist.js index 40e87a4f..d051182b 100644 --- a/src/static/js/pad_userlist.js +++ b/src/static/js/pad_userlist.js @@ -118,7 +118,7 @@ var paduserlist = (function() } else { - nameHtml = ''; + nameHtml = ''; } return ['
 
', '', nameHtml, '', '', padutils.escapeHtml(data.activity), ''].join(''); @@ -710,8 +710,7 @@ var paduserlist = (function() { if (myUserInfo.name) { - $("#myusernameedit").removeClass("editempty").val( - myUserInfo.name); + $("#myusernameedit").removeClass("editempty").val(myUserInfo.name); } else { diff --git a/src/templates/pad.html b/src/templates/pad.html index 274a3b1a..6b5b179a 100644 --- a/src/templates/pad.html +++ b/src/templates/pad.html @@ -163,7 +163,7 @@
-
+
From 763864539ffce2ed1b60be0e63bcb060deafe712 Mon Sep 17 00:00:00 2001 From: mluto Date: Fri, 25 Jan 2013 17:41:33 +0100 Subject: [PATCH 2/3] Use 'html10n' instead of '_', i10nzed "unnamed author(s)" --- src/locales/en.json | 2 ++ src/static/js/broadcast_slider.js | 7 ++++++- src/static/js/pad_editor.js | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 15feae64..eea35cc5 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -95,6 +95,8 @@ "timeslider.month.october": "October", "timeslider.month.november": "November", "timeslider.month.december": "December", + "timeslider.unnamedauthor": "{{num}} unnamed author", + "timeslider.unnamedauthors": "{{num}} unnamed authors", "pad.savedrevs.marked": "This revision is now marked as a saved revision", "pad.userlist.entername": "Enter your name", "pad.userlist.unnamed": "unnamed", diff --git a/src/static/js/broadcast_slider.js b/src/static/js/broadcast_slider.js index 83483537..221666de 100644 --- a/src/static/js/broadcast_slider.js +++ b/src/static/js/broadcast_slider.js @@ -193,7 +193,12 @@ function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded) }); if (numAnonymous > 0) { - var anonymousAuthorString = numAnonymous + " unnamed author" + (numAnonymous > 1 ? "s" : "") + var anonymousAuthorString; + if(numAnonymous == 1) + anonymousAuthorString = html10n.get("timeslider.unnamedauthor", { num: numAnonymous }); + else + anonymousAuthorString = html10n.get("timeslider.unnamedauthors", { num: numAnonymous }); + if (numNamed !== 0){ authorsList.append(' + ' + anonymousAuthorString); } else { diff --git a/src/static/js/pad_editor.js b/src/static/js/pad_editor.js index b828711e..553245ea 100644 --- a/src/static/js/pad_editor.js +++ b/src/static/js/pad_editor.js @@ -78,11 +78,12 @@ var padeditor = (function() html10n.bind('localized', function() { $("#languagemenu").val(html10n.getLanguage()); + // translate the value of 'unnamed' and 'Enter your name' textboxes in the userlist $('input[data-l10n-id]').each(function(key, input) { input = $(input); if(input.hasClass("editempty")) - input.val(_(input.attr("data-l10n-id"))); + input.val(html10n.get(input.attr("data-l10n-id"))); }); }) $("#languagemenu").val(html10n.getLanguage()); From 046fac9fa9c1a4cb2677d09ade9c181750f5a6d4 Mon Sep 17 00:00:00 2001 From: mluto Date: Fri, 25 Jan 2013 20:38:24 +0100 Subject: [PATCH 3/3] Added a comment to clearify *why* this works --- src/static/js/pad_editor.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/static/js/pad_editor.js b/src/static/js/pad_editor.js index 553245ea..dd0cbbbb 100644 --- a/src/static/js/pad_editor.js +++ b/src/static/js/pad_editor.js @@ -79,6 +79,9 @@ var padeditor = (function() html10n.bind('localized', function() { $("#languagemenu").val(html10n.getLanguage()); // translate the value of 'unnamed' and 'Enter your name' textboxes in the userlist + // this does not interfere with html10n's normal value-setting because html10n just ingores s + // also, a value which has been set by the user will be not overwritten since a user-edited + // does *not* have the editempty-class $('input[data-l10n-id]').each(function(key, input) { input = $(input);