Bug 7327 - Translation script doesn't like concatenated javascript strings
Summary: Translation script doesn't like concatenated javascript strings
Status: RESOLVED DUPLICATE of bug 12138
Alias: None
Product: Koha
Classification: Unclassified
Component: I18N/L10N (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Aleksa Vujicic
QA Contact: Ian Walls
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-07 06:16 UTC by Katrin Fischer
Modified: 2014-04-26 19:26 UTC (History)
1 user (show)

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


Attachments
Translate scripts now handle javascript variables inside strings. (6.74 KB, patch)
2012-01-30 22:54 UTC, Aleksa Vujicic
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Katrin Fischer 2011-12-07 06:16:08 UTC
I noticed that some alerts are (no longer?) translated.

Example: cat-toolbar.inc
is_confirmed= alert(_('There are [ '+ count +' ] item(s) attached to this record \n You must delete all items before deleting this record.'));

This string doesn't get translated at all now. Also the \n is not good because it causes problems in Pootle.

The only solution to make this translatable seems to be:

is_confirmed= alert(_("There are [ ") + count + _(" ] item(s) attached to this record.") + "\n" + _("You must delete all items before deleting this record."

By splitting it up into several part the sentence is very hard to translate. Also small pieces like "Delete" or "There are" are difficult, because you might want to use different words for it in your translation.

It would be better if we can make the translation script deal with those strings and make it put in placeholders. So you would end up with:

is_confirmed= alert(_('There are [ '+ count +' ] item(s) attached to this record \n You must delete all items before deleting this record.'));

Output in po-file:
There are [ %s ] item(s) attached to this record. ...

I think this is a bug now, because those alerts don't get translated at all. Splitting them up is one solution, but fixing the translation scripts would be much better.
Comment 1 Aleksa Vujicic 2012-01-30 22:54:55 UTC
Created attachment 7392 [details] [review]
Translate scripts now handle javascript variables inside strings.

The translation scripts now convert variables into '%s' when generating or reading from .po files, and convert '%s' into variables when creating translated .tt files. This means that it should work when creating, updating, or installing a language.
Comment 2 Owen Leonard 2012-02-07 17:26:50 UTC
What is a test plan for this? Is it necessary to edit the .po file to test?
Comment 3 Liz Rea 2012-02-07 18:21:16 UTC
I was testing this and noted some anomalies - namely that the javascript menus were broken after running the new translation scripts. 

I would have to spend some time looking at po files that were right before I could determine whether or not the script is working correctly - things looked mighty strange in there to me.
Comment 4 Katrin Fischer 2012-03-08 07:17:41 UTC
I can reproduce the problems with javascript Liz noted. This is my test plan:

1) Applied the patch
2) Ran perl translate update <langcode> on 2 languages (de-DE, it-IT)
3) Ran perl translate install <langcode) on my 2 languages
4) Turned on those languages in systempreferences
5) Checked
- normal templates
- javascript toolbars (example: circulation?
- XSLT translation (OPAC, staff)
- javascript error messages (cataloging, trying to delete record with items)

Examples for found problems:

- Toolbar in patron account in staff (circulation)
- OPAC deatail page - item tabs and more searches
Comment 5 Katrin Fischer 2014-04-26 19:26:16 UTC

*** This bug has been marked as a duplicate of bug 12138 ***