From 7a3c48e5825c24c17fff8ae424477581e21930f5 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@biblibre.com>
Date: Tue, 29 Oct 2013 15:03:41 +0100
Subject: [PATCH] Bug 9216: columns.def file is not translatable

The sql column headers is stored into the columns.def file.
This file is not managed by the translation script.

This patch makes possible the headers translation.
Note: The translation xml tags were added to avoid all lines to be put
on a single line.

Test plan:
1/ update your po file
cd misc/translate;
perl translate -f columns update LANG # Replace by another language here
2/ translate header columns (search "columns.def" in your po file).
Be careful, you have to keep the column names!
3/ install the translated columns.def
perl translate -f columns install LANG # Replace by another language here
4/ go on the report module > create a new report > next > next
5/ change the language
on the 3rd step, you should see the column header translated.
---
 C4/Reports/Guided.pm                        |   39 ++--
 koha-tmpl/intranet-tmpl/prog/en/columns.def |  280 +++++++++++++--------------
 misc/translator/tmpl_process3.pl            |    2 +-
 3 files changed, 163 insertions(+), 158 deletions(-)

diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm
index 22a23dd..b1eba02 100644
--- a/C4/Reports/Guided.pm
+++ b/C4/Reports/Guided.pm
@@ -835,23 +835,28 @@ sub get_sql {
 }
 
 sub _get_column_defs {
-	my ($cgi) = @_;
-	my %columns;
-	my $columns_def_file = "columns.def";
-	my $htdocs = C4::Context->config('intrahtdocs');                       
-	my $section='intranet';
-    my ($theme, $lang, $availablethemes) = C4::Templates::themelanguage($htdocs, $columns_def_file, $section,$cgi);
-
-	my $full_path_to_columns_def_file="$htdocs/$theme/$lang/$columns_def_file";    
-	open (COLUMNS,$full_path_to_columns_def_file);
-	while (my $input = <COLUMNS>){
-		chomp $input;
-		my @row =split(/\t/,$input);
-		$columns{$row[0]}= $row[1];
-	}
-
-	close COLUMNS;
-	return \%columns;
+    my ($cgi) = @_;
+    my %columns;
+    my $columns_def_file = "columns.def";
+    my $htdocs = C4::Context->config('intrahtdocs');
+    my $section = 'intranet';
+
+    # We need the theme and the lang
+    # Since columns.def is not in the modules directory, we cannot sent it for the $tmpl var
+    my ($theme, $lang, $availablethemes) = C4::Templates::themelanguage($htdocs, 'about.tt', $section, $cgi);
+
+    my $full_path_to_columns_def_file="$htdocs/$theme/$lang/$columns_def_file";
+    open (my $fh, $full_path_to_columns_def_file);
+    while ( my $input = <$fh> ){
+        chomp $input;
+        $input =~ s|<translation>(.*)</translation>|$1|;
+        if ( $input =~ m|([^:]*):(.*)| ) {
+            my ( $field, $translation ) = ( $1, $2 );
+            $columns{$field} = $translation;
+        }
+    }
+    close $fh;
+    return \%columns;
 }
 
 =head2 build_authorised_value_list($authorised_value)
diff --git a/koha-tmpl/intranet-tmpl/prog/en/columns.def b/koha-tmpl/intranet-tmpl/prog/en/columns.def
index c48fa48..9f55d74 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/columns.def
+++ b/koha-tmpl/intranet-tmpl/prog/en/columns.def
@@ -1,140 +1,140 @@
-borrowers.borrowernumber	Borrower number
-borrowers.title	Salutation
-borrowers.surname	Surname
-borrowers.firstname	First name
-borrowers.dateofbirth	Date of birth
-borrowers.initials	Initials
-borrowers.othernames	Other name
-borrowers.sex	Gender
-borrowers.relationship	Relationship
-borrowers.guarantorid	Guarantor borrower number
-borrowers.streetnumber	Street number
-borrowers.streettype	Street type
-borrowers.address	Address
-borrowers.address2	Address 2
-borrowers.city	City
-borrowers.state	State
-borrowers.zipcode	Zip/postal code
-borrowers.country	Country
-borrowers.phone	Primary phone
-borrowers.phonepro	Secondary phone
-borrowers.mobile	Other phone
-borrowers.email	Primary email
-borrowers.emailpro	Secondary email
-borrowers.fax	Fax
-borrowers.B_streetnumber	Alternate address: Street number
-borrowers.B_streettype	Alternate address: Street type
-borrowers.B_address	Alternate address: Address
-borrowers.B_address2	Alternate address: Address 2
-borrowers.B_city	Alternate address: City
-borrowers.B_state	Alternate address: State
-borrowers.B_zipcode	Alternate address: Zip/postal code
-borrowers.B_country	Alternate address: Country
-borrowers.B_phone	Alternate address: Phone
-borrowers.B_email	Alternate address: Email
-borrowers.contactnote	Alternate contact: Note
-borrowers.altcontactfirstname	Alternate contact: Last name
-borrowers.altcontactsurname	Alternate contact: First name
-borrowers.altcontactaddress1	Alternate contact: Address
-borrowers.altcontactaddress2	Alternate contact: Address 2
-borrowers.altcontactaddress3	Alternate contact: City
-borrowers.contactname	Alternate contact: Surname
-borrowers.contactfirstname	Alternate contact: First name
-borrowers.contacttitle	Alternate contact: Title
-borrowers.altcontactstate	Alternate contact: State
-borrowers.altcontactzipcode	Alternate contact: Zip/postal code
-borrowers.altcontactcountry	Alternate contact: Country
-borrowers.altcontactphone	Alternate contact: Phone
-borrowers.cardnumber	Card number
-borrowers.branchcode	Home library
-borrowers.categorycode	Category
-borrowers.sort1	Sort 1
-borrowers.sort2	Sort 2
-borrowers.dateenrolled	Registration date
-borrowers.dateexpiry	Expiry date
-borrowers.opacnote	OPAC note
-borrowers.borrowernotes	Circulation note
-borrowers.userid	Username
-borrowers.password	Password
-borrowers.flags	System permissions
-borrowers.gonenoaddress	Gone no address flag
-borrowers.lost	Lost card flag
-borrowers.debarred	Restricted [until] flag
-borrowers.debarredcomment	Comment
-borrowers.smsalertnumber	Mobile phone number
-borrowers.privacy	Privacy settings
-items.itemnumber	Item number (internal)
-items.biblionumber	Biblio number (internal)
-items.biblioitemnumber	Biblioitem number (internal)
-items.barcode	Barcode
-items.dateaccessioned	Date acquired
-items.booksellerid	Source of acquisition
-items.homebranch	Permanent library
-items.price	Price
-items.replacementprice	Replacement price
-items.replacementpricedate	Price effective from
-items.datelastborrowed	Date last checked out
-items.datelastseen	Date last seen
-items.stack	Shelving control number
-items.onloan	Due date
-items.cn_source	Source of classification / shelving scheme
-items.cn_sort	Koha normalized classification for sorting
-items.notforloan	Not for loan
-items.itemlost	Lost status
-items.withdrawn	Withdrawn status
-items.itemcallnumber	Call number
-items.issues	Total checkouts
-items.renewals	Total renewals
-items.reserves	Total holds
-items.restricted	Use restrictions
-items.itemnotes	Public note
-items.holdingbranch	Current library
-items.paidfor
-items.timestamp	Timestamp
-items.location	Shelving location
-items.ccode	Collection code
-items.itype	Koha itemtype
-items.stocknumber	Inventory number
-items.damaged	Damaged status
-items.materials	Materials specified
-items.uri	Uniform Resource Identifier
-items.more_subfields_xml	Additional subfields (XML)
-items.enumchron	Serial enumeraton/chronology
-items.copynumber	Copy number
-statistics.datetime	Statistics date and time
-statistics.branch	Library
-statistics.proccode	Type of procedure
-statistics.value	Value
-statistics.type	Type
-statistics.other
-statistics.usercode	User code
-statistics.itemnumber	Item number
-statistics.itemtype	Itemtype
-statistics.borrowernumber	Borrower number
-biblio.frameworkcode	Framework code
-biblio.author	Author
-biblio.datecreated	Creation date
-biblio.timestamp	Modification date
-biblioitems.biblioitemnumber	Biblioitem number
-biblioitems.biblionumber	Biblio number
-biblioitems.volume	Volume number
-biblioitems.number	Number
-biblioitems.classification	Classification
-biblioitems.itemtype	Biblio-level item type
-biblioitems.isbn	ISBN
-biblioitems.issn	ISSN
-biblioitems.dewey	Dewey/classification
-biblioitems.subclass	Sub classification
-biblioitems.publicationyear	Publication date
-biblioitems.publishercode	Publisher
-biblioitems.volumedate	Volume date
-biblioitems.volumedesc	Volume information
-biblioitems.timestamp	Timestamp
-biblioitems.illus	Illustrator
-biblioitems.pages	Number of pages
-biblioitems.notes	Notes
-biblioitems.size	Size
-biblioitems.place	Place of publication
-biblioitems.lccn	LCCN
-biblioitems.marcxml	MARC blob
-biblioitems.url	URL
+<translation>borrowers.borrowernumber: Borrower number</translation>
+<translation>borrowers.title: Salutation</translation>
+<translation>borrowers.surname: Surname</translation>
+<translation>borrowers.firstname: First name</translation>
+<translation>borrowers.dateofbirth: Date of birth</translation>
+<translation>borrowers.initials: Initials</translation>
+<translation>borrowers.othernames: Other name</translation>
+<translation>borrowers.sex: Gender</translation>
+<translation>borrowers.relationship: Relationship</translation>
+<translation>borrowers.guarantorid: Guarantor borrower number</translation>
+<translation>borrowers.streetnumber: Street number</translation>
+<translation>borrowers.streettype: Street type</translation>
+<translation>borrowers.address: Address</translation>
+<translation>borrowers.address2: Address 2</translation>
+<translation>borrowers.city: City</translation>
+<translation>borrowers.state: State</translation>
+<translation>borrowers.zipcode: Zip/postal code</translation>
+<translation>borrowers.country: Country</translation>
+<translation>borrowers.phone: Primary phone</translation>
+<translation>borrowers.phonepro: Secondary phone</translation>
+<translation>borrowers.mobile: Other phone</translation>
+<translation>borrowers.email: Primary email</translation>
+<translation>borrowers.emailpro: Secondary email</translation>
+<translation>borrowers.fax: Fax</translation>
+<translation>borrowers.B_streetnumber: Alternate address: Street number</translation>
+<translation>borrowers.B_streettype: Alternate address: Street type</translation>
+<translation>borrowers.B_address: Alternate address: Address</translation>
+<translation>borrowers.B_address2: Alternate address: Address 2</translation>
+<translation>borrowers.B_city: Alternate address: City</translation>
+<translation>borrowers.B_state: Alternate address: State</translation>
+<translation>borrowers.B_zipcode: Alternate address: Zip/postal code</translation>
+<translation>borrowers.B_country: Alternate address: Country</translation>
+<translation>borrowers.B_phone: Alternate address: Phone</translation>
+<translation>borrowers.B_email: Alternate address: Email</translation>
+<translation>borrowers.contactnote: Alternate contact: Note</translation>
+<translation>borrowers.altcontactfirstname: Alternate contact: Last name</translation>
+<translation>borrowers.altcontactsurname: Alternate contact: First name</translation>
+<translation>borrowers.altcontactaddress1: Alternate contact: Address</translation>
+<translation>borrowers.altcontactaddress2: Alternate contact: Address 2</translation>
+<translation>borrowers.altcontactaddress3: Alternate contact: City</translation>
+<translation>borrowers.contactname: Alternate contact: Surname</translation>
+<translation>borrowers.contactfirstname: Alternate contact: First name</translation>
+<translation>borrowers.contacttitle: Alternate contact: Title</translation>
+<translation>borrowers.altcontactstate: Alternate contact: State</translation>
+<translation>borrowers.altcontactzipcode: Alternate contact: Zip/postal code</translation>
+<translation>borrowers.altcontactcountry: Alternate contact: Country</translation>
+<translation>borrowers.altcontactphone: Alternate contact: Phone</translation>
+<translation>borrowers.cardnumber: Card number</translation>
+<translation>borrowers.branchcode: Home library</translation>
+<translation>borrowers.categorycode: Category</translation>
+<translation>borrowers.sort1: Sort 1</translation>
+<translation>borrowers.sort2: Sort 2</translation>
+<translation>borrowers.dateenrolled: Registration date</translation>
+<translation>borrowers.dateexpiry: Expiry date</translation>
+<translation>borrowers.opacnote: OPAC note</translation>
+<translation>borrowers.borrowernotes: Circulation note</translation>
+<translation>borrowers.userid: Username</translation>
+<translation>borrowers.password: Password</translation>
+<translation>borrowers.flags: System permissions</translation>
+<translation>borrowers.gonenoaddress: Gone no address flag</translation>
+<translation>borrowers.lost: Lost card flag</translation>
+<translation>borrowers.debarred: Restricted [until] flag</translation>
+<translation>borrowers.debarredcomment: Comment</translation>
+<translation>borrowers.smsalertnumber: Mobile phone number</translation>
+<translation>borrowers.privacy: Privacy settings</translation>
+<translation>items.itemnumber: Item number (internal)</translation>
+<translation>items.biblionumber: Biblio number (internal)</translation>
+<translation>items.biblioitemnumber: Biblioitem number (internal)</translation>
+<translation>items.barcode: Barcode</translation>
+<translation>items.dateaccessioned: Date acquired</translation>
+<translation>items.booksellerid: Source of acquisition</translation>
+<translation>items.homebranch: Permanent library</translation>
+<translation>items.price: Price</translation>
+<translation>items.replacementprice: Replacement price</translation>
+<translation>items.replacementpricedate: Price effective from</translation>
+<translation>items.datelastborrowed: Date last checked out</translation>
+<translation>items.datelastseen: Date last seen</translation>
+<translation>items.stack: Shelving control number</translation>
+<translation>items.onloan: Due date</translation>
+<translation>items.cn_source: Source of classification / shelving scheme</translation>
+<translation>items.cn_sort: Koha normalized classification for sorting</translation>
+<translation>items.notforloan: Not for loan</translation>
+<translation>items.itemlost: Lost status</translation>
+<translation>items.withdrawn: Withdrawn status</translation>
+<translation>items.itemcallnumber: Call number</translation>
+<translation>items.issues: Total checkouts</translation>
+<translation>items.renewals: Total renewals</translation>
+<translation>items.reserves: Total holds</translation>
+<translation>items.restricted: Use restrictions</translation>
+<translation>items.itemnotes: Public note</translation>
+<translation>items.holdingbranch: Current library</translation>
+<translation>items.paidfor</translation>
+<translation>items.timestamp: Timestamp</translation>
+<translation>items.location: Shelving location</translation>
+<translation>items.ccode: Collection code</translation>
+<translation>items.itype: Koha itemtype</translation>
+<translation>items.stocknumber: Inventory number</translation>
+<translation>items.damaged: Damaged status</translation>
+<translation>items.materials: Materials specified</translation>
+<translation>items.uri: Uniform Resource Identifier</translation>
+<translation>items.more_subfields_xml: Additional subfields (XML)</translation>
+<translation>items.enumchron: Serial enumeraton/chronology</translation>
+<translation>items.copynumber: Copy number</translation>
+<translation>statistics.datetime: Statistics date and time</translation>
+<translation>statistics.branch: Library</translation>
+<translation>statistics.proccode: Type of procedure</translation>
+<translation>statistics.value: Value</translation>
+<translation>statistics.type: Type</translation>
+<translation>statistics.other</translation>
+<translation>statistics.usercode: User code</translation>
+<translation>statistics.itemnumber: Item number</translation>
+<translation>statistics.itemtype: Itemtype</translation>
+<translation>statistics.borrowernumber: Borrower number</translation>
+<translation>biblio.frameworkcode: Framework code</translation>
+<translation>biblio.author: Author</translation>
+<translation>biblio.datecreated: Creation date</translation>
+<translation>biblio.timestamp: Modification date</translation>
+<translation>biblioitems.biblioitemnumber: Biblioitem number</translation>
+<translation>biblioitems.biblionumber: Biblio number</translation>
+<translation>biblioitems.volume: Volume number</translation>
+<translation>biblioitems.number: Number</translation>
+<translation>biblioitems.classification: Classification</translation>
+<translation>biblioitems.itemtype: Biblio-level item type</translation>
+<translation>biblioitems.isbn: ISBN</translation>
+<translation>biblioitems.issn: ISSN</translation>
+<translation>biblioitems.dewey: Dewey/classification</translation>
+<translation>biblioitems.subclass: Sub classification</translation>
+<translation>biblioitems.publicationyear: Publication date</translation>
+<translation>biblioitems.publishercode: Publisher</translation>
+<translation>biblioitems.volumedate: Volume date</translation>
+<translation>biblioitems.volumedesc: Volume information</translation>
+<translation>biblioitems.timestamp: Timestamp</translation>
+<translation>biblioitems.illus: Illustrator</translation>
+<translation>biblioitems.pages: Number of pages</translation>
+<translation>biblioitems.notes: Notes</translation>
+<translation>biblioitems.size: Size</translation>
+<translation>biblioitems.place: Place of publication</translation>
+<translation>biblioitems.lccn: LCCN</translation>
+<translation>biblioitems.marcxml: MARC blob</translation>
+<translation>biblioitems.url: URL</translation>
diff --git a/misc/translator/tmpl_process3.pl b/misc/translator/tmpl_process3.pl
index e5df69a..e64f935 100755
--- a/misc/translator/tmpl_process3.pl
+++ b/misc/translator/tmpl_process3.pl
@@ -242,7 +242,7 @@ usage_error('You must at least specify input and string list filenames.')
     if !$in_dir || !defined $str_file;
 
 # Type match defaults to *.tt plus *.inc if not specified
-$type = "tt|inc|xsl|xml" if !defined($type);
+$type = "tt|inc|xsl|xml|def" if !defined($type);
 
 # Check the inputs for being directories
 usage_error("$in_dir: Input must be a directory.\n"
-- 
1.7.10.4