Bug 11488 - Untranslatable warning "Are you sure you want to write off ..."
Summary: Untranslatable warning "Are you sure you want to write off ..."
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: I18N/L10N (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Emma Heath
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-07 12:38 UTC by paxed
Modified: 2014-12-07 20:07 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 11488 Untranslatable warning "Are you sure you want to write off ..." (1.34 KB, patch)
2014-01-14 21:26 UTC, Emma Heath
Details | Diff | Splinter Review
Bug 11488 Untranslatable warning "Are you sure you want to write off ..." (1.46 KB, patch)
2014-01-16 15:09 UTC, Jonathan Druart
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 11488 Untranslatable warning "Are you sure you want to write off ..." (1.52 KB, patch)
2014-01-29 16:02 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 11488 Untranslatable warning "Are you sure you want to write off ..." (1.56 KB, patch)
2014-01-31 09:58 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description paxed 2014-01-07 12:38:44 UTC
The following text is not picked up by the translation toolchain:

koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt:            var answer = confirm(_("Are you sure you want to write off [% total | format('%.2f') %] in outstanding fines? This cannot be undone!"));
Comment 1 Emma Heath 2014-01-14 21:26:10 UTC Comment hidden (obsolete)
Comment 2 Owen Leonard 2014-01-15 14:21:49 UTC
This has a few problems which need to be addressed:

Line 19: A tab character was introduced for indentation. Should be spaces.

Line 20:  var answer = "confirm(msg); <-- That quotation mark shouldn't be there.

But the big problem is that even with these problems corrected the patch doesn't work to make the string translatable. I'm not sure what the cause is, but I have a suggestion which might fix the problem and make the string more translation-friendly.

In general it's bad practice to add template variables into the middle of a sentence because it makes assumptions about sentence structure in other languages:

_("Are you sure you want to write off [% total | format('%.2f') %] in outstanding fines? This cannot be undone!")

It would probably be better to move the template variable to the end. Something like this:

_("Are you sure you want to write off these outstanding fines? This cannot be undone! Total writeoff:") + [% total | format('%.2f') %]

Finally: The test plan has to include another step: Making sure the translation script really picks up the string:

In misc/translator run "perl translate update en-GB" (or whatever language you'd like to test). Check the regenerated po file (en-GB-i-staff-t-prog-v-3006000.po in this case) to make sure the string is there.
Comment 3 paxed 2014-01-16 05:34:40 UTC
(In reply to Owen Leonard from comment #2)
> 
> It would probably be better to move the template variable to the end.
> Something like this:
> 
> _("Are you sure you want to write off these outstanding fines? This cannot
> be undone! Total writeoff:") + [% total | format('%.2f') %]
> 

No. Just... no. That is much worse. Hard-coding the placement of the number will create it's own problems.
Comment 4 Owen Leonard 2014-01-16 13:55:40 UTC
(In reply to paxed from comment #3)

> No. Just... no. That is much worse. Hard-coding the placement of the number
> will create it's own problems.

Please provide a better alternative, with explanation.
Comment 5 Jonathan Druart 2014-01-16 15:09:59 UTC Comment hidden (obsolete)
Comment 6 Jonathan Druart 2014-01-16 15:10:21 UTC
What about this solution?
Comment 7 Katrin Fischer 2014-01-16 15:21:14 UTC
I think both opinions are valid here. 

The best way to translate something is with a placeholder in the sentence. Because this way, you can build your sentence the way you want with the variable in whatever position it needs to be. 

The problem is, that we have to differentiate a bit between TT code and Javascript code, because of bug bug 7327. So if you use + the string will get cut up into small separate pieces that might not be easy to translate if the variable is in the middle of a sentence. So Owen's suggestion makes sense.

Could we use a different technique here? Maybe add a placeholder in a different way that is then replaced by the Javascript? I think the datatables navigation/paging seems to do something like this.

And just now I see that Jonathan proposed something like it... :)
Comment 8 Owen Leonard 2014-01-29 16:02:57 UTC
Created attachment 24867 [details] [review]
[SIGNED-OFF] Bug 11488 Untranslatable warning "Are you sure you want to write off ..."

Test plan:
- ./translate update LANG
- translate the string into your po file
- ./translate install LANG
- Verify the string is translated.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 9 Marcel de Rooy 2014-01-31 09:58:41 UTC
Created attachment 24922 [details] [review]
Bug 11488 Untranslatable warning "Are you sure you want to write off ..."

Test plan:
- ./translate update LANG
- translate the string into your po file
- ./translate install LANG
- Verify the string is translated.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 10 Galen Charlton 2014-01-31 15:52:17 UTC
Pushed to master.  Thanks, Jonathan!