Bug 12138 - Use placeholders in translatable javascript strings
Summary: Use placeholders in translatable javascript strings
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: I18N/L10N (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: paxed
QA Contact: Testopia
URL:
Keywords:
: 7327 (view as bug list)
Depends on:
Blocks: 12161
  Show dependency treegraph
 
Reported: 2014-04-25 08:07 UTC by paxed
Modified: 2014-12-07 20:07 UTC (History)
3 users (show)

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


Attachments
Use formatting for translatable javascript strings (43.61 KB, patch)
2014-04-25 08:07 UTC, paxed
Details | Diff | Splinter Review
Bug 12138 - Use placeholders in translatable javascript strings (45.03 KB, patch)
2014-04-25 14:58 UTC, Owen Leonard
Details | Diff | Splinter Review
[PASSED QA] Bug 12138 - Use placeholders in translatable javascript strings (45.17 KB, patch)
2014-04-26 19:29 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description paxed 2014-04-25 08:07:02 UTC Comment hidden (obsolete)
Comment 1 Owen Leonard 2014-04-25 14:58:35 UTC Comment hidden (obsolete)
Comment 2 Katrin Fischer 2014-04-26 19:26:16 UTC
*** Bug 7327 has been marked as a duplicate of this bug. ***
Comment 3 Katrin Fischer 2014-04-26 19:29:12 UTC
Created attachment 27664 [details] [review]
[PASSED QA] Bug 12138 - Use placeholders in translatable javascript strings

Currently translating javascript strings with variables in them is hard,
because the strings are created from separate parts. For example:

 _("Are you sure you want to delete the") + " " + count + " " +
_("attached items?")

This is translated in two different parts, and the translator cannot
affect the place where the count-variable is.

Now, if the javascript strings allowed placeholders, similar to how the
template strings do, the above could be written as:

_("Are you sure you want to delete the %s attached
items?").format(count)

This would make translation much easier.

Attached patch adds a javascript string formatter, and changes all the
concatenated translatable js strings used in intranet to use that.

To test:
1) cd misc/translator
2) perl translate update xx-YY
3) grep ^msgid po/xx-YY-i-staff-t-prog-v-3006000.po | sort | uniq >
xx-YY-pre
4) apply patch
5) perl translate update xx-YY
6) grep ^msgid po/xx-YY-i-staff-t-prog-v-3006000.po | sort | uniq >
xx-YY-post
7) compare the files: diff -Nurd xx-YY-pre xx-yy-post | less
   should show the javascript strings that changed.
8) Test the UIs where the formatted js strings are used.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

I tested *most* of the changed files. There were some instances where it
wasn't clear to me how to trigger the warnings which were modified,
especially tags/review.tt, admin/manage-marc-import.tt, and holidays.tt.
Everything I was able to test worked correctly.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>

Works nicely, no regressions found. Thx!
Comment 4 Galen Charlton 2014-04-27 22:05:12 UTC
Pushed to master.  Thanks, Pasi!