Koha-clms/C4
Matthias Meusburger 4dd5b2a891
Bug 38142: Choose language to report from authority to bibliographic record.
Currently, when reporting authority field to the bibliographic records,
the merge function uses the first matching authority field.

However, authorities can provide multiple versions of the same field, with
different languages, identified by a code in the $7 field.

French reference for languages codes for example, but any code system could be
used:
https://documentation.abes.fr/sudoc/formats/unmb/DonneesCodees/CodesZone104.htm#$d

This patch introduces the LanguageToReportOnMerge system preference, which
allows to specify a language code.

When set, if there is an authority field with the given language code, it will
be used to report to the bibliographic record.

If the system preference is not set, or there is no matching field, the default
behavior will apply: the first field will be used.

The $7 in the authority field can be in a short or long form:

 - the short form is 2 characters long. Example: ba
 - the long form is 8 characters long, with the short form in position 5 and 6
   (starting from 1). Example: ba0yba0y

Test plan:
----------

1) Edit the 'Personal Name' authority type framework to make the 100 field
repeatable

2) Add an authority with several languages, like this (the order is important):

100    _7ba0yda0y
       _a伊東豊雄
100    _7ba0yba0y
       _aItō

3) Add a bibliographic record linked to that authority.
(Click on the "tag editor" icon next to the 100$a field in the bibliographic record to
 search for the authority, then Search main heading ($a only): contains Itō)

Note that you can choose which version you want when searching for the
authority, under the "Get it!" column

For this example, choose the latin version: Itō

You should now have this in your bibliographic record:
100    _aItō
       _92646

4) Edit the authority, you don't have to change anything, just edit and save.
Note that your bibliographic record now looks like this:

100    _7ba0yda0y
       _a伊東豊雄
       _92646

The first 100 field of the authority has been reported back to the bibliographic
record, regardless of what you chose when selecting the authority.

5) Apply the patch, set the LanguageToReportOnMerge system preference to: 'ba'

6) Edit the authority again, and check that your bibliographic record now looks
like this, according to the system preference:

100    _7ba0yba0y
       _aItō
       _92646

7) Edit the authority again, but set the $7 of the latin field to its short
form:

100    _7ba0yda0y
       _a伊東豊雄
100    _7ba
       _aItō

8) Check that the bibliographic record still has the latin field reported:

100    _7ba
       _aItō
       _92646

9) prove koha/t/db_dependent/Authority/Merge.t

10) Sign-off :)

Sponsored-by: ENSA

Works smoothly, both with UNIMARC/MARC21
Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2025-04-25 08:46:38 +02:00
..
AuthoritiesMarc Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Barcodes Bug 39367: Manual changes 2025-04-23 09:35:15 +02:00
ClassSortRoutine Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
ClassSplitRoutine Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Creators Bug 39367: Manual changes 2025-04-23 09:35:15 +02:00
External Bug 39367: Manual changes 2025-04-23 09:35:15 +02:00
Form Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Heading Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
ILSDI Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Installer Bug 39367: Manual changes 2025-04-23 09:35:15 +02:00
Labels Bug 39367: Manual changes 2025-04-23 09:35:15 +02:00
Linker Bug 39367: Manual changes 2025-04-23 09:35:15 +02:00
Members Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
OAI Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Output Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Patroncards Bug 39367: Manual changes 2025-04-23 09:35:15 +02:00
Reports Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
SIP Bug 39367: Replace tabs with spaces in POD 2025-04-23 09:35:17 +02:00
Search Bug 39367: Manual changes 2025-04-23 09:35:15 +02:00
Serials Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Utils/DataTables Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Accounts.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Acquisition.pm Bug 39367: Manual changes 2025-04-23 09:35:15 +02:00
Auth.pm Bug 39367: Manual changes 2025-04-23 09:35:15 +02:00
Auth_cas_servers.yaml.sample
…
Auth_with_cas.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Auth_with_ldap.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Auth_with_shibboleth.pm Bug 39367: Manual changes 2025-04-23 09:35:15 +02:00
AuthoritiesMarc.pm Bug 38142: Choose language to report from authority to bibliographic record. 2025-04-25 08:46:38 +02:00
Barcodes.pm Bug 39367: Manual changes 2025-04-23 09:35:15 +02:00
Biblio.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Breeding.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Budgets.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Calendar.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Charset.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Circulation.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
ClassSortRoutine.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
ClassSource.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
ClassSplitRoutine.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Context.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Contract.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
CourseReserves.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Creators.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
HTML5Media.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Heading.pm Bug 38729: Linker should consider diacritics 2025-04-14 08:50:57 +02:00
HoldsQueue.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
ImportBatch.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
ImportExportFramework.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
InstallAuth.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Installer.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
ItemCirculationAlertPreference.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Items.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Koha.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Labels.pm Bug 21395: Make perlcritic happy 2020-06-29 12:37:02 +02:00
Languages.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Letters.pm Bug 37989: Add template toolkit to problem_report notice 2025-02-26 13:45:47 +01:00
Linker.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Log.pm Bug 37944: Log object delete as JSON diff, implement for items 2024-10-30 11:57:25 +01:00
MarcModificationTemplates.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Matcher.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Members.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Message.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Output.pm Bug 39367: Manual changes 2025-04-23 09:35:15 +02:00
Overdues.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Patroncards.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Record.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Reports.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Reserves.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Ris.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
RotatingCollections.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
SMS.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Scheduler.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Scrubber.pm Bug 39367: Replace tabs with spaces in POD 2025-04-23 09:35:17 +02:00
Search.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Serials.pm Bug 37171: Add serial note to serial claims screen 2025-03-19 11:55:31 +01:00
Service.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
ShelfBrowser.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
SocialData.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Stats.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Suggestions.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
TTParser.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Tags.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
Templates.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
TmplToken.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
TmplTokenType.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
UsageStats.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
XISBN.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00
XSLT.pm Bug 39367: Automatic changes 2025-04-23 09:35:14 +02:00