From 1bc6e7afd881ca9ffdd7c5bc13d7c98a0f176201 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 14 Oct 2024 11:54:54 -0300 Subject: [PATCH] Bug 38166: Make core status graph strings translatable This patch makes several strings translatable. I usually dealth with this by adding my statuses like `NEW` to the status graph shippped by the backend I was working with, and solved the translation step inside of the plugin itself. But really, the core status graph should be translatable so core backends (like the to-be FreeForm) and backend authors can rest assured they only need to care about their custom statuses. To test: 1. Make sure you have 35570 applied so it is easier to test 2. Enable the ILLModule syspref. 3. Install a language you're familiar with. I pick es-ES for the sake of this testing steps to be readable: $ ktd --shell k$ koha-translate --install es-ES --dev kohadev && restart_all 4. Enable (language sysprefs) and switch to your language (click at the left bottom on the language name). 5. Create a new ILL request => FAIL: Notice some buttons are not in your language 6. Jump to the ILL requests list => FAIL: The status displays as 'New request' 7. Apply this patch 8. Generate the translation entries for the core status graph strings: k$ gulp po:extract k$ gulp po:update # I had to run it twice to complete, unrelated error 9. Edit the relevant -messages.po file. In my case: k$ vim misc/translator/po/es-ES-messages.po Note: it is easier on VScode which shows you the changed lines in colors on the scroll bar. The idea is to find the new strings that relate to Koha::ILL::Request and translate them 10. Translate the strings that relate to this patch (at least 'New request' and some of the buttons in the ILL request detail). 11. Install the new translations: k$ koha-translate --update es-ES --dev kohadev && restart_all 12. Refresh the ILL requests list => SUCCESS: The request status is translated! 13. Manage the ILL request => SUCCESS: The buttons you translated, are translated!! 14. Sign off :-D 15. Grant tcohen some cookies next time Signed-off-by: Tomas Cohen Arazi --- Koha/ILL/Request.pm | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/Koha/ILL/Request.pm b/Koha/ILL/Request.pm index 9bc3ebc4d20..6ea5742228e 100644 --- a/Koha/ILL/Request.pm +++ b/Koha/ILL/Request.pm @@ -34,6 +34,7 @@ use Koha::Cache::Memory::Lite; use Koha::Database; use Koha::DateUtils qw( dt_from_string ); use Koha::Exceptions::Ill; +use Koha::I18N qw(__); use Koha::ILL::Backend::Standard; use Koha::ILL::Batches; use Koha::ILL::Comments; @@ -577,8 +578,8 @@ sub _core_status_graph { prev_actions => [ ], # Actions containing buttons # leading to this status id => 'NEW', # ID of this status - name => 'New request', # UI name of this status - ui_method_name => 'New request', # UI name of method leading + name => __('New request'), # UI name of this status + ui_method_name => __('New request'), # UI name of method leading # to this status method => 'create', # method to this status next_actions => [ 'REQ', 'GENREQ', 'KILL' ], # buttons to add to all @@ -588,8 +589,8 @@ sub _core_status_graph { REQ => { prev_actions => [ 'NEW', 'REQREV', 'QUEUED', 'CANCREQ' ], id => 'REQ', - name => 'Requested', - ui_method_name => 'Confirm request', + name => __('Requested'), + ui_method_name => __('Confirm request'), method => 'confirm', next_actions => [ 'REQREV', 'COMP', 'CHK' ], ui_method_icon => 'fa-check', @@ -597,8 +598,8 @@ sub _core_status_graph { GENREQ => { prev_actions => [ 'NEW', 'REQREV' ], id => 'GENREQ', - name => 'Requested from partners', - ui_method_name => 'Place request with partners', + name => __('Requested from partners'), + ui_method_name => __('Place request with partners'), method => 'generic_confirm', next_actions => [ 'COMP', 'CHK', 'REQREV' ], ui_method_icon => 'fa-paper-plane', @@ -606,8 +607,8 @@ sub _core_status_graph { REQREV => { prev_actions => [ 'REQ', 'GENREQ' ], id => 'REQREV', - name => 'Request reverted', - ui_method_name => 'Revert request', + name => __('Request reverted'), + ui_method_name => __('Revert request'), method => 'cancel', next_actions => [ 'REQ', 'GENREQ', 'KILL' ], ui_method_icon => 'fa-times', @@ -615,7 +616,7 @@ sub _core_status_graph { QUEUED => { prev_actions => [ ], id => 'QUEUED', - name => 'Queued request', + name => __('Queued request'), ui_method_name => 0, method => 0, next_actions => [ 'REQ', 'KILL' ], @@ -624,7 +625,7 @@ sub _core_status_graph { CANCREQ => { prev_actions => [ 'NEW' ], id => 'CANCREQ', - name => 'Cancellation requested', + name => __('Cancellation requested'), ui_method_name => 0, method => 0, next_actions => [ 'KILL', 'REQ' ], @@ -633,8 +634,8 @@ sub _core_status_graph { COMP => { prev_actions => [ 'REQ' ], id => 'COMP', - name => 'Completed', - ui_method_name => 'Mark completed', + name => __('Completed'), + ui_method_name => __('Mark completed'), method => 'mark_completed', next_actions => [ 'CHK' ], ui_method_icon => 'fa-check', @@ -643,7 +644,7 @@ sub _core_status_graph { prev_actions => [ 'QUEUED', 'REQREV', 'NEW', 'CANCREQ' ], id => 'KILL', name => 0, - ui_method_name => 'Delete request', + ui_method_name => __('Delete request'), method => 'delete', next_actions => [ ], ui_method_icon => 'fa-trash', @@ -651,8 +652,8 @@ sub _core_status_graph { CHK => { prev_actions => [ 'REQ', 'GENREQ', 'COMP' ], id => 'CHK', - name => 'Checked out', - ui_method_name => 'Check out', + name => __('Checked out'), + ui_method_name => __('Check out'), needs_prefs => [ 'CirculateILL' ], needs_perms => [ 'user_circulate_circulate_remaining_permissions' ], # An array of functions that all must return true @@ -664,8 +665,8 @@ sub _core_status_graph { RET => { prev_actions => [ 'CHK' ], id => 'RET', - name => 'Returned to library', - ui_method_name => 'Check in', + name => __('Returned to library'), + ui_method_name => __('Check in'), method => 'check_in', next_actions => [ 'COMP' ], ui_method_icon => 'fa-download', -- 2.47.0