@@ -, +, @@ and into JavaScript files - Apply the patch, go to Administration -> System preference - Modify any system preference. "modified" should appear next to the preference name. - Click the "Save" button. You should get a message, "Saved preference " - Hover your mouse over a section heading (e.g. "Features" under Accounting). You should see a tooltip, "Click to collapse this section." - Click to collapse the section. The tooltip should change to "Click to expand the section." - Open a new tab for the staff interface and log out. - In the original tab, modify and try to save a system preference. You should get a message, "Error; your data might not have been saved." - Update a translation, e.g. fr-FR: > cd misc/translator > perl translate update fr-FR - Open the corresponding .po file for JavaScript strings, e.g. misc/translator/po/fr-FR-messages-js.po - Locate strings pulled from koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js for translation, e.g.: msgid "Saved preference %s" msgstr "" - Edit the "msgstr" string however you want (it's just for testing). - Install the updated translation: > perl translate install fr-FR - Switch to your newly translated language in the staff client and repeat the test plan above. The translated strings should appear. --- .../prog/en/modules/admin/preferences.tt | 14 ------------ koha-tmpl/intranet-tmpl/prog/js/ajax.js | 8 +++---- .../intranet-tmpl/prog/js/pages/preferences.js | 26 +++++++++++----------- 3 files changed, 17 insertions(+), 31 deletions(-) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt @@ -251,20 +251,6 @@ // This is here because of its dependence on template variables, everything else should go in js/pages/preferences.js - jpw var to_highlight = "[% To.json( searchfield ) | $raw %]"; var search_jumped = [% IF ( search_jumped ) %]true[% ELSE %]false[% END %]; - var MSG_NOTHING_TO_SAVE = _("Nothing to save"); - var MSG_SAVING = _("Saving..."); - var MSG_SAVED_PREFERENCE = _("Saved preference %s"); - var MSG_MODIFIED = _("modified"); - var MSG_MADE_CHANGES = _("You have made changes to system preferences."); - var MSG_CLICK_TO_EXPAND = _("Click to expand this section"); - var MSG_CLICK_TO_COLLAPSE = _("Click to collapse this section"); - var MSG_INTERNAL_SERVER_ERROR = _( "Internal Server Error, please reload the page" ); - var MSG_SESSION_TIMED_OUT = _( "You need to log in again, your session has timed out" ); - var MSG_DATA_NOT_SAVED = _( "Error; your data might not have been saved" ); - var MSG_LOADING = _( "Loading..." ); - var MSG_ALL_VALUE_WARN = _("Note: _ALL_ value will override all other values"); - var MSG_UPD_LOC_FORMAT_WARN = _("The following values are not formatted correctly:"); - var MSG_INVALID = _( "Error: presence of invalid data prevent saving. Please make the corrections and try again." ); [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %] [% Asset.js("js/ajax.js") | $raw %] --- a/koha-tmpl/intranet-tmpl/prog/js/ajax.js +++ a/koha-tmpl/intranet-tmpl/prog/js/ajax.js @@ -15,24 +15,24 @@ KOHA.AJAX = { KOHA.xhr = xhr; if ( !xhr.getResponseHeader( 'content-type' ).match( 'application/json' ) ) { // Something really failed - humanMsg.displayAlert( MSG_INTERNAL_SERVER_ERROR ); + humanMsg.displayAlert( __("Internal Server Error, please reload the page") ); return; } var error = eval( '(' + xhr.responseText + ')' ); if ( error.type == 'auth' ) { - humanMsg.displayMsg( MSG_SESSION_TIMED_OUT ); + humanMsg.displayMsg( __("You need to log in again, your session has timed out") ); } if ( callback ) { callback( error ); } else { - humanMsg.displayAlert( MSG_DATA_NOT_SAVED ); + humanMsg.displayAlert( __("Error; your data might not have been saved") ); } }, MarkRunning: function ( selector, text ) { - text = text || _("Loading..."); + text = text || __("Loading..."); $( selector ) .prop('disabled', true) .each( function () { --- a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js +++ a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js @@ -1,10 +1,10 @@ -/* global KOHA MSG_MADE_CHANGES CodeMirror MSG_CLICK_TO_EXPAND MSG_CLICK_TO_COLLAPSE to_highlight search_jumped humanMsg MSG_NOTHING_TO_SAVE MSG_MODIFIED MSG_SAVING MSG_SAVED_PREFERENCE dataTablesDefaults themelang */ +/* global KOHA CodeMirror to_highlight search_jumped humanMsg dataTablesDefaults themelang */ // We can assume 'KOHA' exists, as we depend on KOHA.AJAX KOHA.Preferences = { Save: function ( form ) { if ( ! $(form).valid() ) { - humanMsg.displayAlert( MSG_INVALID ); + humanMsg.displayAlert( __("Error: presence of invalid data prevent saving. Please make the corrections and try again.") ); return; } @@ -22,10 +22,10 @@ KOHA.Preferences = { data += '&' + $(this).attr('name') + '='; }); if ( !data ) { - humanMsg.displayAlert( MSG_NOTHING_TO_SAVE ); + humanMsg.displayAlert( __("Nothing to save") ); return; } - KOHA.AJAX.MarkRunning( $( form ).find( '.save-all' ), MSG_SAVING ); + KOHA.AJAX.MarkRunning($(form).find('.save-all'), __("Saving...") ); KOHA.AJAX.Submit( { data: data, url: '/cgi-bin/koha/svc/config/systempreferences/', @@ -38,7 +38,7 @@ KOHA.Preferences = { modified_prefs.each(function(){ var modified_pref = $(this).attr("id"); modified_pref = modified_pref.replace("pref_",""); - msg += ""+ MSG_SAVED_PREFERENCE.format(modified_pref) + "\n"; + msg += "" + __("Saved preference %s").format(modified_pref) + "\n"; }); humanMsg.displayAlert(msg); @@ -54,13 +54,13 @@ function mark_modified() { $( this ).addClass( 'modified' ); var name_cell = $( this ).parents( '.name-row' ).find( '.name-cell' ); if ( !name_cell.find( '.modified-warning' ).length ) - name_cell.append( '('+MSG_MODIFIED+')' ); + name_cell.append('(' + __("modified") + ')'); KOHA.Preferences.Modified = true; } window.onbeforeunload = function () { if ( KOHA.Preferences.Modified ) { - return MSG_MADE_CHANGES; + return __("You have made changes to system preferences."); } }; @@ -146,17 +146,17 @@ $( document ).ready( function () { $("#pref_" + target ).hide(); }); - $("h3").attr("class","expanded").attr("title",MSG_CLICK_TO_EXPAND); + $("h3").attr("class", "expanded").attr("title", __("Click to collapse this section")); var collapsible = $(".collapsed,.expanded"); $(collapsible).on("click",function(){ var h3Id = $(this).attr("id"); var panel = $("#collapse_" + h3Id); if(panel.is(":visible")){ - $(this).addClass("collapsed").removeClass("expanded").attr("title",MSG_CLICK_TO_EXPAND); + $(this).addClass("collapsed").removeClass("expanded").attr("title", __("Click to expand this section") ); panel.hide(); } else { - $(this).addClass("expanded").removeClass("collapsed").attr("title",MSG_CLICK_TO_COLLAPSE); + $(this).addClass("expanded").removeClass("collapsed").attr("title", __("Click to collapse this section") ); panel.show(); } }); @@ -168,7 +168,7 @@ $( document ).ready( function () { href = href.replace("#",""); var panel = $("#collapse_" + href ); if( panel.is(":hidden") ){ - $("#" + href ).addClass("expanded").removeClass("collapsed").attr("title",MSG_CLICK_TO_COLLAPSE); + $("#" + href).addClass("expanded").removeClass("collapsed").attr("title", __("Click to collapse this section") ); panel.show(); } }); @@ -187,7 +187,7 @@ $( document ).ready( function () { $("#pref_UpdateItemLocationOnCheckin").change(function(){ var the_text = $(this).val(); var alert_text = ''; - if ( the_text.indexOf('_ALL_:') != -1 ) alert_text = MSG_ALL_VALUE_WARN + '\n'; + if (the_text.indexOf('_ALL_:') != -1) alert_text = __("Note: _ALL_ value will override all other values") + '\n'; var split_text =the_text.split("\n"); var alert_issues = ''; var issue_count = 0; @@ -198,7 +198,7 @@ $( document ).ready( function () { issue_count++; } } - if (issue_count) alert_text += "\n"+ MSG_UPD_LOC_FORMAT_WARN +"\n"+alert_issues; + if (issue_count) alert_text += "\n" + __("The following values are not formatted correctly:") + "\n" + alert_issues; if ( alert_text.length ) alert(alert_text); }); --