Kodi Community Forum

Full Version: Script to display Regional Settings
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Good day everyone,

Happy holidays to you all! I am trying to display the regional settings through scripting so that when I click on it, the regional changes. So far I have this code, it was barrowed from script that brings up the language settings. Only issue is that when I click on region, it does not change in Kodi settings. Can someone please assist? :
python:
import time, xbmc
import xbmcaddon
import xbmcgui
import xbmcplugin

ADDON_ID = 'script.region'
ADDON = xbmcaddon.Addon()
T = xbmc.getRegion()
wel = T(30703)
sel_lang = T(30704)

full_language_array = [  'Australia(12h)','Australia(24h)','Canada','Central Europe','India(12h)','India(24h)','UK(12h)','UK(24)','USA(12h)','USA(24h)']

def doLanguageListing():
    window = KodiRegionalListing('region-set.xml',ADDON.getAddonInfo('path'),'Default','720p')
    window.doModal()
    del window

class KodiRegionalListing(xbmcgui.WindowXMLDialog):
    def onInit(self):
        self.setProperty("WEL",wel)
        self.setProperty("SEL_LANG",sel_lang)
        self.ctrl = self.getControl(101)
        item = []
        for lang in full_language_array:
            list_lang = xbmcgui.ListItem(label=lang)
            item.append(list_lang)
        self.ctrl.reset()
        self.ctrl.addItems(item)
        self.setFocusId(101)

    def onClick(self, controlID):
        self.setProperty("loader","2")
        xbmc.sleep(1000)
        select_lang = self.ctrl.getSelectedItem().getLabel()
        xbmc.executebuiltin('getRegion(%s)' % select_lang)
        xbmc.executebuiltin('Skin.SetString(Regionset,true)')
        self.close()

    def onAction(self, action):
        pass


   
Image
In case not very clear, this is the information I am trying to display through script
you'd likely need to use json-rpc to alter the setting.
https://kodi.wiki/view/JSON-RPC_API/v9#S...ttingValue
(2018-12-30, 15:26)ronie Wrote: [ -> ]you'd likely need to use json-rpc to alter the setting.
https://kodi.wiki/view/JSON-RPC_API/v9#S...ttingValue
 Thanks for the tip! Can this be done through skin or use script? Can you please provide example on how to do this?

Thanks again
it's not something that can be done through skinning, so you'd have to create an addon for it.

the json command should be something like this (not tested):
{"jsonrpc": "2.0", "method": "Settings.SetSettingValue", "params": {"setting": "locale.country", "value": "USA (12h)"}, "id": 1}


the thing i don't know is if kodi will apply the new setting right away or if a reload / restart is required.
(2019-01-09, 21:41)ronie Wrote: [ -> ]it's not something that can be done through skinning, so you'd have to create an addon for it.

the json command should be something like this (not tested):
{"jsonrpc": "2.0", "method": "Settings.SetSettingValue", "params": {"setting": "locale.country", "value": "USA (12h)"}, "id": 1}


the thing i don't know is if kodi will apply the new setting right away or if a reload / restart is required.
I will give a try. Thank you