From 8d4d12544eaefa6fd62619440e74dbef803508bd Mon Sep 17 00:00:00 2001
From: Mark Tompsett <mtompset@hotmail.com>
Date: Wed, 28 Mar 2018 02:47:18 +0000
Subject: [PATCH] Bug 20482: Correct Terminology codes to Bibliographic ones

"RELATIONSHIP TO ISO 639-2
ISO 639-2 (Codes for the representation of names of
languages-- Part 2: alpha-3 code) was based on the MARC
Code List for Languages and published in 1998. In the 22
cases where the ISO 639-2 list has two alternative codes,
the bibliographic code is the same as the MARC code."
(http://www.loc.gov/marc/languages/introduction.pdf)

This leads me to believe that eus, mri, and sqi are
incorrect. The slk code was corrected on an earlier bug.

TEST PLAN
----------
Apply patch
Do a database upgrade
-- Are eus, mri, and sqi fixed?
reset_all
-- Are eus, mri, and sqi never there in the first place?
koha qa test tools only check perl code.

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
---
 .../data/mysql/atomicupdate/bug_20482_update_language_codes.sql     | 3 +++
 installer/data/mysql/mandatory/subtag_registry.sql                  | 6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)
 create mode 100644 installer/data/mysql/atomicupdate/bug_20482_update_language_codes.sql

diff --git a/installer/data/mysql/atomicupdate/bug_20482_update_language_codes.sql b/installer/data/mysql/atomicupdate/bug_20482_update_language_codes.sql
new file mode 100644
index 0000000..a06c8fe
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_20482_update_language_codes.sql
@@ -0,0 +1,3 @@
+UPDATE language_rfc4646_to_iso639 SET iso639_2_code = 'baq' WHERE iso639_2_code = 'eus' AND rfc4646_subtag = 'eu';
+UPDATE language_rfc4646_to_iso639 SET iso639_2_code = 'mri' WHERE iso639_2_code = 'mri' AND rfc4646_subtag = 'mi';
+UPDATE language_rfc4646_to_iso639 SET iso639_2_code = 'alb' WHERE iso639_2_code = 'sqi' AND rfc4646_subtag = 'sq';
diff --git a/installer/data/mysql/mandatory/subtag_registry.sql b/installer/data/mysql/mandatory/subtag_registry.sql
index ebcdedc..4a7f0a1 100755
--- a/installer/data/mysql/mandatory/subtag_registry.sql
+++ b/installer/data/mysql/mandatory/subtag_registry.sql
@@ -281,7 +281,7 @@ INSERT INTO language_subtag_registry( subtag, type, description, added)
 VALUES ( 'eu', 'language', 'Basque','2014-10-30');
 
 INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code)
-VALUES ( 'eu','eus');
+VALUES ( 'eu','baq');
 
 INSERT INTO language_descriptions(subtag, type, lang, description)
 VALUES ( 'eu', 'language', 'eu', 'Euskera');
@@ -669,7 +669,7 @@ INSERT INTO language_subtag_registry( subtag, type, description, added)
 VALUES ( 'mi', 'language', 'Maori','2014-10-30');
 
 INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code)
-VALUES ( 'mi','mri');
+VALUES ( 'mi','mao');
 
 INSERT INTO language_descriptions(subtag, type, lang, description)
 VALUES ( 'mi', 'language', 'mi', 'Te Reo Māori');
@@ -948,7 +948,7 @@ INSERT INTO language_subtag_registry( subtag, type, description, added)
 VALUES ( 'sq', 'language', 'Albanian','2014-10-30');
 
 INSERT INTO language_rfc4646_to_iso639(rfc4646_subtag,iso639_2_code)
-VALUES ( 'sq','sqi');
+VALUES ( 'sq','alb');
 
 INSERT INTO language_descriptions(subtag, type, lang, description)
 VALUES ( 'sq', 'language', 'sq', 'Shqip');
-- 
2.1.4