Correctly check the index in the pref. list when selecting the ES.

The former check wasn't enough since a language that isn't in the table
has a -1 index.

Fix #9531