From fe60de3622478b5c3c4647b3ab66d60e7f0e37d5 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 14 Dec 2021 17:27:37 +0100 Subject: [PATCH] Bug 29695: Add new module Koha::Database::Columns This module will contain new strings and make them translatable using Koha::I18N. We will need to improve this module to prevent the dozens of __ calls each time we retrieve the column list. We could either use memcached or add a method to only retrieve columns for a given table. --- Koha/Database/Columns.pm | 212 +++++++++++++++++++++++ t/Koha/Database/Columns.t | 34 ++++ t/Koha/I18N/po/xx_XX/LC_MESSAGES/Koha.mo | Bin 1370 -> 1385 bytes 3 files changed, 246 insertions(+) create mode 100644 Koha/Database/Columns.pm create mode 100755 t/Koha/Database/Columns.t diff --git a/Koha/Database/Columns.pm b/Koha/Database/Columns.pm new file mode 100644 index 00000000000..521b07a2cc4 --- /dev/null +++ b/Koha/Database/Columns.pm @@ -0,0 +1,212 @@ +package Koha::Database::Columns; + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +=head1 NAME + +Koha::Database::Columns + +=head1 SYNOPSIS + + use Koha::Database::Columns; + +=head1 FUNCTIONS + +=cut + +use Modern::Perl; +use Koha::I18N qw( __ ); + +sub columns { + return { + borrowers => { + "borrowernumber" => __("Borrower number"), + "title" => __("Salutation"), + "surname" => __("Surname"), + "firstname" => __("First name"), + "dateofbirth" => __("Date of birth"), + "initials" => __("Initials"), + "othernames" => __("Other name"), + "sex" => __("Gender"), + "relationship" => __("Relationship"), + "streetnumber" => __("Street number"), + "streettype" => __("Street type"), + "address" => __("Address"), + "address2" => __("Address 2"), + "city" => __("City"), + "state" => __("State"), + "zipcode" => __("ZIP/Postal code"), + "country" => __("Country"), + "phone" => __("Primary phone"), + "phonepro" => __("Secondary phone"), + "mobile" => __("Other phone"), + "email" => __("Primary email"), + "emailpro" => __("Secondary email"), + "fax" => __("Fax"), + "B_streetnumber" => __("Alternate address: Street number"), + "B_streettype" => __("Alternate address: Street type"), + "B_address" => __("Alternate address: Address"), + "B_address2" => __("Alternate address: Address 2"), + "B_city" => __("Alternate address: City"), + "B_state" => __("Alternate address: State"), + "B_zipcode" => __("Alternate address: ZIP/Postal code"), + "B_country" => __("Alternate address: Country"), + "B_phone" => __("Alternate address: Phone"), + "B_email" => __("Alternate address: Email"), + "contactnote" => __("Alternate contact: Note"), + "altcontactfirstname" => __("Alternate contact: First name"), + "altcontactsurname" => __("Alternate contact: Surname"), + "altcontactaddress1" => __("Alternate contact: Address"), + "altcontactaddress2" => __("Alternate contact: Address 2"), + "altcontactaddress3" => __("Alternate contact: City"), + "contactname" => __("Alternate contact: Surname"), + "contactfirstname" => __("Alternate contact: First name"), + "contacttitle" => __("Alternate contact: Title"), + "altcontactstate" => __("Alternate contact: State"), + "altcontactzipcode" => __("Alternate contact: ZIP/Postal code"), + "altcontactcountry" => __("Alternate contact: Country"), + "altcontactphone" => __("Alternate contact: Phone"), + "cardnumber" => __("Card number"), + "branchcode" => __("Home library"), + "categorycode" => __("Patron category"), + "sort1" => __("Sort 1"), + "sort2" => __("Sort 2"), + "dateenrolled" => __("Registration date"), + "dateexpiry" => __("Expiry date"), + "opacnote" => __("OPAC note"), + "borrowernotes" => __("Circulation note"), + "userid" => __("Username"), + "password" => __("Password"), + "flags" => __("System permissions"), + "gonenoaddress" => __("Gone no address flag"), + "lost" => __("Lost card flag"), + "debarred" => __("Restricted [until] flag"), + "debarredcomment" => __("Comment"), + "smsalertnumber" => __("Mobile phone number"), + "privacy" => __("Privacy settings"), + }, + items => { + "itemnumber" => __("Item number (internal)"), + "biblionumber" => __("Biblio number (internal)"), + "biblioitemnumber" => __("Biblioitem number (internal)"), + "barcode" => __("Barcode"), + "dateaccessioned" => __("Date acquired"), + "booksellerid" => __("Source of acquisition"), + "homebranch" => __("Permanent library"), + "price" => __("Price"), + "replacementprice" => __("Replacement price"), + "replacementpricedate" => __("Price effective from"), + "datelastborrowed" => __("Date last checked out"), + "datelastseen" => __("Date last seen"), + "stack" => __("Shelving control number"), + "onloan" => __("Due date"), + "cn_source" => __("Source of classification / shelving scheme"), + "cn_sort" => __("Koha normalized classification for sorting"), + "notforloan" => __("Not for loan"), + "itemlost" => __("Lost status"), + "itemlost_on" => __("Lost on"), + "withdrawn" => __("Withdrawn status"), + "withdrawn_on" => __("Withdrawn on"), + "itemcallnumber" => __("Call number"), + "issues" => __("Total checkouts"), + "renewals" => __("Total renewals"), + "reserves" => __("Total holds"), + "restricted" => __("Use restrictions"), + "itemnotes" => __("Public note"), + "itemnotes_nonpublic" => __("Internal note"), + "holdingbranch" => __("Current library"), + "timestamp" => __("Timestamp"), + "location" => __("Shelving location"), + "permanent_location" => __("Permanent shelving location"), + "ccode" => __("Collection code"), + "itype" => __("Koha itemtype"), + "stocknumber" => __("Inventory number"), + "damaged" => __("Damaged status"), + "damaged_on" => __("Damaged on"), + "materials" => __("Materials specified"), + "uri" => __("Uniform Resource Identifier"), + "more_subfields_xml" => __("Additional subfields (XML)"), + "enumchron" => __("Serial enumeraton/chronology"), + "copynumber" => __("Copy number"), + "new_status" => __("New status"), + }, + statistics => { + "datetime" => __("Statistics date and time"), + "branch" => __("Library"), + "value" => __("Value"), + "type" => __("Type"), + "other" => __(""), + "itemnumber" => __("Item number"), + "itemtype" => __("Itemtype"), + "borrowernumber" => __("Borrower number"), + }, + biblio => { + "frameworkcode" => __("Framework code"), + "author" => __("Author"), + "datecreated" => __("Creation date"), + "timestamp" => __("Modification date"), + }, + biblioitems => { + "biblioitemnumber" => __("Biblioitem number"), + "biblionumber" => __("Biblio number"), + "volume" => __("Volume number"), + "number" => __("Number"), + "classification" => __("Classification"), + "itemtype" => __("Biblio-level item type"), + "isbn" => __("ISBN"), + "issn" => __("ISSN"), + "dewey" => __("Dewey/classification"), + "subclass" => __("Sub classification"), + "publicationyear" => __("Publication date"), + "publishercode" => __("Publisher"), + "volumedate" => __("Volume date"), + "volumedesc" => __("Volume information"), + "timestamp" => __("Timestamp"), + "illus" => __("Illustrations"), + "pages" => __("Number of pages"), + "notes" => __("Notes"), + "size" => __("Size"), + "place" => __("Place of publication"), + "lccn" => __("LCCN"), + "agerestriction" => __("Age restriction"), + "url" => __("URL"), + "title" => __("Title"), + }, + subscription => { + "startdate" => __("Start date"), + "enddate" => __("End date"), + "periodicity" => __("Periodicity"), + "callnumber" => __("Call number"), + "location" => __("Location"), + "branchcode" => __("Library"), + }, + suggestions=> { + "author" => __("author"), + "copyrightdate" => __("copyrightdate"), + "isbn" => __("isbn"), + "publishercode" => __("publishercode"), + "collectiontitle" => __("collectiontitle"), + "place" => __("place"), + "quantity" => __("quantity"), + "itemtype" => __("itemtype"), + "branchcode" => __("branchcode"), + "patronreason" => __("patronreason"), + "note" => __("note"), + } + }; +} + +1; diff --git a/t/Koha/Database/Columns.t b/t/Koha/Database/Columns.t new file mode 100755 index 00000000000..ff9191c678a --- /dev/null +++ b/t/Koha/Database/Columns.t @@ -0,0 +1,34 @@ +#!/usr/bin/perl + +# This file is part of Koha +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use Test::More tests => 1; +use Test::MockModule; +use FindBin qw($Bin); +use Encode; + +use Koha::Database::Columns; + +my $koha_i18n = Test::MockModule->new('Koha::I18N'); +$koha_i18n->mock('_base_directory', sub { "$Bin/../I18N/po" }); + +my $c4_languages = Test::MockModule->new('C4::Languages'); +$c4_languages->mock('getlanguage', sub { 'xx-XX' }); + +my $columns = Koha::Database::Columns->columns; + +is( $columns->{borrowers}->{opacnote}, decode_utf8('OPAC note ✔ ❤ ★') ); diff --git a/t/Koha/I18N/po/xx_XX/LC_MESSAGES/Koha.mo b/t/Koha/I18N/po/xx_XX/LC_MESSAGES/Koha.mo index 99be22f268b3e872ac10b2d2e3e538b1fd8293d6..ea84bd6c8c1b17cf6ba22abb335bc3eaffabe61f 100644 GIT binary patch delta 395 zcmV;60d)S_3h4@e-Vy|r000004gdfE8~^|Si~s-t6951J`~Uy|00000NC5x<3;+NC zNdW)=2><{9RsjG24*&oFU;zLC7XSbNZ~*`S9RL6Thyefq3;+NCrU3u|6#xJLvjG4A z6#xJL$pHWW6#xJL-vIys8vp;M1&00000FaZDn3;+NC zF#!Mo4*&oFJ^=s#7XSbNP5}S_9RL6TW&r>I3;+NCgaH5m6#xJLkpTbz6#xJLrvU%} z6#xJLy#W9K8vpV>VL}7GgIv_GIF*hwRG%YbO YATcyLFf%JKGB7Z+X#za~v%CYX0a17;`Tzg` -- 2.25.1