aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2017-03-16 10:14:47 -0400
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-03-30 17:35:05 +0100
commite5529e430f180cebfa992dff6ac8285870576051 (patch)
tree7e19ad9b26d1e64804fe998afd52f1f04d0f5d85 /web
parent21bde113503d86f1791e170d1133710a2ed32077 (diff)
Improve translatability of various pages.
This commit makes the following parts of the site translatable: - Social login buttons - Moderation UI - Offline glitch page & offline caching UI - Dashboard It also fixes a bug in the nget parser, stops some Oxfordshire bits being translated for the moment, and brings the translation file up to date.
Diffstat (limited to 'web')
-rw-r--r--web/cobrands/fixmystreet/fixmystreet.js2
-rw-r--r--web/cobrands/fixmystreet/offline.js32
2 files changed, 22 insertions, 12 deletions
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js
index e92395661..a4bab095e 100644
--- a/web/cobrands/fixmystreet/fixmystreet.js
+++ b/web/cobrands/fixmystreet/fixmystreet.js
@@ -669,7 +669,7 @@ $.extend(fixmystreet.set_up, {
email_login_form: function() {
// Log in with email button
var email_form = $('#js-social-email-hide'),
- button = $('<button class="btn btn--social btn--social-email">Log in with email</button>'),
+ button = $('<button class="btn btn--social btn--social-email">'+translation_strings.login_with_email+'</button>'),
form_box = $('<div class="form-box"></div>');
button.click(function(e) {
e.preventDefault();
diff --git a/web/cobrands/fixmystreet/offline.js b/web/cobrands/fixmystreet/offline.js
index 0fdad1279..e6e50d3e8 100644
--- a/web/cobrands/fixmystreet/offline.js
+++ b/web/cobrands/fixmystreet/offline.js
@@ -2,17 +2,27 @@ fixmystreet.offlineBanner = (function() {
var toCache = 0;
var cachedSoFar = 0;
+ // Extremely noddy function
+ function sprintf(s, p) {
+ return s.replace('%s', p);
+ }
+
+ // Note this non-global way of handling plurals may need looking at in future
function formText() {
var num = fixmystreet.offlineData.getForms().length;
- return num + ' update' + (num===1 ? '' : 's');
+ if ( num === 1 ) {
+ return num + translation_strings.offline.update_single;
+ } else {
+ return num + translation_strings.offline.update_plural;
+ }
}
function onlineText() {
- return 'You have <a id="oFN" href=""><span>' + formText() + '</span> saved to submit</a>.';
+ return sprintf(translation_strings.offline.saved_to_submit, formText());
}
function offlineText() {
- return 'You are offline \u2013 <span>' + formText() + '</span> saved.';
+ return translation_strings.offline.you_are_offline + ' \u2013 ' + sprintf(translation_strings.offline.N_saved, formText());
}
function remove() {
@@ -87,12 +97,12 @@ fixmystreet.offlineBanner = (function() {
startProgress: function(l) {
$('.top_banner--offline').slideDown();
toCache = l;
- $('#offline_saving').html('Saving reports offline &ndash; <span>0</span>/' + toCache + '.');
+ $('#offline_saving').html(translation_strings.offline.saving_reports + ' &ndash; <span>0</span>/' + toCache + '.');
},
progress: function() {
cachedSoFar += 1;
if (cachedSoFar === toCache) {
- $('#offline_saving').text('Reports saved offline.');
+ $('#offline_saving').text(translation_strings.offline.reports_saved);
window.setTimeout(remove, 3000);
} else {
$('#offline_saving span').text(cachedSoFar);
@@ -367,10 +377,10 @@ if ($('#offline_list').length) {
if (!success) {
var html = localStorage.getItem('/my/planned');
if (html) {
- $('#offline_list').before('<h2>Your offline reports</h2>');
+ $('#offline_list').before('<h2>'+translation_strings.offline.your_reports+'</h2>');
$('#offline_list').html(html);
if (location.search.indexOf('saved=1') > 0) {
- $('#offline_list').before('<p class="form-success">Your update has been saved offline for submission when back online.</p>');
+ $('#offline_list').before('<p class="form-success">'+translation_strings.offline.update_saved+'</p>');
}
fixmystreet.offline.replaceImages('#offline_list img');
var offlineForms = fixmystreet.offlineData.getForms();
@@ -380,16 +390,16 @@ if ($('#offline_list').length) {
});
$('#offline_list a').each(function(i, a) {
if (savedForms[a.href]) {
- $(this).find('h3').prepend('<em>Offline update data saved</em> ');
+ $(this).find('h3').prepend('<em>'+translation_strings.offline.update_data_saved+'</em> ');
}
});
- $('#offline_clear').css('margin-top', '5em').html('<button id="js-clear-localStorage">Clear offline data</button>');
+ $('#offline_clear').css('margin-top', '5em').html('<button id="js-clear-localStorage">'+translation_strings.offline.clear_data+'</button>');
$('#js-clear-localStorage').click(function() {
- if (window.confirm("Are you sure?")) {
+ if (window.confirm(translation_strings.offline.are_you_sure)) {
fixmystreet.offline.removeReports(fixmystreet.offlineData.getCachedUrls());
fixmystreet.offlineData.clearForms();
localStorage.removeItem('/my/planned');
- alert('Offline data cleared');
+ alert(translation_strings.offline.data_cleared);
}
});
}