learningequality / le-utils

Utilities and constants shared across Kolibri, Ricecooker, and Kolibri Studio
MIT License
2 stars 31 forks source link

fix wrong default Spanish lookup by name #33

Closed ivanistheone closed 6 years ago

ivanistheone commented 6 years ago

Before this PR, looking for Spanish by name was retuning Nicaraguan

>>> from le_utils.constants.languages import getlang, getlang_by_name, getlang_by_native_name
>>> lang_obj = getlang_by_name('Spanish')
>>> lang_obj.code
'es-NI'

There was a bug in the "enrichment" logic (edge case only applies to Spanish) that used the last occurence of the string.

After this PR, the un-localized Spanish gets processed first and so becomes the default:

>>> from le_utils.constants.languages import getlang, getlang_by_name, getlang_by_native_name
>>> lang_obj = getlang_by_name('Spanish')
>>> lang_obj.code
'es'

The second commit also fixes some inconsistensies in the native_name attributes. I enforced the convention that commas separate sifferent native names, and extra attributes in brackets.