Bug 38900

Summary: Translation script explodes without a meaningful error when an "incorrect" structure is found
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: I18N/L10NAssignee: Jonathan Druart <jonathan.druart>
Status: Pushed to main --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: david, dcook, f.demians, jonathan.druart, julian.maurice
Version: unspecified   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38720
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
This fixes the translation script so that it now provides a more meaningful error when updating a language that has incorrect strings. It now identifies exactly where the problem comes from, making it easier to fix the problem. An example of the updated error message: gulp po:update --lang LANG .. Incorrect structure found at ./koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt:230: '<option value="*" ' at misc/translator/xgettext.pl line 124, <$INPUT> line 65. ..
Version(s) released in:
25.05.00
Circulation function:
Bug Depends on:    
Bug Blocks: 38714    
Attachments: Bug 38900: Provide info about the problematic strings
Bug 38900: [DO NOT PUSH] show the problem
Bug 38900: Provide info about the problematic strings
Bug 38900: [DO NOT PUSH] show the problem
Bug 38900: Provide info about the problematic strings
Bug 38900: Provide info about the problematic strings

Description Jonathan Druart 2025-01-15 13:27:55 UTC
Found when working on bug 38714, the translation script can break with en error that does directly point to the problematic string

[13:00:23] Error: Command failed: misc/translator/xgettext.pl --charset=UTF-8 -F -o /tmp/koha-2rwDEm/Koha-opac-bootstrap.pot -f /tmp/koha-2rwDEm/files                                                               
Can't use an undefined value as a HASH reference at misc/translator/xgettext.pl line 131.                 
                                                                                                          
    at ChildProcess.exithandler (node:child_process:422:12)                                                                                                                                                          
    at ChildProcess.emit (node:events:517:28)                                                                                                                                                                        
    at ChildProcess.emit (node:domain:552:15)                                                                                                                                                                        
    at maybeClose (node:internal/child_process:1098:16)                                                                                                                                                              
    at ChildProcess._handle.onexit (node:internal/child_process:303:5)                                                                                                                                               
    at Process.callbackTrampoline (node:internal/async_hooks:128:17)                                                                                                                                                 
[13:00:23] 'po:update' errored after 992 ms
Comment 1 Jonathan Druart 2025-01-15 13:36:40 UTC
Created attachment 176568 [details] [review]
Bug 38900: Provide info about the problematic strings

The ranslation script explodes without meaningful error when "incorrect" structure is found (edit)

Found when working on bug 38714, the translation script can break with en error that does directly point to the problematic string

[13:00:23] Error: Command failed: misc/translator/xgettext.pl --charset=UTF-8 -F -o /tmp/koha-2rwDEm/Koha-opac-bootstrap.pot -f /tmp/koha-2rwDEm/files
Can't use an undefined value as a HASH reference at misc/translator/xgettext.pl line 131.

    at ChildProcess.exithandler (node:child_process:422:12)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess.emit (node:domain:552:15)
    at maybeClose (node:internal/child_process:1098:16)
    at ChildProcess._handle.onexit (node:internal/child_process:303:5)
    at Process.callbackTrampoline (node:internal/async_hooks:128:17)
[13:00:23] 'po:update' errored after 992 ms

Test plan:
0. Use main and confirm that `gulp po:update --lang LANG` returns
   successfully
1. Apply the first patch
=> The error is
Can't use an undefined value as a HASH reference at misc/translator/xgettext.pl line 131, <$INPUT> line 80.
2. Apply this patch
=> The error is now:
Incorrect structure found at ./koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt:230: '<option value="*" ' at misc/translator/xgettext.pl line 124, <$INPUT> line 100.

Which is way more interesting to fix the problem as we know exactly
where the problem comes from
Comment 2 Jonathan Druart 2025-01-15 13:38:37 UTC
Created attachment 176569 [details] [review]
Bug 38900: [DO NOT PUSH] show the problem
Comment 3 Jonathan Druart 2025-01-15 13:38:40 UTC
Created attachment 176570 [details] [review]
Bug 38900: Provide info about the problematic strings

The ranslation script explodes without meaningful error when "incorrect" structure is found (edit)

Found when working on bug 38714, the translation script can break with en error that does directly point to the problematic string

[13:00:23] Error: Command failed: misc/translator/xgettext.pl --charset=UTF-8 -F -o /tmp/koha-2rwDEm/Koha-opac-bootstrap.pot -f /tmp/koha-2rwDEm/files
Can't use an undefined value as a HASH reference at misc/translator/xgettext.pl line 131.

    at ChildProcess.exithandler (node:child_process:422:12)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess.emit (node:domain:552:15)
    at maybeClose (node:internal/child_process:1098:16)
    at ChildProcess._handle.onexit (node:internal/child_process:303:5)
    at Process.callbackTrampoline (node:internal/async_hooks:128:17)
[13:00:23] 'po:update' errored after 992 ms

Test plan:
0. Use main and confirm that `gulp po:update --lang LANG` returns
   successfully
1. Apply the first patch
=> The error is
Can't use an undefined value as a HASH reference at misc/translator/xgettext.pl line 131, <$INPUT> line 80.
2. Apply this patch
=> The error is now:
Incorrect structure found at ./koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt:230: '<option value="*" ' at misc/translator/xgettext.pl line 124, <$INPUT> line 100.

Which is way more interesting to fix the problem as we know exactly
where the problem comes from
Comment 4 David Nind 2025-01-15 19:18:14 UTC
Created attachment 176583 [details] [review]
Bug 38900: [DO NOT PUSH] show the problem

Signed-off-by: David Nind <david@davidnind.com>
Comment 5 David Nind 2025-01-15 19:18:17 UTC
Created attachment 176584 [details] [review]
Bug 38900: Provide info about the problematic strings

The ranslation script explodes without meaningful error when "incorrect" structure is found (edit)

Found when working on bug 38714, the translation script can break with en error that does directly point to the problematic string

[13:00:23] Error: Command failed: misc/translator/xgettext.pl --charset=UTF-8 -F -o /tmp/koha-2rwDEm/Koha-opac-bootstrap.pot -f /tmp/koha-2rwDEm/files
Can't use an undefined value as a HASH reference at misc/translator/xgettext.pl line 131.

    at ChildProcess.exithandler (node:child_process:422:12)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess.emit (node:domain:552:15)
    at maybeClose (node:internal/child_process:1098:16)
    at ChildProcess._handle.onexit (node:internal/child_process:303:5)
    at Process.callbackTrampoline (node:internal/async_hooks:128:17)
[13:00:23] 'po:update' errored after 992 ms

Test plan:
0. Use main and confirm that `gulp po:update --lang LANG` returns
   successfully
1. Apply the first patch
=> The error is
Can't use an undefined value as a HASH reference at misc/translator/xgettext.pl line 131, <$INPUT> line 80.
2. Apply this patch
=> The error is now:
Incorrect structure found at ./koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt:230: '<option value="*" ' at misc/translator/xgettext.pl line 124, <$INPUT> line 100.

Which is way more interesting to fix the problem as we know exactly
where the problem comes from

Signed-off-by: David Nind <david@davidnind.com>
Comment 6 David Nind 2025-01-15 19:32:52 UTC
Full error after applying the patch:

gulp po:update --lang fr-CA
[19:17:24] Using gulpfile /kohadevbox/koha/gulpfile.js
[19:17:24] Starting 'po:update'...
[19:17:24] Starting 'po_update_marc_marc21'...
[19:17:24] Starting 'po_update_marc_unimarc'...
[19:17:24] Starting 'po_update_staff'...
[19:17:24] Starting 'po_update_opac'...
[19:17:24] Starting 'po_update_pref'...
[19:17:24] Starting 'po_update_messages'...
[19:17:24] Starting 'po_update_messages_js'...
[19:17:24] Starting 'po_update_installer'...
[19:17:24] Starting 'po_update_installer_marc21'...
[19:17:24] Starting 'po_update_installer_unimarc'...
[19:17:27] Finished 'po_update_installer_unimarc' after 2.43 s
[19:17:27] Finished 'po_update_installer' after 2.55 s
[19:17:27] Finished 'po_update_installer_marc21' after 2.59 s
[19:17:27] Finished 'po_update_pref' after 2.6 s
[19:17:27] Finished 'po_update_messages_js' after 2.81 s
[19:17:27] Finished 'po_update_opac' after 3.3 s
[19:17:27] 'po_update_staff' errored after 3.31 s
[19:17:27] Error: Command failed: misc/translator/xgettext.pl --charset=UTF-8 -F -o /tmp/koha-OQ7riK/Koha-staff-prog.pot -f /tmp/koha-OQ7riK/files
Incorrect structure found at ./koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt:230: '<option value="*" ' at misc/translator/xgettext.pl line 124, <$INPUT> line 65.

    at ChildProcess.exithandler (node:child_process:422:12)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess.emit (node:domain:552:15)
    at maybeClose (node:internal/child_process:1098:16)
    at ChildProcess._handle.onexit (node:internal/child_process:303:5)
    at Process.callbackTrampoline (node:internal/async_hooks:128:17)
[19:17:27] 'po:update' errored after 3.32 s
Comment 7 Julian Maurice 2025-01-30 14:27:37 UTC
Created attachment 177354 [details] [review]
Bug 38900: Provide info about the problematic strings

The translation script explodes without meaningful error when
"incorrect" structure is found (edit)

Found when working on bug 38714, the translation script can break with
an error that does not directly point to the problematic string

[13:00:23] Error: Command failed: misc/translator/xgettext.pl --charset=UTF-8 -F -o /tmp/koha-2rwDEm/Koha-opac-bootstrap.pot -f /tmp/koha-2rwDEm/files
Can't use an undefined value as a HASH reference at misc/translator/xgettext.pl line 131.

    at ChildProcess.exithandler (node:child_process:422:12)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess.emit (node:domain:552:15)
    at maybeClose (node:internal/child_process:1098:16)
    at ChildProcess._handle.onexit (node:internal/child_process:303:5)
    at Process.callbackTrampoline (node:internal/async_hooks:128:17)
[13:00:23] 'po:update' errored after 992 ms

Test plan:
0. Use main and confirm that `gulp po:update --lang LANG` returns
   successfully
1. Apply the first patch
=> The error is
Can't use an undefined value as a HASH reference at misc/translator/xgettext.pl line 131, <$INPUT> line 80.
2. Apply this patch
=> The error is now:
Incorrect structure found at ./koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt:230: '<option value="*" ' at misc/translator/xgettext.pl line 124, <$INPUT> line 100.

Which is way more interesting to fix the problem as we know exactly
where the problem comes from

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Comment 8 Katrin Fischer 2025-01-30 17:56:16 UTC
Pushed for 25.05!

Well done everyone, thank you!