aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/fatcat_tools/importers/datacite.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/python/fatcat_tools/importers/datacite.py b/python/fatcat_tools/importers/datacite.py
index 19b89edf..26520164 100644
--- a/python/fatcat_tools/importers/datacite.py
+++ b/python/fatcat_tools/importers/datacite.py
@@ -10,7 +10,7 @@ import datetime
import fatcat_openapi_client
import hashlib
import json
-import langcodes
+import pycountry
import langdetect
import sqlite3
import sys
@@ -433,12 +433,9 @@ class DataciteImporter(EntityImporter):
value = attributes.get('language', '') or ''
try:
- language = langcodes.find(value).language
- except LookupError:
- try:
- language = langcodes.get(value).language
- except langcodes.tag_parser.LanguageTagError:
- pass
+ language = pycountry.languages.lookup(value).alpha_2
+ except (LookupError, AttributeError) as err:
+ print('language lookup miss for {}: {}'.format(value, err), file=sys.stderr)
# Abstracts appear in "attributes.descriptions[].descriptionType", some
# of the observed values: "Methods", "TechnicalInfo",