Anki/pylib/anki
GithubAnon0000 8ff9691723 FIX lang selection resetting to en_US for some langs (#3744)
* FIX lang selection resetting to en_US for some langs

Fixes https://forums.ankiweb.net/t/anki-25-01-beta/54490/17?u=anon_0000.

# Issue
Set a hand full of certain languages in the preferences screen and see that the translations have been applied after reboot. The language selection in preferences wrongly shows en_US though, not the current active language. If you wanted to switch to `en_US` in this case, then you'd have to first switch to a working language (like de_DE) and then switch to en_US.

# Solution
`anki/qt/aqt/preferences.py` has the functions `setup_language()` and `current_lang_index()`. I noticed that it defaults to en_US, if the language is not in `compatMap` and it couldn’t return the index of the current language. No idea if this code is faulty but I headed over to `anki/pylib/anki/lang.py` afterwards.

Here, in `compatMap`, I added e.g. `"la": "la_LA"`. I knew the code since I could get it with `print("––– lang is ", lang)` in `preferences.py` (`current_lang_index()` retrieves `la` for latin).

After adding those code changes from my PR, the problem for those selected languages had gone away.

No idea if that's best practices though or if something else should be fixed instead.

* UPDATE CONTRIBUTORS adding myself to the list
2025-01-25 19:14:50 +11:00
..
_vendor
foreign_data
importing
scheduler
_backend.py
_legacy.py
_rsbridge.pyi
browser.py
cards.py
collection.py
config.py
consts.py
db.py
dbproxy.py
decks.py
errors.py
exporting.py
find.py
hooks.py
httpclient.py
lang.py FIX lang selection resetting to en_US for some langs (#3744) 2025-01-25 19:14:50 +11:00
latex.py
media.py
models.py
notes.py
py.typed
rsbackend.py
sound.py
stats.py
statsbg.py
stdmodels.py
storage.py
sync.py
syncserver.py
tags.py
template.py
types.py
utils.py