Multilingual typing: main locale is not guaranteed to be dictionaryGroups[0] (HashSet in getUsedLocales)
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- Meio dia
- Facilidade para iniciantes
- 62/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Domínio
- internationalization, mobile
Direção de pesquisa
Start in DictionaryFacilitatorImpl.getUsedLocales(), where hashSetOf(mainLocale) is built, and in getNewDictGroupsAndDictsToCleanup(), which creates the groups in that set's iteration order. Then check the dictionaryGroups[0] call sites the issue lists: mainLocale, currentlyPreferredDictionaryGroup, getSuggestionResults(), isActive() and LatinIME.resetSuggestMainDict(). Done when the main locale is always group 0 regardless of Locale.hashCode(), for example with a linkedSetOf change, and a test or debug output confirms the order for en_US with de.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Describe the bug
With a secondary language (multilingual typing), the main locale of the layout is not guaranteed to be the first dictionary group. DictionaryFacilitatorImpl.getUsedLocales() collects the locales in a HashSet:
val locales = hashSetOf(mainLocale)
locales.addAll(getSecondaryLocales(selectedSubtype.extraValue))
getNewDictGroupsAndDictsToCleanup() creates the groups in the iteration order of that set, and a HashSet doesn't keep insertion order. But a lot of code assumes dictionaryGroups[0] is the main locale:
mainLocale=dictionaryGroups[0].locale, also used byLatinIME.resetSuggestMainDict(), which callsresetDictionaries(this, dictionaryFacilitator.mainLocale, ...). If that is the secondary locale,getUsedLocales()goes into the "called from the spell checker" branch, and as far as I can see the keyboard can end up with only the secondary language.currentlyPreferredDictionaryGroup=maxBy { it.confidence }returns the first group on a tie. At the start all groups have confidence 1, so the tie goes to whichever locale the HashSet put first.getSuggestionResults()queries only group 0 synchronously and waits at most 120 ms for the others.isActive(),isValidSuggestionWord(), the personal-dictionary check inaddToUserHistory()anddumpDictionaryForDebug()also use group 0.
Which pairs are affected depends on Locale.hashCode(). A quick check on a desktop JVM (Java 21) shows the secondary locale first for 7 of 12 common pairs, e.g. main en_US + secondary de, fr or es, and main nl or pl + secondary en_US. On our devices (Android 15/17), de_DE + en_US happened to come out in the right order, so Android's order differs from the JVM, but it is still not defined.
Possible fix
Keep the insertion order (that's what we did):
val locales = linkedSetOf(mainLocale)
To Reproduce
- Set up a layout with a secondary language via Multilingual typing, e.g. English (US) with German.
- Depending on the pair, the secondary locale becomes
dictionaryGroups[0]. With debug mode on, the space bar shows the order of the locales (localesAndConfidences()).
Expected behavior
The layout's main locale is always the first dictionary group.
App version & Flavor
Found in GlassType, my fork, now based on LeanType 4.3.1 (0e673e1). The code is unchanged in current main.
Device Info
- Model: Samsung Galaxy Z Fold 3 (SM-F926B) and Galaxy S23 Ultra (SM-S918B)
- OS version: Android 15 / Android 17
- Linguagem predominante
- Kotlin
- Estrelas
- 1k
- Forks
- 59
- Merge médio
- 14h 9min
- PRs com merge (30d)
- 56
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de LeanBitLab/LeanType
-
enhancement
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
LeanBitLab/LeanType#766 ·
Mantenedores costumam responder em até 1 dia
-
[Bug] Silence timeout doesn't close interface and start transcription; causes silent loss of dictated speech.Talvez já em andamento @LeanBitLab assumiu hoje. Abertabug
LeanBitLab/LeanType#765 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
[issue] Tamil Keyboard issueAbertabug
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
LeanBitLab/LeanType#764 ·
Mantenedores costumam responder em até 1 dia
-
enhancement
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 30/100
LeanBitLab/LeanType#757 · 7 comentários ·
Mantenedores costumam responder em até 1 dia
-
More suggestions based on version 1.0.1 of the CJK pluginTalvez já em andamento @LeanBitLab assumiu há 2 dias. Abertaenhancement
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 38/100
LeanBitLab/LeanType#754 · 1 comentário · 1 responsável ·
Mantenedores costumam responder em até 1 dia
Todas as issues de LeanBitLab/LeanType
Issues semelhantes
-
bug core p3
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
RunanywhereAI/runanywhere-sdks#1258 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
Kotlin-server-squad/vizcore#278 ·
Mantenedores costumam responder em até 1 dia
-
Empty blood pressure handled as “null” string in exam editTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
open-learning-exchange/myplanet#18484 ·
Mantenedores costumam responder em até 1 dia
-
enhancement
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
Seb3thehacker/gearslip#71 ·