Bug 9161 - Translate only specific files
Summary: Translate only specific files
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: translate.koha-community.org (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Jonathan Druart
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-28 10:10 UTC by Jonathan Druart
Modified: 2014-12-07 20:02 UTC (History)
3 users (show)

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


Attachments
Bug 9161: translate only 1 specific file (7.83 KB, patch)
2012-11-28 10:16 UTC, Jonathan Druart
Details | Diff | Splinter Review
MT9161: Followup change the maching test (1.22 KB, patch)
2012-11-28 10:31 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 9161: Followup: Add a -f param for the translate script (4.30 KB, patch)
2012-11-28 11:21 UTC, Jonathan Druart
Details | Diff | Splinter Review
Signed-off patch (13.46 KB, patch)
2012-12-20 06:30 UTC, Frédéric Demians
Details | Diff | Splinter Review
Bug 9161: Followup: the -f param does not work correctly (4.60 KB, patch)
2013-01-29 13:38 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 9161: Allow to specificy a complete relpath instead of a filename (1.25 KB, patch)
2013-02-01 10:00 UTC, Jonathan Druart
Details | Diff | Splinter Review
Signed-off patch (merged follow-up) (5.32 KB, patch)
2013-02-10 07:29 UTC, Frédéric Demians
Details | Diff | Splinter Review
Bug 9161: Translate only specific files (13.52 KB, patch)
2013-05-24 00:47 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 9161: Followup: the -f param does not work correctly (5.37 KB, patch)
2013-05-24 00:47 UTC, Chris Cormack
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2012-11-28 10:10:41 UTC
Contrary to the POD say, it is not possible to translate only one file. Very usefull for debug.
Comment 1 Jonathan Druart 2012-11-28 10:16:39 UTC Comment hidden (obsolete)
Comment 2 Jonathan Druart 2012-11-28 10:31:36 UTC Comment hidden (obsolete)
Comment 3 Jonathan Druart 2012-11-28 11:21:07 UTC Comment hidden (obsolete)
Comment 4 Frédéric Demians 2012-12-20 06:30:12 UTC Comment hidden (obsolete)
Comment 5 Jonathan Druart 2013-01-29 13:38:58 UTC Comment hidden (obsolete)
Comment 6 Jonathan Druart 2013-02-01 10:00:49 UTC Comment hidden (obsolete)
Comment 7 Frédéric Demians 2013-02-10 07:29:47 UTC Comment hidden (obsolete)
Comment 8 Chris Cormack 2013-05-24 00:47:38 UTC
Created attachment 18362 [details] [review]
Bug 9161: Translate only specific files

The previous version of tmpl_process3.pl says in the pod:

  -i, --input=SOURCE          Get or update strings from SOURCE file.
                              SOURCE is a directory if -r is also specified.

But is was not possible to specify one or more files.

This patch allows us to give one or more specific file with the -f
parameter.

for eg.:

perl tmpl_process3.pl install -i /home/koha/koha-tmpl/opac-tmpl/prog/en/modules/
    -o /home/koha/koha-tmpl/opac-tmpl/prog/fr-FR/modules/
    -s /home/koha/misc/translator/po/fr-FR-i-opac-t-prog-v-3006000.po
    -r
    -f opac-account.tt
    -f opac-main.tt

You can specify:
  -f advsearch.tt => translate all files with a filename containing
  'advsearch.tt'
or
  -f search => will translate acqui/histsearch.tt, acqui/z3950_search.tt, etc.

Bug 9161: Followup: Add a -f param for the translate script

Now you can directly call the translate script
(misc/translator/translate) with the -f parameter

eg.:
./translate install|create|update -f search.tt -f main.tt

Signed-off-by: Frédéric Demians <f.demians@tamil.fr>

I've squashed the 3 patches, and reported doc into 'translate' script.
It works as advertised.

Side note: It would be great to extend this functionnality in order to
be able to apply the translation to XSL files stored outside Koha
directories hierarchy. Useful to translate site-specific XSLs defined
with XSLTResultsDisplay, and other sysprefs.

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Comment 9 Chris Cormack 2013-05-24 00:47:49 UTC
Created attachment 18363 [details] [review]
Bug 9161: Followup: the -f param does not work correctly

Without this patch, the -f param (for the translate script) add the
modified line in the po file BUT comment all lines from others files.

This patch concat the generated file with the previous one and merge
them. This way produce a pretty po file with all our strings :)

+ Modification in LangInstaller.pm to fix a bug when the -f param was not
given.

Test plan:
1/ Update your po file :
cd misc/translator
perl translate update fr-FR
git commit -a -m"TMP PO"
2/ Modification on 2 files:
ie.
catalogue/advsearch.tt:32 <h1>Advanced search Foo</h1>
catalogue/issuehistory.tt:38 <th>Patron Bar</th>

3/ Update your po file with only the first file:
perl translate update fr-FR -f advsearch.tt

4/ Edit your po file and check that only the foo string is present (or
git diff).

5/ Update your po file with only the second file:
perl translate update fr-FR -f issuehistory

6/ Edit your po file and check that 2 strings are present (or git diff).

7/ Change the translation for these 2 strings and delete the fuzzy
lines.

8/ Install the first file for your language:
perl translate install fr-FR -f advsearch.tt

9/ Edit your translated file and verify the string is translated. Check
that the issuehistory.tt file is not changed.

10/ Same for issuehistory:
perl translate install fr-FR -f issuehistory

11/ stash your modification in your tt files (or reset --hard):
git stash

12/ Check in your po file that the 2 strings are commented (git diff).

13/ To finish, install all template files and check that they are
replaced correctly:
perl translate install fr-FR

Signed-off-by: Frédéric Demians <f.demians@tamil.fr>

I have squashed the both follow-up patches.

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Comment 10 Chris Cormack 2013-05-24 00:49:32 UTC
Passes all tests, and works as advertised without breaking existing functionality.
Comment 11 Galen Charlton 2013-05-24 16:16:29 UTC
Pushed to master.  Thanks, Jonathan!