Bugzilla – Attachment 108527 Details for
Bug 26237
Move translatable strings out of preferences.tt and into JavaScript files
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26237: Move translatable strings out of preferences.tt and into JavaScript files
Bug-26237-Move-translatable-strings-out-of-prefere.patch (text/plain), 9.93 KB, created by
Owen Leonard
on 2020-08-18 16:08:47 UTC
(
hide
)
Description:
Bug 26237: Move translatable strings out of preferences.tt and into JavaScript files
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2020-08-18 16:08:47 UTC
Size:
9.93 KB
patch
obsolete
>From cfb3baa97f9aedc0373caec19549e62f89a2ed25 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Tue, 18 Aug 2020 15:11:10 +0000 >Subject: [PATCH] Bug 26237: Move translatable strings out of preferences.tt > and into JavaScript files > >This patch removes the definition of translatable strings out of >templates and into the corresponding JavaScript file, using the new JS >i81n function. > >To test (a non-comprehensive list): > >- 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 > <pref name>" >- 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." > >TESTING TRANSLATABILITY > >- 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(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt >index 4ec818f470..941974dc67 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt >+++ b/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." ); > </script> > [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %] > [% Asset.js("js/ajax.js") | $raw %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/ajax.js b/koha-tmpl/intranet-tmpl/prog/js/ajax.js >index eebfa1c95c..805a05fbaa 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/ajax.js >+++ b/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 () { >diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js b/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js >index 8bb977aa4d..2ff49b3f3b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js >+++ b/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 += "<strong>"+ MSG_SAVED_PREFERENCE.format(modified_pref) + "</strong>\n"; >+ msg += "<strong>" + __("Saved preference %s").format(modified_pref) + "</strong>\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( '<em class="modified-warning">('+MSG_MODIFIED+')</em>' ); >+ name_cell.append('<em class="modified-warning">(' + __("modified") + ')</em>'); > 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); > }); > >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26237
:
108527
|
110780
|
110788