pubmed.inc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. <?php
  2. /**
  3. * @file
  4. * Tripal Pub PubMed Interface
  5. *
  6. * @defgroup tripal_pub_pubmed PubMed Interface
  7. * @ingroup tripal_pub
  8. */
  9. /**
  10. *
  11. */
  12. function tripal_pub_remote_search_pubmed($terms_str, $num_to_retrieve, $pager_id) {
  13. // convert the terms list provicded by the caller into a string with words
  14. // separated by a '+' symbol.
  15. $search_terms = implode("+", preg_split('/\s+/', trim($terms_str)));
  16. // we want to get the list of pubs using the search terms but using a Drupal style pager
  17. $pubs = tripal_pager_callback('tripal_pub_remote_search_pubmed_range',
  18. 'tripal_pub_remote_search_pubmed_count', $num_to_retrieve, $pager_id, $search_terms);
  19. if ($pubs) {
  20. foreach ($pubs as $pub) {
  21. /*
  22. $pmid = $output[$i];
  23. //aquiring the pubmed id from the pub table based on the uniquename
  24. $values = array( 'uniquename' => $pmid);
  25. $pubmed_id = tripal_core_chado_select('pub', array('pub_id'), $values); */
  26. }
  27. }
  28. return $pubs;
  29. }
  30. /*
  31. * This function is used as the callback function when used with the
  32. * tripal_pager_callback function. This function returns a count of
  33. * the dataset to be paged.
  34. */
  35. function tripal_pub_remote_search_pubmed_count($terms) {
  36. // do a quick query using the provided terms, set the session variables
  37. // so we can reuse this query and then return the total number of records.
  38. $results = tripal_pub_remote_search_pubmed_query($terms);
  39. $_SESSION['tripal_pub_pubmed_query']['WebEnv'] = $results['WebEnv'];
  40. $_SESSION['tripal_pub_pubmed_query']['QueryKey'] = $results['QueryKey'];
  41. return $total_records;
  42. }
  43. /*
  44. * This function is used as the callback function when used with the
  45. * tripal_pager_callback function. This function returns the results
  46. * within the specified range
  47. */
  48. function tripal_pub_remote_search_pubmed_range($terms, $start = 0, $limit = 10) {
  49. // get the query_key and the web_env from the previous count query.
  50. $query_key = $_SESSION['tripal_pub_pubmed_query']['QueryKey'];
  51. $web_env = $_SESSION['tripal_pub_pubmed_query']['WebEnv'];
  52. // repeat the search performed previously (using WebEnv & QueryKey) to retrieve
  53. // the PMID's within the range specied. The PMIDs will be returned as a text list
  54. $pmids_txt = tripal_pub_remote_search_pubmed_fetch($terms, $query_key, $web_env, 'uilist', 'text', $start, $limit);
  55. // iterate through each PMID and get the publication record. This requires a new search and new fetch
  56. $pmids = explode("\n", trim($pmids_txt));
  57. $pubs = array();
  58. foreach ($pmids as $pmid) {
  59. // first intialize the search for a single PMID. This will give us a new query key and Web env
  60. $term = $pmid . "[uid]";
  61. $query = tripal_pub_remote_search_pubmed_query($terms);
  62. // second retrieve the individual record
  63. $pub_xml = tripal_pub_remote_search_pubmed_fetch($terms, $query['QueryKey'], $query['WebEnv'], 'null', 'xml', 0, 1);
  64. $pub = tripal_pub_remote_search_pubmed_parse_pubxml($pub_xml);
  65. $pubs[] = $pub;
  66. }
  67. dpm($pubs);
  68. return $pubs;
  69. }
  70. /*
  71. *
  72. */
  73. function tripal_pub_remote_search_pubmed_query($terms){
  74. // do a search for a single result so that we can establish a history, and get
  75. // the number of records. Once we have the number of records we can retrieve
  76. // those requested in the range.
  77. $query_url = "http://www.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=Pubmed&retmax=1&usehistory=y&term=$terms";
  78. $rfh = fopen($query_url, "r");
  79. if (!$rfh) {
  80. drupal_set_message('Could not perform Pubmed query. Cannot connect to Entrez.', 'error');
  81. return 0;
  82. }
  83. // retrieve the XML results
  84. $query_xml = '';
  85. while (!feof($rfh)) {
  86. $query_xml .= fread($rfh, 255);
  87. }
  88. fclose($rfh);
  89. $xml = new XMLReader();
  90. $xml->xml($query_xml);
  91. // iterate though the child nodes of the <eSearchResult> tag and get the count, history and query_id
  92. $result = array();
  93. while ($xml->read()) {
  94. if ($xml->nodeType == XMLReader::ELEMENT) {
  95. $element = $xml->name;
  96. $xml->read();
  97. $value = $xml->value;
  98. switch ($element) {
  99. case 'Count':
  100. $result['Count'] = $value;
  101. break;
  102. case 'WebEnv':
  103. $result['WebEnv'] = $value;
  104. break;
  105. case 'QueryKey':
  106. $result['QueryKey'] = $value;
  107. break;
  108. }
  109. }
  110. }
  111. return $result;
  112. }
  113. /*
  114. *
  115. */
  116. function tripal_pub_remote_search_pubmed_fetch($terms, $query_key, $web_env, $rettype = 'null',
  117. $retmod = 'null', $start = 0, $limit = 10){
  118. // repeat the search performed previously (using WebEnv & QueryKey) to retrieve
  119. // the PMID's within the range specied. The PMIDs will be returned as a text list
  120. $fetch_url = "http://www.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?rettype=$rettype&retmode=$retmod&retstart=$start&retmax=$limit&db=Pubmed&query_key=$query_key&WebEnv=$web_env";
  121. $rfh = fopen($fetch_url, "r");
  122. $results = '';
  123. while (!feof($rfh)) {
  124. $results .= fread($rfh, 255);
  125. }
  126. fclose($rfh);
  127. return $results;
  128. }
  129. /*
  130. * This function parses the XML containing details of a publication and
  131. * converts it into an associative array of where keys are Tripal Pub
  132. * ontology terms and the values are extracted from the XML. The
  133. * XML should contain only a single publication record.
  134. *
  135. * Information about the valid elements in the PubMed XML can be found here:
  136. * http://www.nlm.nih.gov/bsd/licensee/elements_descriptions.html
  137. *
  138. * Information about PubMed's citation format can be found here
  139. * http://www.nlm.nih.gov/bsd/policy/cit_format.html
  140. */
  141. function tripal_pub_remote_search_pubmed_parse_pubxml($pub_xml) {
  142. $pub = array();
  143. // read the XML and iterate through it.
  144. $xml = new XMLReader();
  145. $xml->xml($pub_xml);
  146. while ($xml->read()) {
  147. $element = $xml->name;
  148. if ($xml->nodeType == XMLReader::ELEMENT) {
  149. switch ($element) {
  150. case 'PMID':
  151. $xml->read(); // get the value for this element
  152. $pub['pub_accession'] = $xml->value;
  153. $pub['pub_database'] = 'PMID';
  154. break;
  155. case 'Article':
  156. $pub_model = $xml->getAttribute('PubModel');
  157. $pub['publication_model'] = $pub_model;
  158. tripal_pub_remote_search_pubmed_parse_article($xml, $pub);
  159. break;
  160. case 'MedlineJournalInfo':
  161. tripal_pub_remote_search_pubmed_parse_medline_journal_info($xml, $pub);
  162. break;
  163. case 'ChemicalList':
  164. // TODO: handle this
  165. break;
  166. case 'SupplMeshList':
  167. // TODO: meant for protocol list
  168. break;
  169. case 'CitationSubset':
  170. // TODO: not sure this is needed.
  171. break;
  172. case 'CommentsCorrections':
  173. // TODO: handle this
  174. break;
  175. case 'GeneSymbolList':
  176. // TODO: handle this
  177. break;
  178. case 'MeshHeadingList':
  179. // TODO: Medical subject headings
  180. break;
  181. case 'NumberOfReferences':
  182. // TODO: not sure we should keep this as it changes frequently.
  183. break;
  184. case 'PersonalNameSubjectList':
  185. // TODO: for works about an individual or with biographical note/obituary.
  186. break;
  187. case 'OtherID':
  188. // TODO: ID's from another NLM partner.
  189. break;
  190. case 'OtherAbstract':
  191. // TODO: when the journal does not contain an abstract for the publication.
  192. break;
  193. case 'KeywordList':
  194. // TODO: handle this
  195. break;
  196. case 'InvestigatorList':
  197. // TODO: personal names of individuals who are not authors (can be used with collection)
  198. break;
  199. case 'GeneralNote':
  200. // TODO: handle this
  201. break;
  202. case 'DeleteCitation':
  203. // TODO: need to know how to handle this
  204. break;
  205. default:
  206. break;
  207. }
  208. }
  209. }
  210. return $pub;
  211. }
  212. /*
  213. *
  214. */
  215. function tripal_pub_remote_search_pubmed_parse_medline_journal_info($xml, &$pub) {
  216. while ($xml->read()) {
  217. // get this element name
  218. $element = $xml->name;
  219. // if we're at the </Article> element then we're done with the article...
  220. if ($xml->nodeType == XMLReader::END_ELEMENT and $element == 'MedlineJournalInfo') {
  221. return;
  222. }
  223. if ($xml->nodeType == XMLReader::ELEMENT) {
  224. switch ($element) {
  225. case 'Country':
  226. // the place of publication of the journal
  227. $xml->read();
  228. $pub['journal_country'] = $xml->value;
  229. break;
  230. case 'MedlineTA':
  231. // TODO: not sure how this is different from ISOAbbreviation
  232. break;
  233. case 'NlmUniqueID':
  234. // TODO: the journal's unique ID in medline
  235. break;
  236. case 'ISSNLinking':
  237. // TODO: not sure how this is different from ISSN
  238. break;
  239. default:
  240. break;
  241. }
  242. }
  243. }
  244. }
  245. /*
  246. *
  247. */
  248. function tripal_pub_remote_search_pubmed_parse_article($xml, &$pub) {
  249. while ($xml->read()) {
  250. // get this element name
  251. $element = $xml->name;
  252. // if we're at the </Article> element then we're done with the article...
  253. if ($xml->nodeType == XMLReader::END_ELEMENT and $element == 'Article') {
  254. return;
  255. }
  256. if ($xml->nodeType == XMLReader::ELEMENT) {
  257. switch ($element) {
  258. case 'Journal':
  259. tripal_pub_remote_search_pubmed_parse_journal($xml, $pub);
  260. break;
  261. case 'ArticleTitle':
  262. $xml->read();
  263. $pub['title'] = $xml->value;
  264. break;
  265. case 'Abstract':
  266. tripal_pub_remote_search_pubmed_parse_abstract($xml, $pub);
  267. break;
  268. case 'Pagination':
  269. tripal_pub_remote_search_pubmed_parse_pagination($xml, $pub);
  270. break;
  271. case 'ELocationID':
  272. $type = $xml->getAttribute('EIdType');
  273. $valid = $xml->getAttribute('ValidYN');
  274. $xml->read();
  275. $elocation = $xml->value;
  276. if ($type == 'doi' and $valid == 'Y') {
  277. $pub['DOI'] = $elocation;
  278. }
  279. if ($type == 'pii' and $valid == 'Y') {
  280. $pub['PII'] = $elocation;
  281. }
  282. $pub['elocation'] = $elocation;
  283. break;
  284. case 'Affiliation':
  285. // the affiliation tag at this level is meant solely for the first author
  286. $xml->read();
  287. $pub['authors'][0]['affiliation'] = $xml->value;
  288. break;
  289. case 'AuthorList':
  290. $complete = $xml->getAttribute('CompleteYN');
  291. tripal_pub_remote_search_pubmed_parse_authorlist($xml, $pub);
  292. break;
  293. case 'InvestigatorList':
  294. // TODO: perhaps handle this one day. The investigator list is to list the names of people who
  295. // are members of a collective or corporate group that is an author in the paper.
  296. break;
  297. case 'Language':
  298. $xml->read();
  299. $lang_abbr = $xml->value;
  300. // there may be multiple languages so we store these in an array
  301. $pub['language'][] = tripal_pub_remote_search_get_language($lang_abbr);
  302. $pub['language_abbr'][] = $lang_abbr;
  303. break;
  304. case 'DataBankList':
  305. // TODO: handle this case
  306. break;
  307. case 'GrantList':
  308. // TODO: handle this case
  309. break;
  310. case 'PublicationTypeList':
  311. tripal_pub_remote_search_pubmed_parse_publication_type($xml, $pub);
  312. break;
  313. case 'VernacularTitle':
  314. $xml->read();
  315. $pub['vernacular_title'][] = $xml->value;;
  316. break;
  317. case 'ArticleDate':
  318. // TODO: figure out what to do with this element. We already have the
  319. // published date in the <PubDate> field, but this date should be in numeric
  320. // form and may have more information.
  321. break;
  322. default:
  323. break;
  324. }
  325. }
  326. }
  327. }
  328. /*
  329. * A full list of publication types can be found here:
  330. * http://www.nlm.nih.gov/mesh/pubtypes.html.
  331. *
  332. * The Tripal Pub ontology doesn't yet have terms for all of the
  333. * publication types so we store the value in the 'publication_type' term.
  334. */
  335. function tripal_pub_remote_search_pubmed_parse_publication_type($xml, &$pub) {
  336. while ($xml->read()) {
  337. $element = $xml->name;
  338. if ($xml->nodeType == XMLReader::END_ELEMENT and $element == 'PublicationTypeList') {
  339. // we've reached the </Pagination> element so we're done.
  340. return;
  341. }
  342. if ($xml->nodeType == XMLReader::ELEMENT) {
  343. switch ($element) {
  344. case 'PublicationType':
  345. $xml->read();
  346. $pub['publication_type'][] = $xml->value;
  347. break;
  348. default:
  349. break;
  350. }
  351. }
  352. }
  353. }
  354. /*
  355. *
  356. */
  357. function tripal_pub_remote_search_pubmed_parse_abstract($xml, &$pub) {
  358. $abstract = '';
  359. while ($xml->read()) {
  360. $element = $xml->name;
  361. if ($xml->nodeType == XMLReader::END_ELEMENT and $element == 'Abstract') {
  362. // we've reached the </Abstract> element so return
  363. $pub['abstract'] = $abstract;
  364. return;
  365. }
  366. // the abstract text can be just a singe paragraph or be broken into multiple
  367. // abstract texts for structured abstracts. Here we will just combine then
  368. // into a single element in the order that they arrive in HTML format
  369. if ($xml->nodeType == XMLReader::ELEMENT) {
  370. switch ($element) {
  371. case 'AbstractText':
  372. $label = $xml->getAttribute('Label');
  373. $xml->read();
  374. if ($label) {
  375. $pub['structured_abstract_part'][][$label] = $xml->value;
  376. $abstract .= "<p><b>$label</b></br>" . $xml->value . '</p>';
  377. }
  378. else {
  379. $abstract .= '<p>' . $xml->value . '</p>';
  380. }
  381. break;
  382. case 'CopyrightInformation':
  383. $xml->read();
  384. $pub['copyright'] = $xml->value;
  385. break;
  386. default:
  387. break;
  388. }
  389. }
  390. }
  391. }
  392. /*
  393. *
  394. */
  395. function tripal_pub_remote_search_pubmed_parse_pagination($xml, &$pub) {
  396. while ($xml->read()) {
  397. $element = $xml->name;
  398. if ($xml->nodeType == XMLReader::END_ELEMENT and $element == 'Pagination') {
  399. // we've reached the </Pagination> element so we're done.
  400. return;
  401. }
  402. if ($xml->nodeType == XMLReader::ELEMENT) {
  403. switch ($element) {
  404. case 'MedlinePgn':
  405. $xml->read();
  406. $pub['pages'] = $xml->value;
  407. break;
  408. default:
  409. break;
  410. }
  411. }
  412. }
  413. }
  414. /*
  415. *
  416. */
  417. function tripal_pub_remote_search_pubmed_parse_journal($xml, &$pub) {
  418. while ($xml->read()) {
  419. $element = $xml->name;
  420. if ($xml->nodeType == XMLReader::END_ELEMENT){
  421. // if we're at the </AuthorList> element then we're done with the article...
  422. if($element == 'Journal') {
  423. return;
  424. }
  425. }
  426. if ($xml->nodeType == XMLReader::ELEMENT) {
  427. switch ($element) {
  428. case 'ISSN':
  429. $issn_type = $xml->getAttribute('IssnType');
  430. $xml->read();
  431. $issn = $xml->value;
  432. $pub['ISSN'] = $issn;
  433. if ($issn_type == 'Electronic') {
  434. $pub['eISSN'] = $issn;
  435. }
  436. if ($issn_type == 'Print') {
  437. $pub['pISSN'] = $issn;
  438. }
  439. break;
  440. case 'JournalIssue':
  441. // valid values of cited_medium are 'Internet' and 'Print'
  442. $cited_medium = $xml->getAttribute('CitedMedium');
  443. tripal_pub_remote_search_pubmed_parse_journal_issue($xml, $pub);
  444. break;
  445. case 'Title':
  446. $xml->read();
  447. $pub['journal_name'] = $xml->value;
  448. break;
  449. case 'ISOAbbreviation':
  450. $xml->read();
  451. $pub['journal_iso_abbreviation'] = $xml->value;
  452. break;
  453. default:
  454. break;
  455. }
  456. }
  457. }
  458. }
  459. /*
  460. *
  461. */
  462. function tripal_pub_remote_search_pubmed_parse_journal_issue($xml, &$pub) {
  463. while ($xml->read()) {
  464. $element = $xml->name;
  465. if ($xml->nodeType == XMLReader::END_ELEMENT and $element = 'JournalIssue'){
  466. // if we're at the </JournalIssue> element then we're done
  467. return;
  468. }
  469. if ($xml->nodeType == XMLReader::ELEMENT) {
  470. switch ($element) {
  471. case 'Volume':
  472. $xml->read();
  473. $pub['volumn'] = $xml->value;
  474. break;
  475. case 'Issue':
  476. $xml->read();
  477. $pub['issue'] = $xml->value;
  478. break;
  479. case 'PubDate':
  480. $date = tripal_pub_remote_search_pubmed_parse_date($xml, 'PubDate');
  481. $year = $date['year'];
  482. $month = $date['month'];
  483. $day = $date['day'];
  484. $medline = $date['medline'];
  485. if ($month and $day and $year) {
  486. $pub['publication_date'] = "$year $month $day";
  487. }
  488. elseif ($month and !$day and $year) {
  489. $pub['publication_date'] = "$year $month";
  490. }
  491. elseif (!$month and !$day and $year) {
  492. $pub['publication_date'] = $year;
  493. }
  494. elseif ($medline) {
  495. $pub['publication_date'] = $medline;
  496. }
  497. else {
  498. $pub['publication_date'] = "Unknown";
  499. }
  500. break;
  501. default:
  502. break;
  503. }
  504. }
  505. }
  506. }
  507. /*
  508. *
  509. */
  510. function tripal_pub_remote_search_pubmed_parse_date ($xml, $element_name) {
  511. $date = array();
  512. while ($xml->read()) {
  513. $element = $xml->name;
  514. if ($xml->nodeType == XMLReader::END_ELEMENT and $element = $element_name){
  515. // if we're at the </$element_name> then we're done
  516. return $date;
  517. }
  518. if ($xml->nodeType == XMLReader::ELEMENT) {
  519. switch ($element) {
  520. case 'Year':
  521. $xml->read();
  522. $date['year'] = $xml->value;
  523. break;
  524. case 'Month':
  525. $xml->read();
  526. $month =
  527. $date['month'] = $xml->value;
  528. break;
  529. case 'Day':
  530. $xml->read();
  531. $date['day'] = $xml->value;
  532. break;
  533. case 'MedlineDate':
  534. // the medline date is when the date cannot be broken into distinct month day year.
  535. $xml->read();
  536. $date['medline'] = $xml->value;
  537. break;
  538. default:
  539. break;
  540. }
  541. }
  542. }
  543. }
  544. /*
  545. *
  546. */
  547. function tripal_pub_remote_search_pubmed_parse_authorlist($xml, &$pub) {
  548. $num_authors = 0;
  549. while ($xml->read()) {
  550. $element = $xml->name;
  551. if ($xml->nodeType == XMLReader::END_ELEMENT){
  552. // if we're at the </AuthorList> element then we're done with the article...
  553. if($element == 'AuthorList') {
  554. // build the author list before returning
  555. $author_list = '';
  556. foreach ($pub['authors'] as $author) {
  557. if ($author['valid'] == 'N') {
  558. // skip non-valid entries. A non-valid entry should have
  559. // a corresponding corrected entry so we can saftely skip it.
  560. continue;
  561. }
  562. if ($author['collective']) {
  563. $author_list .= $author['collective'] . ', ';
  564. }
  565. else {
  566. $author_list .= $author['surname'] . ' ' . $author['first_initials'] . ', ';
  567. }
  568. }
  569. $author_list = substr($author_list, 0, -2);
  570. $pub['author_list'] = $author_list;
  571. return;
  572. }
  573. // if we're at the end </Author> element then we're done with the author and we can
  574. // start a new one.
  575. if($element == 'Author') {
  576. $num_authors++;
  577. }
  578. }
  579. if ($xml->nodeType == XMLReader::ELEMENT) {
  580. switch ($element) {
  581. case 'Author':
  582. $valid = $xml->getAttribute('ValidYN');
  583. $pub['authors'][$num_authors]['valid'] = $valid;
  584. break;
  585. case 'LastName':
  586. $xml->read();
  587. $pub['authors'][$num_authors]['surname'] = $xml->value;
  588. break;
  589. case 'ForeName':
  590. $xml->read();
  591. $pub['authors'][$num_authors]['given_name'] = $xml->value;
  592. break;
  593. case 'Initials':
  594. $xml->read();
  595. $pub['authors'][$num_authors]['first_initials'] = $xml->value;
  596. break;
  597. case 'Suffix':
  598. $xml->read();
  599. $pub['authors'][$num_authors]['suffix'] = $xml->value;
  600. break;
  601. case 'CollectiveName':
  602. $xml->read();
  603. $pub['authors'][$num_authors]['collective'] = $xml->value;
  604. break;
  605. case 'Identifier':
  606. // according to the specification, this element is not yet used.
  607. break;
  608. default:
  609. break;
  610. }
  611. }
  612. }
  613. }
  614. /*
  615. * Language abbreviations were obtained here:
  616. * http://www.nlm.nih.gov/bsd/language_table.html
  617. */
  618. function tripal_pub_remote_search_get_language($lang_abbr) {
  619. $languages = array(
  620. 'afr' => 'Afrikaans',
  621. 'alb' => 'Albanian',
  622. 'amh' => 'Amharic',
  623. 'ara' => 'Arabic',
  624. 'arm' => 'Armenian',
  625. 'aze' => 'Azerbaijani',
  626. 'ben' => 'Bengali',
  627. 'bos' => 'Bosnian',
  628. 'bul' => 'Bulgarian',
  629. 'cat' => 'Catalan',
  630. 'chi' => 'Chinese',
  631. 'cze' => 'Czech',
  632. 'dan' => 'Danish',
  633. 'dut' => 'Dutch',
  634. 'eng' => 'English',
  635. 'epo' => 'Esperanto',
  636. 'est' => 'Estonian',
  637. 'fin' => 'Finnish',
  638. 'fre' => 'French',
  639. 'geo' => 'Georgian',
  640. 'ger' => 'German',
  641. 'gla' => 'Scottish Gaelic',
  642. 'gre' => 'Greek, Modern',
  643. 'heb' => 'Hebrew',
  644. 'hin' => 'Hindi',
  645. 'hrv' => 'Croatian',
  646. 'hun' => 'Hungarian',
  647. 'ice' => 'Icelandic',
  648. 'ind' => 'Indonesian',
  649. 'ita' => 'Italian',
  650. 'jpn' => 'Japanese',
  651. 'kin' => 'Kinyarwanda',
  652. 'kor' => 'Korean',
  653. 'lat' => 'Latin',
  654. 'lav' => 'Latvian',
  655. 'lit' => 'Lithuanian',
  656. 'mac' => 'Macedonian',
  657. 'mal' => 'Malayalam',
  658. 'mao' => 'Maori',
  659. 'may' => 'Malay',
  660. 'mul' => 'Multiple languages',
  661. 'nor' => 'Norwegian',
  662. 'per' => 'Persian',
  663. 'pol' => 'Polish',
  664. 'por' => 'Portuguese',
  665. 'pus' => 'Pushto',
  666. 'rum' => 'Romanian, Rumanian, Moldovan',
  667. 'rus' => 'Russian',
  668. 'san' => 'Sanskrit',
  669. 'slo' => 'Slovak',
  670. 'slv' => 'Slovenian',
  671. 'spa' => 'Spanish',
  672. 'srp' => 'Serbian',
  673. 'swe' => 'Swedish',
  674. 'tha' => 'Thai',
  675. 'tur' => 'Turkish',
  676. 'ukr' => 'Ukrainian',
  677. 'und' => 'Undetermined',
  678. 'urd' => 'Urdu',
  679. 'vie' => 'Vietnamese',
  680. 'wel' => 'Welsh',
  681. );
  682. return $languages[$lang_abbr];
  683. }