New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Python] xbmc.getLanguage(xbmc.ISO_639_1) returns empty string for English(US), English(AU), French(CA) etc #24990
Comments
OK, the problem appears to be in utils/LanguageCodeExpander.cpp xbmc/xbmc/utils/LangCodeExpander.cpp Line 294 in 497beac
The Englishname is used in the call to
ReferseLookup tries to match the Englishname in the user assigned codes, g_iso639_1 table and g_iso639_2 tables xbmc/xbmc/utils/LangCodeExpander.cpp Lines 395 to 397 in 497beac
which for "English {New Zealand)" returns "en-nz" in str tmp. ConvertToISO6391 continues: xbmc/xbmc/utils/LangCodeExpander.cpp Lines 338 to 353 in 497beac
which expects the returned code to be 2 chars (except for a single case of 3 chars) so "en-nz" fails. Not sure how best to fix. Maybe in ConvertToISO6391 strip the hyphen region off the returned results of ReverseLookup. I guess CLocale can parse the string and return the ISO 639-1 portion of it. |
After thinking about this, I think changing ModuleXbmc.cpp is the place to do this, since it's closest to the caller and not likely to have side effects. Then in getLocalizedString for the |
I did a one-line fix for this issue, but during testing I set the "region" parameter to "True" in the python test script, and what I get back for ISO639_2 and ENGLISH_NAME was a mess for the test case of UI language set to English (New Zealand). For example, for ISO639_2 the code is calling As it is the Python is returning "en-nz-nzl" when what is expected is "eng-nzl". |
While testing fixes, discovered related issue when switching language resource addons in the UI see #25034 |
Also would help if a requirements engineer (anyone with interest in setting/validating the requirement) could specify what is supposed to be returned for the six possible cases in xbmc.getLanguage(). In particular, for case xbmc.ISO_639_2 with region=True and xbmc.ENGLISH_NAME with region=True what exactly should be returned? |
Bug report
Describe the bug
Here is a clear and concise description of what the problem is:
The python function from xbmc, xbmc.getLanguage(xbmc.ISO_639_1) returns an empty string when the Kodi GUI language is set to one of the "compound" languages, for example English(US), English(AU), French(CA). The nominal language version, English or French return "en" or "fr" as expected. Also, xbmc.ISO_639_2 and xbmc.ENGLISH_NAME return the expected results. Went back and it has been like this since at least matrix.
Expected Behavior
Here is a clear and concise description of what was expected to happen:
GUI language such as English (US) should return the proper 2-char ISO code, "en".
Actual Behavior
function returns an empty string
Possible Fix
Haven't had time to run Kodi in a debugger to examine more fully.
To Reproduce
Steps to reproduce the behavior:
Debuglog
The debuglog can be found here:
https://paste.kodi.tv/usejafariq.kodi
In this log I installed a simple program script to exercise the function. First with default resource.language.en_gb in use, then installing and switching to resource.language.en_us and repeating.
Screenshots
Here are some links or screenshots to help explain the problem:
Additional context or screenshots (if appropriate)
Here is some additional context or explanation that might help:
Discovered looking at user forum issue that script.tv.show.next.aired 8.0.4 doesn't work. Function is used in dependency script.module.thetvdb and when run was throwing exception.
Your Environment
Used Operating system:
Android
iOS
tvOS
Linux
macOS
Windows
Windows UWP
Operating system version/name: Win 10 x64 22H2
Kodi version: Windows x64 desktop 22 nightly Git:20240318-40c09d0c93
note: Once the issue is made we require you to update it with new information or Kodi versions should that be required.
Team Kodi will consider your problem report however, we will not make any promises the problem will be solved.
The text was updated successfully, but these errors were encountered: