forked from zotero/translators
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrimo.js
822 lines (778 loc) · 22.6 KB
/
Primo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
{
"translatorID":"1300cd65-d23a-4bbf-93e5-a3c9e00d1066",
"translatorType":4,
"label":"Primo",
"creator":"Matt Burton, Avram Lyon, Etienne Cavalié",
"target":"/primo_library/",
"minVersion":"2.0",
"maxVersion":"",
"priority":100,
"inRepository":true,
"lastUpdated":"2010-06-08 07:15:00"
}
/*
Supports Primo 2:
Université de Nice, France (http://catalogue.unice.fr/)
Supports Primo 3
Boston College (http://www.bc.edu/supersleuth),
Oxford Libraries (http://solo.ouls.ox.ac.uk/)
*/
function detectWeb(doc, url) {
var namespace = doc.documentElement.namespaceURI;
var nsResolver = namespace ? function(prefix) {
if (prefix == 'x') return namespace; else return null;
} : null;
if (doc.evaluate('//span[@class="results_corner EXLResultsTitleCorner"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext() ) {
return 'multiple';
}
else if (doc.evaluate('//div[@class="EXLContent EXLBriefDisplay"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext() ) {
return 'multiple';
}
else if (doc.evaluate('//div[@class="results2 EXLFullResultsHeader"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext() ) {
return 'book';
}
else if (doc.evaluate('//div[@class="EXLContent EXLFullDisplay"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext() ) {
return 'book';
}
}
// There is code for handling RIS, but let's stick with PNX for now.
function doWeb(doc, url) {
var namespace = doc.documentElement.namespaceURI;
var nsResolver = namespace ? function(prefix) {
if (prefix == 'x') return namespace; else return null;
} : null;
var links = new Array();
if (detectWeb(doc,url) == 'multiple') {
var items = new Object();
var linkIterator = "";
var titleIterator = "";
if (doc.evaluate('//h2[contains(@class, "EXLResultTitle")]/a/@href', doc, nsResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotLength == 0)
{
// Primo v2
linkIterator = doc.evaluate('//div[contains(@class, "title")]/a/@href', doc, nsResolver, XPathResult.ANY_TYPE, null);
titleIterator = doc.evaluate('//div[contains(@class, "title")]/a/span', doc, nsResolver, XPathResult.ANY_TYPE, null);
}
else
{
// Primo v3
linkIterator = doc.evaluate('//h2[contains(@class, "EXLResultTitle")]/a/@href', doc, nsResolver, XPathResult.ANY_TYPE, null);
titleIterator = doc.evaluate('//h2[contains(@class, "EXLResultTitle")]/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
}
// try/catch for the case when there are no search results, let doc.evealuate fail quietly
try {
while (link = linkIterator.iterateNext(), title = titleIterator.iterateNext()) {
// create an array containing the links and add '&showPnx=true' to the end
var xmlLink = Zotero.Utilities.trimInternal(link.textContent)+'&showPnx=true';
Zotero.debug(xmlLink);
var title = Zotero.Utilities.trimInternal(title.textContent);
items[xmlLink] = title;
}
items = Zotero.selectItems(items);
for(var link in items) {
links.push(link);
}
} catch(e) {
Zotero.debug("Search results contained zero items. "+e);
return;
}
} else {
links.push(url+'&showPnx=true');
}
Zotero.Utilities.HTTP.doGet(links, function(text) {
text = text.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, ""); //because E4X is full of FAIL
var xmldoc = new XML(text);
if (xmldoc.display.type.toString() == 'book') {
var item = new Zotero.Item("book");
} else if (xmldoc.display.type.toString() == 'audio') {
var item = new Zotero.Item("audioRecording");
} else if (xmldoc.display.type.toString() == 'video') {
var item = new Zotero.Item("videoRecording");
} else {
var item = new Zotero.Item("document");
}
item.title = xmldoc.display.title.toString();
var creators = xmldoc.display.creator.toString().replace(/\d{4}-(\d{4})?/, '').split("; ");
var contributors = xmldoc.display.contributor.toString().replace(/\d{4}-(\d{4})?/, '').split("; ");
if (!creators[0]) { // <contributor> not available using <contributor> as author instead
creators = contributors;
contributors = null;
}
for (creator in creators) {
if (creators[creator]) {
item.creators.push(Zotero.Utilities.cleanAuthor(creators[creator], "author"));
}
}
for (contributor in contributors) {
if (contributors[contributor]) {
item.creators.push(Zotero.Utilities.cleanAuthor(contributors[contributor], "contributor"));
}
}
var pubplace = xmldoc.display.publisher.toString().split(" : ");
if (pubplace) {
item.place = pubplace[0];
item.publisher = pubplace[1];
}
var date = xmldoc.display.creationdate.toString();
if (date) item.date = date.match(/\d+/)[0];
var language = xmldoc.display.language.toString();
// We really hope that Primo always uses ISO 639-2
// This looks odd, but it just means that we're using the verbatim
// content if it isn't in our ISO 639-2 hash.
if (language)
if(!(item.language = iso6392(language)))
item.language = language;
var pages = xmldoc.display.format.toString().match(/(\d+)\sp\./);
if (pages) item.pages = pages[1];
// The identifier field is supposed to have standardized format, but
// the super-tolerant idCheck should be better than a regex.
// (although note that it will reject invalid ISBNs)
var locators = idCheck(xmldoc.display.identifier.toString());
if (locators.isbn10) item.ISBN = locators.isbn10;
if (locators.isbn13) item.ISBN = locators.isbn13;
if (locators.issn) item.ISSN = locators.issn;
var edition = xmldoc.display.edition.toString();
if (edition) item.edition = edition;
for each (subject in xmldoc.search.subject) {
item.tags.push(subject.toString());
}
// does callNumber get stored anywhere else in the xml?
item.callNumber = xmldoc.enrichment.classificationlcc[0];
item.complete();
}, function() {Zotero.done();});
Zotero.wait();
}
/* The next two functions are logic that could be bundled away into the translator toolkit. */
// Implementation of ISBN and ISSN check-digit verification
// Based on ISBN Users' Manual (http://www.isbn.org/standards/home/isbn/international/html/usm4.htm)
// and the Wikipedia treatment of ISBN (http://en.wikipedia.org/wiki/International_Standard_Book_Number)
// and the Wikipedia treatment of ISSN (http://en.wikipedia.org/wiki/International_Standard_Serial_Number)
// This will also check ISMN validity, although it does not distinguish from their
// neighbors in namespace, ISBN-13. It does not handle pre-2008 M-prefixed ISMNs; see
// http://en.wikipedia.org/wiki/International_Standard_Music_Number
// This does not validate multiple identifiers in one field,
// but it will gracefully ignore all non-number detritus,
// such as extraneous hyphens, spaces, and comments.
// It currently maintains hyphens in non-initial and non-final position,
// discarding consecutive ones beyond the first as well.
// It also adds the customary hyphen to valid ISSNs.
// Takes the first 8 valid digits and tries to read an ISSN,
// takes the first 10 valid digits and tries to read an ISBN 10,
// and takes the first 13 valid digits to try to read an ISBN 13
// Returns an object with three attributes:
// "issn"
// "isbn10"
// "isbn13"
// Each will be set to a valid identifier if found, and otherwise be a
// boolean false.
// There could conceivably be a valid ISBN-13 with an ISBN-10
// substring; this should probably be interpreted as the latter, but it is a
// client UI issue.
idCheck = function(isbn) {
// For ISBN 10, multiple by these coefficients, take the sum mod 11
// and subtract from 11
var isbn10 = [10, 9, 8, 7, 6, 5, 4, 3, 2];
// For ISBN 13, multiple by these coefficients, take the sum mod 10
// and subtract from 10
var isbn13 = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3];
// For ISSN, multiply by these coefficients, take the sum mod 11
// and subtract from 11
var issn = [8, 7, 6, 5, 4, 3, 2];
// We make a single pass through the provided string, interpreting the
// first 10 valid characters as an ISBN-10, and the first 13 as an
// ISBN-13. We then return an array of booleans and valid detected
// ISBNs.
var j = 0;
var sum8 = 0;
var num8 = "";
var sum10 = 0;
var num10 = "";
var sum13 = 0;
var num13 = "";
var chars = [];
for (var i=0; i < isbn.length; i++) {
if (isbn.charAt(i) == " ") {
// Since the space character evaluates as a number,
// it is a special case.
} else if (j > 0 && isbn.charAt(i) == "-" && isbn.charAt(i-1) != "-") {
// Preserve hyphens, except in initial and final position
// Also discard consecutive hyphens
if(j < 7) num8 += "-";
if(j < 10) num10 += "-";
if(j < 13) num13 += "-";
} else if (j < 7 && ((isbn.charAt(i) - 0) == isbn.charAt(i))) {
sum8 += isbn.charAt(i) * issn[j];
sum10 += isbn.charAt(i) * isbn10[j];
sum13 += isbn.charAt(i) * isbn13[j];
num8 += isbn.charAt(i);
num10 += isbn.charAt(i);
num13 += isbn.charAt(i);
j++;
} else if (j == 7 &&
(isbn.charAt(i) == "X" || isbn.charAt(i) == "x" ||
((isbn.charAt(i) - 0) == isbn.charAt(i)))) {
// In ISSN, an X represents the check digit "10".
if(isbn.charAt(i) == "X" || isbn.charAt(i) == "x") {
var check8 = 10;
num8 += "X";
} else {
var check8 = isbn.charAt(i);
sum10 += isbn.charAt(i) * isbn10[j];
sum13 += isbn.charAt(i) * isbn13[j];
num8 += isbn.charAt(i);
num10 += isbn.charAt(i);
num13 += isbn.charAt(i);
j++;
}
} else if (j < 9 && ((isbn.charAt(i) - 0) == isbn.charAt(i))) {
sum10 += isbn.charAt(i) * isbn10[j];
sum13 += isbn.charAt(i) * isbn13[j];
num10 += isbn.charAt(i);
num13 += isbn.charAt(i);
j++;
} else if (j == 9 &&
(isbn.charAt(i) == "X" || isbn.charAt(i) == "x" ||
((isbn.charAt(i) - 0) == isbn.charAt(i)))) {
// In ISBN-10, an X represents the check digit "10".
if(isbn.charAt(i) == "X" || isbn.charAt(i) == "x") {
var check10 = 10;
num10 += "X";
} else {
var check10 = isbn.charAt(i);
sum13 += isbn.charAt(i) * isbn13[j];
num10 += isbn.charAt(i);
num13 += isbn.charAt(i);
j++;
}
} else if(j < 12 && ((isbn.charAt(i) - 0) == isbn.charAt(i))) {
sum13 += isbn.charAt(i) * isbn13[j];
num13 += isbn.charAt(i);
j++;
} else if (j == 12 && ((isbn.charAt(i) - 0) == isbn.charAt(i))) {
var check13 = isbn.charAt(i);
num13 += isbn.charAt(i);
}
}
var valid8 = ((11 - sum8 % 11) % 11) == check8;
var valid10 = ((11 - sum10 % 11) % 11) == check10;
var valid13 = (10 - sum13 % 10 == check13);
var matches = false;
// Since ISSNs have a standard hyphen placement, we can add a hyphen
if (valid8 && (matches = num8.match(/([0-9]{4})([0-9]{3}[0-9Xx])/))) {
num8 = matches[1] + '-' + matches[2];
}
if(!valid8) {num8 = false};
if(!valid10) {num10 = false};
if(!valid13) {num13 = false};
return {"isbn10" : num10, "isbn13" : num13, "issn" : num8};
}
// This function should be replaced by a lookup from the multilingual machinery in multilingual builds of Zotero
// Gives name for three-letter code
function iso6392(code) {
MAP_ISO6391_ISO6392 = {'aar' : 'Afar',
'abk' : 'Abkhazian',
'ace' : 'Achinese',
'ach' : 'Acoli',
'ada' : 'Adangme',
'ady' : 'Adyghe; Adygei',
'afa' : 'Afro-Asiatic languages',
'afh' : 'Afrihili',
'afr' : 'Afrikaans',
'ain' : 'Ainu',
'aka' : 'Akan',
'akk' : 'Akkadian',
'alb' : 'Albanian',
'ale' : 'Aleut',
'alg' : 'Algonquian languages',
'alt' : 'Southern Altai',
'amh' : 'Amharic',
'ang' : 'English, Old (ca.450-1100)',
'anp' : 'Angika',
'apa' : 'Apache languages',
'ara' : 'Arabic',
'arc' : 'Official Aramaic (700-300 BCE); Imperial Aramaic (700-300 BCE)',
'arg' : 'Aragonese',
'arm' : 'Armenian',
'arn' : 'Mapudungun; Mapuche',
'arp' : 'Arapaho',
'art' : 'Artificial languages',
'arw' : 'Arawak',
'asm' : 'Assamese',
'ast' : 'Asturian; Bable; Leonese; Asturleonese',
'ath' : 'Athapascan languages',
'aus' : 'Australian languages',
'ava' : 'Avaric',
'ave' : 'Avestan',
'awa' : 'Awadhi',
'aym' : 'Aymara',
'aze' : 'Azerbaijani',
'bad' : 'Banda languages',
'bai' : 'Bamileke languages',
'bak' : 'Bashkir',
'bal' : 'Baluchi',
'bam' : 'Bambara',
'ban' : 'Balinese',
'baq' : 'Basque',
'bas' : 'Basa',
'bat' : 'Baltic languages',
'bej' : 'Beja; Bedawiyet',
'bel' : 'Belarusian',
'bem' : 'Bemba',
'ben' : 'Bengali',
'ber' : 'Berber languages',
'bho' : 'Bhojpuri',
'bih' : 'Bihari languages',
'bik' : 'Bikol',
'bin' : 'Bini; Edo',
'bis' : 'Bislama',
'bla' : 'Siksika',
'bnt' : 'Bantu languages',
'tib' : 'Tibetan',
'bos' : 'Bosnian',
'bra' : 'Braj',
'bre' : 'Breton',
'btk' : 'Batak languages',
'bua' : 'Buriat',
'bug' : 'Buginese',
'bul' : 'Bulgarian',
'bur' : 'Burmese',
'byn' : 'Blin; Bilin',
'cad' : 'Caddo',
'cai' : 'Central American Indian languages',
'car' : 'Galibi Carib',
'cat' : 'Catalan; Valencian',
'cau' : 'Caucasian languages',
'ceb' : 'Cebuano',
'cel' : 'Celtic languages',
'cze' : 'Czech',
'cha' : 'Chamorro',
'chb' : 'Chibcha',
'che' : 'Chechen',
'chg' : 'Chagatai',
'chi' : 'Chinese',
'chk' : 'Chuukese',
'chm' : 'Mari',
'chn' : 'Chinook jargon',
'cho' : 'Choctaw',
'chp' : 'Chipewyan; Dene Suline',
'chr' : 'Cherokee',
'chu' : 'Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic',
'chv' : 'Chuvash',
'chy' : 'Cheyenne',
'cmc' : 'Chamic languages',
'cop' : 'Coptic',
'cor' : 'Cornish',
'cos' : 'Corsican',
'cpe' : 'Creoles and pidgins, English based',
'cpf' : 'Creoles and pidgins, French-based',
'cpp' : 'Creoles and pidgins, Portuguese-based',
'cre' : 'Cree',
'crh' : 'Crimean Tatar; Crimean Turkish',
'crp' : 'Creoles and pidgins',
'csb' : 'Kashubian',
'cus' : 'Cushitic languages',
'wel' : 'Welsh',
'cze' : 'Czech',
'dak' : 'Dakota',
'dan' : 'Danish',
'dar' : 'Dargwa',
'day' : 'Land Dayak languages',
'del' : 'Delaware',
'den' : 'Slave (Athapascan)',
'ger' : 'German',
'dgr' : 'Dogrib',
'din' : 'Dinka',
'div' : 'Divehi; Dhivehi; Maldivian',
'doi' : 'Dogri',
'dra' : 'Dravidian languages',
'dsb' : 'Lower Sorbian',
'dua' : 'Duala',
'dum' : 'Dutch, Middle (ca.1050-1350)',
'dut' : 'Dutch; Flemish',
'dyu' : 'Dyula',
'dzo' : 'Dzongkha',
'efi' : 'Efik',
'egy' : 'Egyptian (Ancient)',
'eka' : 'Ekajuk',
'gre' : 'Greek, Modern (1453-)',
'elx' : 'Elamite',
'eng' : 'English',
'enm' : 'English, Middle (1100-1500)',
'epo' : 'Esperanto',
'est' : 'Estonian',
'baq' : 'Basque',
'ewe' : 'Ewe',
'ewo' : 'Ewondo',
'fan' : 'Fang',
'fao' : 'Faroese',
'per' : 'Persian',
'fat' : 'Fanti',
'fij' : 'Fijian',
'fil' : 'Filipino; Pilipino',
'fin' : 'Finnish',
'fiu' : 'Finno-Ugrian languages',
'fon' : 'Fon',
'fre' : 'French',
'fre' : 'French',
'frm' : 'French, Middle (ca.1400-1600)',
'fro' : 'French, Old (842-ca.1400)',
'frr' : 'Northern Frisian',
'frs' : 'Eastern Frisian',
'fry' : 'Western Frisian',
'ful' : 'Fulah',
'fur' : 'Friulian',
'gaa' : 'Ga',
'gay' : 'Gayo',
'gba' : 'Gbaya',
'gem' : 'Germanic languages',
'geo' : 'Georgian',
'ger' : 'German',
'gez' : 'Geez',
'gil' : 'Gilbertese',
'gla' : 'Gaelic; Scottish Gaelic',
'gle' : 'Irish',
'glg' : 'Galician',
'glv' : 'Manx',
'gmh' : 'German, Middle High (ca.1050-1500)',
'goh' : 'German, Old High (ca.750-1050)',
'gon' : 'Gondi',
'gor' : 'Gorontalo',
'got' : 'Gothic',
'grb' : 'Grebo',
'grc' : 'Greek, Ancient (to 1453)',
'gre' : 'Greek, Modern (1453-)',
'grn' : 'Guarani',
'gsw' : 'Swiss German; Alemannic; Alsatian',
'guj' : 'Gujarati',
'gwi' : 'Gwich\'in',
'hai' : 'Haida',
'hat' : 'Haitian; Haitian Creole',
'hau' : 'Hausa',
'haw' : 'Hawaiian',
'heb' : 'Hebrew',
'her' : 'Herero',
'hil' : 'Hiligaynon',
'him' : 'Himachali languages; Western Pahari languages',
'hin' : 'Hindi',
'hit' : 'Hittite',
'hmn' : 'Hmong',
'hmo' : 'Hiri Motu',
'hrv' : 'Croatian',
'hsb' : 'Upper Sorbian',
'hun' : 'Hungarian',
'hup' : 'Hupa',
'arm' : 'Armenian',
'iba' : 'Iban',
'ibo' : 'Igbo',
'ice' : 'Icelandic',
'ido' : 'Ido',
'iii' : 'Sichuan Yi; Nuosu',
'ijo' : 'Ijo languages',
'iku' : 'Inuktitut',
'ile' : 'Interlingue; Occidental',
'ilo' : 'Iloko',
'ina' : 'Interlingua (International Auxiliary Language Association)',
'inc' : 'Indic languages',
'ind' : 'Indonesian',
'ine' : 'Indo-European languages',
'inh' : 'Ingush',
'ipk' : 'Inupiaq',
'ira' : 'Iranian languages',
'iro' : 'Iroquoian languages',
'ice' : 'Icelandic',
'ita' : 'Italian',
'jav' : 'Javanese',
'jbo' : 'Lojban',
'jpn' : 'Japanese',
'jpr' : 'Judeo-Persian',
'jrb' : 'Judeo-Arabic',
'kaa' : 'Kara-Kalpak',
'kab' : 'Kabyle',
'kac' : 'Kachin; Jingpho',
'kal' : 'Kalaallisut; Greenlandic',
'kam' : 'Kamba',
'kan' : 'Kannada',
'kar' : 'Karen languages',
'kas' : 'Kashmiri',
'geo' : 'Georgian',
'kau' : 'Kanuri',
'kaw' : 'Kawi',
'kaz' : 'Kazakh',
'kbd' : 'Kabardian',
'kha' : 'Khasi',
'khi' : 'Khoisan languages',
'khm' : 'Central Khmer',
'kho' : 'Khotanese; Sakan',
'kik' : 'Kikuyu; Gikuyu',
'kin' : 'Kinyarwanda',
'kir' : 'Kirghiz; Kyrgyz',
'kmb' : 'Kimbundu',
'kok' : 'Konkani',
'kom' : 'Komi',
'kon' : 'Kongo',
'kor' : 'Korean',
'kos' : 'Kosraean',
'kpe' : 'Kpelle',
'krc' : 'Karachay-Balkar',
'krl' : 'Karelian',
'kro' : 'Kru languages',
'kru' : 'Kurukh',
'kua' : 'Kuanyama; Kwanyama',
'kum' : 'Kumyk',
'kur' : 'Kurdish',
'kut' : 'Kutenai',
'lad' : 'Ladino',
'lah' : 'Lahnda',
'lam' : 'Lamba',
'lao' : 'Lao',
'lat' : 'Latin',
'lav' : 'Latvian',
'lez' : 'Lezghian',
'lim' : 'Limburgan; Limburger; Limburgish',
'lin' : 'Lingala',
'lit' : 'Lithuanian',
'lol' : 'Mongo',
'loz' : 'Lozi',
'ltz' : 'Luxembourgish; Letzeburgesch',
'lua' : 'Luba-Lulua',
'lub' : 'Luba-Katanga',
'lug' : 'Ganda',
'lui' : 'Luiseno',
'lun' : 'Lunda',
'luo' : 'Luo (Kenya and Tanzania)',
'lus' : 'Lushai',
'mac' : 'Macedonian',
'mad' : 'Madurese',
'mag' : 'Magahi',
'mah' : 'Marshallese',
'mai' : 'Maithili',
'mak' : 'Makasar',
'mal' : 'Malayalam',
'man' : 'Mandingo',
'mao' : 'Maori',
'map' : 'Austronesian languages',
'mar' : 'Marathi',
'mas' : 'Masai',
'may' : 'Malay',
'mdf' : 'Moksha',
'mdr' : 'Mandar',
'men' : 'Mende',
'mga' : 'Irish, Middle (900-1200)',
'mic' : 'Mi\'kmaq; Micmac',
'min' : 'Minangkabau',
'mis' : 'Uncoded languages',
'mac' : 'Macedonian',
'mkh' : 'Mon-Khmer languages',
'mlg' : 'Malagasy',
'mlt' : 'Maltese',
'mnc' : 'Manchu',
'mni' : 'Manipuri',
'mno' : 'Manobo languages',
'moh' : 'Mohawk',
'mon' : 'Mongolian',
'mos' : 'Mossi',
'mao' : 'Maori',
'may' : 'Malay',
'mul' : 'Multiple languages',
'mun' : 'Munda languages',
'mus' : 'Creek',
'mwl' : 'Mirandese',
'mwr' : 'Marwari',
'bur' : 'Burmese',
'myn' : 'Mayan languages',
'myv' : 'Erzya',
'nah' : 'Nahuatl languages',
'nai' : 'North American Indian languages',
'nap' : 'Neapolitan',
'nau' : 'Nauru',
'nav' : 'Navajo; Navaho',
'nbl' : 'Ndebele, South; South Ndebele',
'nde' : 'Ndebele, North; North Ndebele',
'ndo' : 'Ndonga',
'nds' : 'Low German; Low Saxon; German, Low; Saxon, Low',
'nep' : 'Nepali',
'new' : 'Nepal Bhasa; Newari',
'nia' : 'Nias',
'nic' : 'Niger-Kordofanian languages',
'niu' : 'Niuean',
'dut' : 'Dutch; Flemish',
'nno' : 'Norwegian Nynorsk; Nynorsk, Norwegian',
'nob' : 'Bokmål, Norwegian; Norwegian Bokmål',
'nog' : 'Nogai',
'non' : 'Norse, Old',
'nor' : 'Norwegian',
'nqo' : 'N\'Ko',
'nso' : 'Pedi; Sepedi; Northern Sotho',
'nub' : 'Nubian languages',
'nwc' : 'Classical Newari; Old Newari; Classical Nepal Bhasa',
'nya' : 'Chichewa; Chewa; Nyanja',
'nym' : 'Nyamwezi',
'nyn' : 'Nyankole',
'nyo' : 'Nyoro',
'nzi' : 'Nzima',
'oci' : 'Occitan (post 1500)',
'oji' : 'Ojibwa',
'ori' : 'Oriya',
'orm' : 'Oromo',
'osa' : 'Osage',
'oss' : 'Ossetian; Ossetic',
'ota' : 'Turkish, Ottoman (1500-1928)',
'oto' : 'Otomian languages',
'paa' : 'Papuan languages',
'pag' : 'Pangasinan',
'pal' : 'Pahlavi',
'pam' : 'Pampanga; Kapampangan',
'pan' : 'Panjabi; Punjabi',
'pap' : 'Papiamento',
'pau' : 'Palauan',
'peo' : 'Persian, Old (ca.600-400 B.C.)',
'per' : 'Persian',
'phi' : 'Philippine languages',
'phn' : 'Phoenician',
'pli' : 'Pali',
'pol' : 'Polish',
'pon' : 'Pohnpeian',
'por' : 'Portuguese',
'pra' : 'Prakrit languages',
'pro' : 'Provençal, Old (to 1500);Occitan, Old (to 1500)',
'pus' : 'Pushto; Pashto',
'qaa' : 'Reserved for local use',
'que' : 'Quechua',
'raj' : 'Rajasthani',
'rap' : 'Rapanui',
'rar' : 'Rarotongan; Cook Islands Maori',
'roa' : 'Romance languages',
'roh' : 'Romansh',
'rom' : 'Romany',
'rum' : 'Romanian; Moldavian; Moldovan',
'rum' : 'Romanian; Moldavian; Moldovan',
'run' : 'Rundi',
'rup' : 'Aromanian; Arumanian; Macedo-Romanian',
'rus' : 'Russian',
'sad' : 'Sandawe',
'sag' : 'Sango',
'sah' : 'Yakut',
'sai' : 'South American Indian languages',
'sal' : 'Salishan languages',
'sam' : 'Samaritan Aramaic',
'san' : 'Sanskrit',
'sas' : 'Sasak',
'sat' : 'Santali',
'scn' : 'Sicilian',
'sco' : 'Scots',
'sel' : 'Selkup',
'sem' : 'Semitic languages',
'sga' : 'Irish, Old (to 900)',
'sgn' : 'Sign Languages',
'shn' : 'Shan',
'sid' : 'Sidamo',
'sin' : 'Sinhala; Sinhalese',
'sio' : 'Siouan languages',
'sit' : 'Sino-Tibetan languages',
'sla' : 'Slavic languages',
'slo' : 'Slovak',
'slo' : 'Slovak',
'slv' : 'Slovenian',
'sma' : 'Southern Sami',
'sme' : 'Northern Sami',
'smi' : 'Sami languages',
'smj' : 'Lule Sami',
'smn' : 'Inari Sami',
'smo' : 'Samoan',
'sms' : 'Skolt Sami',
'sna' : 'Shona',
'snd' : 'Sindhi',
'snk' : 'Soninke',
'sog' : 'Sogdian',
'som' : 'Somali',
'son' : 'Songhai languages',
'sot' : 'Sotho, Southern',
'spa' : 'Spanish; Castilian',
'alb' : 'Albanian',
'srd' : 'Sardinian',
'srn' : 'Sranan Tongo',
'srp' : 'Serbian',
'srr' : 'Serer',
'ssa' : 'Nilo-Saharan languages',
'ssw' : 'Swati',
'suk' : 'Sukuma',
'sun' : 'Sundanese',
'sus' : 'Susu',
'sux' : 'Sumerian',
'swa' : 'Swahili',
'swe' : 'Swedish',
'syc' : 'Classical Syriac',
'syr' : 'Syriac',
'tah' : 'Tahitian',
'tai' : 'Tai languages',
'tam' : 'Tamil',
'tat' : 'Tatar',
'tel' : 'Telugu',
'tem' : 'Timne',
'ter' : 'Tereno',
'tet' : 'Tetum',
'tgk' : 'Tajik',
'tgl' : 'Tagalog',
'tha' : 'Thai',
'tib' : 'Tibetan',
'tig' : 'Tigre',
'tir' : 'Tigrinya',
'tiv' : 'Tiv',
'tkl' : 'Tokelau',
'tlh' : 'Klingon; tlhIngan-Hol',
'tli' : 'Tlingit',
'tmh' : 'Tamashek',
'tog' : 'Tonga (Nyasa)',
'ton' : 'Tonga (Tonga Islands)',
'tpi' : 'Tok Pisin',
'tsi' : 'Tsimshian',
'tsn' : 'Tswana',
'tso' : 'Tsonga',
'tuk' : 'Turkmen',
'tum' : 'Tumbuka',
'tup' : 'Tupi languages',
'tur' : 'Turkish',
'tut' : 'Altaic languages',
'tvl' : 'Tuvalu',
'twi' : 'Twi',
'tyv' : 'Tuvinian',
'udm' : 'Udmurt',
'uga' : 'Ugaritic',
'uig' : 'Uighur; Uyghur',
'ukr' : 'Ukrainian',
'umb' : 'Umbundu',
'und' : 'Undetermined',
'urd' : 'Urdu',
'uzb' : 'Uzbek',
'vai' : 'Vai',
'ven' : 'Venda',
'vie' : 'Vietnamese',
'vol' : 'Volapük',
'vot' : 'Votic',
'wak' : 'Wakashan languages',
'wal' : 'Wolaitta; Wolaytta',
'war' : 'Waray',
'was' : 'Washo',
'wel' : 'Welsh',
'wen' : 'Sorbian languages',
'wln' : 'Walloon',
'wol' : 'Wolof',
'xal' : 'Kalmyk; Oirat',
'xho' : 'Xhosa',
'yao' : 'Yao',
'yap' : 'Yapese',
'yid' : 'Yiddish',
'yor' : 'Yoruba',
'ypk' : 'Yupik languages',
'zap' : 'Zapotec',
'zbl' : 'Blissymbols; Blissymbolics; Bliss',
'zen' : 'Zenaga',
'zha' : 'Zhuang; Chuang',
'chi' : 'Chinese',
'znd' : 'Zande languages',
'zul' : 'Zulu',
'zun' : 'Zuni',
'zxx' : 'No linguistic content; Not applicable',
'zza' : 'Zaza; Dimili; Dimli; Kirdki; Kirmanjki; Zazaki'};
var lang;
return ((lang = MAP_ISO6391_ISO6392[code]) !== null) ? lang : false;
}