Skip to content

feat: auto-detect Hebrew/English per query, add Auto language option - #4

Closed
Nemet360 wants to merge 1 commit into
Appz4Fun:mainfrom
Nemet360:feature/hebrew-english-auto-detect
Closed

Nemet360 wants to merge 1 commit into
Appz4Fun:mainfrom
Nemet360:feature/hebrew-english-auto-detect

Conversation

@Nemet360

@Nemet360 Nemet360 commented Oct 3, 2026

Copy link
Copy Markdown

What

`autocomplete_lang` was a fixed setting, so a Hebrew search needed one language and the next English search needed the opposite — manual switching between every query.

  • `detect_language(text)` returns `"he"` the moment any character in `U+0590-U+05FF` appears anywhere in the query (reusing the same Hebrew block `prep_search_str` already tests a subset of), `"en"` otherwise. Digits and Latin punctuation never flip it; a single Hebrew character in an otherwise-English query is enough (`"שובר bad"` → `he`).
  • `resolve_language(search_str)` is the one place that decides the effective language for a request: if `autocomplete_lang` is `"auto"` it calls `detect_language` on the text just typed; otherwise it returns the configured value completely unchanged — an existing install with a real language code set behaves byte-for-byte as before. The language is passed into each provider as a constructor kwarg rather than mutated onto a shared setting, so nothing is global and nothing needs resetting between searches.
  • Google (`hl=`) and TMDb (`language=`) now receive the resolved value. Bing's `build_url` never referenced `self.language` and still doesn't — it was never asked to change. `LocalDictProvider` keeps reading its own separate `autocomplete_lang_local` setting, untouched.
  • `resources/settings.xml` gains a single new `auto` option in the existing `autocomplete_lang` spinner; the default stays `en`, so nothing changes for anyone who hasn't picked it.

Tests

13 tests in `tests/`, covering the exact examples from the request plus the two guarantees most likely to regress silently: a fixed language must survive being read again unchanged, and the `"auto"` sentinel must never reach a real Google/TMDb request URL.

`AutoCompletion.py` resolves `xbmcaddon`/`xbmcvfs` at import time rather than inside a function, so `tests/kodistubs.py` fakes those three modules in `sys.modules` before import — no third-party test dependency, consistent with the module's own zero-dependency rule. Also adds `.github/workflows/ci.yml` to run `compileall` + the new tests on every push and PR (the existing `release.yml` only runs on a version tag).

Manual verification still needed

Not reproducible outside a running Kodi instance:

  • Physical-keyboard input: typing Hebrew switches to Hebrew suggestions, typing English switches to English, no manual language change
  • Virtual-keyboard input: same
  • No exception in `kodi.log` for either input method
  • No regression in RTL display of results

Changed files

  • `lib/vendor/AutoCompletion.py` — `detect_language`, `resolve_language`, provider `language` kwarg
  • `resources/settings.xml` — `auto` option added to `autocomplete_lang`
  • `tests/kodistubs.py`, `tests/test_language.py` — new
  • `.github/workflows/ci.yml` — new

`autocomplete_lang` was a fixed setting, so a Hebrew search needed one
language and the next English search needed the opposite - manual switching
between every query. detect_language(text) returns "he" the moment any
character in U+0590-U+05FF appears anywhere in the query (reusing the same
Hebrew block prep_search_str already tests a subset of), "en" otherwise;
digits and Latin punctuation never flip it, and a single Hebrew character in
an otherwise-English query is enough ("שובר bad" -> he).

resolve_language(search_str) is the one place that decides the EFFECTIVE
language for a request: if autocomplete_lang is "auto" it calls
detect_language on the text just typed, otherwise it returns the configured
value completely unchanged - an existing install with a real language code
set behaves byte-for-byte as before. The language is passed into each
provider as a constructor kwarg rather than mutated onto a shared setting,
so nothing is global and nothing needs resetting between searches.

Google (hl=) and TMDb (language=) now receive the resolved value. Bing's
build_url never referenced self.language and still doesn't - it was never
asked to change. LocalDictProvider keeps reading its own separate
autocomplete_lang_local setting, untouched.

resources/settings.xml gains a single new `auto` option in the existing
autocomplete_lang spinner; the default stays `en`, so nothing changes for
anyone who hasn't picked it.

13 tests in tests/, covering the exact examples from the request plus the
two guarantees most likely to regress silently: a fixed language must
survive being read again unchanged, and the "auto" sentinel must never reach
a real Google/TMDb request URL. AutoCompletion.py resolves xbmcaddon/xbmcvfs
at import time rather than inside a function, so tests/kodistubs.py fakes
those three modules in sys.modules before import - no third-party test
dependency, consistent with the module's own zero-dependency rule. Also adds
.github/workflows/ci.yml to run compileall + the new tests on every push and
PR (the existing release.yml only runs on a version tag).

Manual verification still needed on real hardware (not reproducible outside
a running Kodi instance): physical-keyboard and virtual-keyboard input both
trigger correct per-query language switching, and no exception appears in
kodi.log for either input method.
@Nemet360

Nemet360 commented Oct 3, 2026

Copy link
Copy Markdown
Author

סוגר - הקוד עובר לריפו שלי (kodi-room-sync) במקום.

@Nemet360 Nemet360 closed this Oct 3, 2026
Nemet360 added a commit to Nemet360/kodi-room-sync that referenced this pull request Oct 3, 2026
Hebrew/English auto-detect language feature was built against a fork of
Appz4Fun/plugin.program.autocompletion-voice and offered upstream as a PR.
Owner wants his own code living only in his own repo, not upstream — so the
whole AutoCompletion add-on (incl. the Hebrew/English auto-detect patch) is
copied in full as a second add-on under addon/plugin.program.autocompletion/,
discovered automatically by the existing multi-addon build_repository.py.

- addon.xml: version normalized to 3.0.1+beta.3 (was 3.0.1-beta.3, invalid
  per the Kodi manifest schema) and the xbmc.service start="startup"
  attribute dropped (schema-invalid; "startup" is the documented default
  when omitted, so behaviour is unchanged)
- ci.yml: runs this add-on's own unit tests and includes it in the
  kodi-addon-checker pass alongside the two existing add-ons
- repository/ rebuilt: addons.xml gained the new manifest entry, and the
  add-on's own zip+hashes were added — the two pre-existing add-ons' zips
  are untouched (verified byte-identical to HEAD)

Upstream PR (Appz4Fun/plugin.program.autocompletion-voice#4) is closed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant