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
xbmc.getLanguage() remediation to provide correct Language & Region information. #23110
base: master
Are you sure you want to change the base?
Conversation
b1bdd0d
to
46514f4
Compare
Changes applied. |
@CastagnaIT - Thanks for your valuable feedback. Do you have any comments on the logic or method applied to remediate this bug? |
06b91ae
to
b4da8ba
Compare
@CastagnaIT - Are you awaiting any input or action from me? I'm still learning how the PR process works. |
PR process guidelines are here: https://github.com/xbmc/xbmc/blob/master/docs/CONTRIBUTING.md#pull-request-merge-guidelines i dont have so much time lately and im currently involved on another repository so i can't give you a timing |
@CastagnaIT - Thank your for your response. My main concern was that I was meant to do something that I was unaware of. I will wait until you have some free time. |
b4da8ba
to
dc08041
Compare
dc08041
to
924713d
Compare
Done |
I would like to attempt to get this PR moving with a suggestion. My understanding is that the main issue blocking this PR is finding a resource with expertise in this area of the code in order to perform a review. In the absence of such a resource, I would like to suggest that once v22 “P” is open for development, this PR is merged into the master branch. This will see the change added to the ‘Nightly Development Builds’. Any severe issues should become apparent relatively quickly. Although the first strategy would be remediation, at any point, the PR could be rolled-back should it be shown to be the source of any new instability. Once it has passed the nightly builds, the ‘Pre release Builds’ should also ensure that no addons or other user features are adversely impacted. |
Are there any other comments regarding my suggestion to merge this PR so that it can be evaluated via the nightly builds? |
Sorry, just now saw this. I will have to spend some time on this, but currently xbmc.getLanguage() with region = True returns the locale, not the language code. Which I think the user of this function would rather get the actual language code and use a different function for locale. But that's just IMHO. So for example, if the active language resource is resource.language.en_gb would expect to get "en-gb" returned for the 639 2-alpha with region, not something like en-de which currently is possible. |
@scott967 - Thanks for your interest. For some additional background on this issue: I created a thread on the forum about a year ago addressing the underlying cause of this issue. https://forum.kodi.tv/showthread.php?tid=372626 The accuracy of the values that the xbmc.getLanguage() function currently returns depends on how well-formed the text descriptions in selected language addon are. |
I picked the commit on top of master and from quick testing seemed to fix getting the language code 2 or 3 alpha, which I had a "band-aid" fix for, but ISO_NAME didn't work and it seemed like it didn't build correctly on my system. So went back and tried to create a clean build environment but managed to kill my buildsteps chain somehow, so ATM can't do more testing. |
@scott967 - I noticed that for PR#25062, you tested on Windows 10. Did you also build this PR on Win10? I seem to recall that in the code there are a number of |
Yes, VS2022 on Win10. But I build using kodi.sln generated by cmake and run the code in VS debugger |
Description
The CLangCodeExpander class has been expanded to include new ISO 3166-1 (Country Code) lookup capabilities for Alpha-2, Alpha-3 and Name.
CLangInfo::Load and CLangInfo::SetCurrentRegion have been modified to perform additional lookups (ISO_639_X [language] and ISO 3166-1 [country]) as the langinfo.xml file is loaded with the results being stored as new properties of their respective objects. New getter methods were added to obtain these new property values.
GetLanguageConfigCode()
GetLanguageISO6391()
GetLanguageISO6392()
GetLanguageISOEnglishName()
GetCurrentRegionISO31661Alpha2()
GetCurrentRegionISO31661Alpha3()
GetCurrentRegionISO31661EnglishName()
xbmc.getLanguage() has been updated as follows:
xbmc.getLanguage(ENGLISH_NAME) - Remains unchanged for backwards compatibility.
xbmc.getLanguage(ISO_639_1) - Updated to return values based on the 'locale' properties in the langinfo.xml file. An ISO_639_2 value is returned where an ISO_639_1 does not exist for a language.
xbmc.getLanguage(ISO_639_2) - Updated to return values based on the 'locale' properties in the langinfo.xml file. The 'locale' properties in the langinfo.xml file are used to return the ISO_639_2 and ISO 3166-1 alpha-3 codes.
xbmc.getLanguage(ISO_NAME) - Added to return the 'clean' names for the language and regions based on a lookup table using the 'locale' properties in the langinfo.xml file.
For example: 'English-Australia' instead of 'English (Australia) - Australia (24h)'
Motivation and context
Provide correct language information to addons.
#22715
How has this been tested?
Custom addon used to assess the returned values for a number of language and region combinations.
Log extract BEFORE:
xbmc.getLanguage(xbmc.ENGLISH_NAME, True) = English (Australia)-Australia (24h)
xbmc.getLanguage(xbmc.ENGLISH_NAME, False) = English (Australia)
xbmc.getLanguage(xbmc.ISO_639_2, True) = en-au-
xbmc.getLanguage(xbmc.ISO_639_2, False) = en-au
xbmc.getLanguage(xbmc.ISO_639_1, True) = -
xbmc.getLanguage(xbmc.ISO_639_1, False) =
Log extract AFTER:
xbmc.getLanguage(xbmc.ENGLISH_NAME, True) = English (Australia)-Australia (24h)
xbmc.getLanguage(xbmc.ENGLISH_NAME, False) = English (Australia)
xbmc.getLanguage(xbmc.ISO_639_2, True) = eng-AUS
xbmc.getLanguage(xbmc.ISO_639_2, False) = eng
xbmc.getLanguage(xbmc.ISO_639_1, True) = en-AU
xbmc.getLanguage(xbmc.ISO_639_1, False) = en
xbmc.getLanguage(xbmc.ISO_NAME, False) = English
xbmc.getLanguage(xbmc.ISO_NAME, True) = English-Australia
Language with ISO_639_2 only:
BEFORE:
xbmc.getLanguage(xbmc.ENGLISH_NAME, True) = Filipino (Talagog)-Philippines (12h)
xbmc.getLanguage(xbmc.ENGLISH_NAME, False) = Filipino (Talagog)
xbmc.getLanguage(xbmc.ISO_639_2, True) = fil-
xbmc.getLanguage(xbmc.ISO_639_2, False) = fil
xbmc.getLanguage(xbmc.ISO_639_1, True) = -
xbmc.getLanguage(xbmc.ISO_639_1, False) =
AFTER:
xbmc.getLanguage(xbmc.ENGLISH_NAME, True) = Filipino (Talagog)-Philippines (12h)
xbmc.getLanguage(xbmc.ENGLISH_NAME, False) = Filipino (Talagog)
xbmc.getLanguage(xbmc.ISO_639_2, True) = fil-PHL
xbmc.getLanguage(xbmc.ISO_639_2, False) = fil
xbmc.getLanguage(xbmc.ISO_639_1, True) = fil-PH
xbmc.getLanguage(xbmc.ISO_639_1, False) = fil
xbmc.getLanguage(xbmc.ISO_NAME, False) = Filipino
xbmc.getLanguage(xbmc.ISO_NAME, True) = Filipino-Philippines
What is the effect on users?
Standard Kodi users should see no change to the UI. Python add-on developers will now be able to obtain the correct language and region codes and names.
Screenshots (if appropriate):
Types of change
Checklist: