nodejs-langs
nodejs-langs copied to clipboard
Add language name aliases and search language by its alias
Hi,
The purpose of this pull request is to enable a "lazy" match on language names.
For instance, some language names in data.js contain characters beyond Basic Latin ASCII range (e.g. Pāli, Norwegian Bokmål). This could be fixed by cleaning data according to official ISO standard, but it wouldn't solve another problem: language names may have synonyms or transliteration variants (e.g. Persian = Farsi, Pashto = Pushto).
My idea is to add aliases for these languages in data.js and extend API to allow searching by these aliases:
// data.js:127
// {"name":"Persian", "alias": ["Farsi"], "local":"فارسی", "1":"fa", "2":"fas", "2T":"fas", "2B":"per", "3":"fas"},
langs.where('name', 'Persian') // -> {'name': 'Persian', ...}
langs.where('name', 'Farsi') // -> undefined
langs.like('Persian') // -> {'name': 'Persian', ...}
langs.like('Farsi') // -> {'name': 'Persian', ...}
langs.like('persian', 'ignoreCase') // -> {'name': 'Persian', ...}
`