mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 10:42:34 +01:00
fix capitalization issues
This commit is contained in:
parent
cc5e37aeae
commit
506242740f
@ -10,10 +10,11 @@
|
||||
|
||||
def code_to_language(code, default="English"):
|
||||
"""Map an ISO 639-1 language code to its actual name"""
|
||||
return codes.get(code, default)
|
||||
return codes.get(code.lower(), default)
|
||||
|
||||
def language_to_code(lang, default="en"):
|
||||
"""Map a language name to its ISO 639-1 code"""
|
||||
lang = lang.capitalize()
|
||||
for code, language in codes.items():
|
||||
if language == lang:
|
||||
return code
|
||||
|
@ -14,10 +14,12 @@ class TestISO639_1(unittest.TestCase):
|
||||
|
||||
def test_code_to_language(self):
|
||||
self.assertEqual(iso639_1.code_to_language("en"), "English")
|
||||
self.assertEqual(iso639_1.code_to_language("FR"), "French")
|
||||
self.assertEqual(iso639_1.code_to_language("xx"), "English")
|
||||
self.assertEqual(iso639_1.code_to_language("xx", default=None), None)
|
||||
def test_language_to_code(self):
|
||||
self.assertEqual(iso639_1.language_to_code("English"), "en")
|
||||
self.assertEqual(iso639_1.language_to_code("fRENch"), "fr")
|
||||
self.assertEqual(iso639_1.language_to_code("Nothing"), "en")
|
||||
self.assertEqual(iso639_1.language_to_code("Nothing", default=None), None)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user