tobyatgithub / ReadalongsDesktop

A desktop GUI app for readalongs to help indigenous communities teach and pass on their languages.
MIT License
3 stars 2 forks source link

Language drop-down list suggestions #10

Closed joanise closed 3 years ago

joanise commented 3 years ago

Playing with the app, I noticed the language selection drop-down list could be improved.

>>> from readalongs.util import getLangs
>>> langs, lang_names = getLangs()
>>> [f"{l} ({lang_names[l]})" for l in langs]
['alq (Algonquin)', 'atj (Atikamekw)', 'ckt (Chukchi)', 'crg-dv (Michif)', 'crg-tmd (Michif)', 'crj (Southern East Cr
ee)', 'crk (Plains Cree)', 'crl (Northern East Cree)', 'crm (Moose Cree)', 'csw (Swampy Cree)', 'ctp (Western Highlan
d Chatino)', 'dan (Danish)', 'eng (English)', 'fra (French)', 'git (Gitksan)', 'gla (Scottish Gaelic)', "gwi (Gwich'i
n)", 'haa (Hän)', 'ikt (Western Inuktut)', 'iku (Inuktitut)', 'iku-sro (Inuktitut)', 'kkz (Kaska)', "kwk-boas (Kwak'w
ala)", "kwk-napa (Kwak'wala)", "kwk-umista (Kwak'wala)", 'lml (Raga)', "mic (Mi'kmaq)", 'moh (Mohawk)', 'moh-festival
 (Mohawk)', 'oji (Ojibwe)', 'oji-syl (Ojibwe)', 'see (Seneca)', "srs (Tsuut'ina)", 'str (SENĆOŦEN)', 'tau (Upper Tana
na)', 'tce (Southern Tutchone)', 'tgx (Tagish)', 'tli (Tlingit)', 'ttm (Northern Tutchone)', 'und (Undetermined)', 'u
nd-ascii (Undetermined)', 'win (Hoocąk)']

If the selection comes back as that whole string and you need to get the language code back out, you can just use split():

>>> selection = "kwk-umista (Kwak'wala)"
>>> selection.split(maxsplit=1)[0]
'kwk-umista'
tobyatgithub commented 3 years ago

Great idea! Solved and merged into main at https://github.com/tobyatgithub/ReadalongsDesktop/commit/9edeac4f36a16bd1105f662281ec5ab0e7faac25