Hi all. I use uno api for python and need to change UI language dynamically.
I use the following code:
import uno
local_context = uno.getComponentContext()
resolver = local_context.ServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", local_context)
remote_context = resolver.resolve(connection_url) #my url here
service_manager = self.remote_context.getServiceManager()
desktop = service_manager.createInstanceWithContext(
"com.sun.star.frame.Desktop", remote_context)
# set needed UI language
nodepath_prop = uno.createUnoStruct("com.sun.star.beans.PropertyValue")
nodepath_prop.Name = "nodepath"
nodepath_prop.Value = "org.openoffice.Office.Linguistic/General"
enableasync_prop = uno.createUnoStruct(
"com.sun.star.beans.PropertyValue")
enableasync_prop.Name = "enableasync"
enableasync_prop.Value = True
config = service_manager.createInstanceWithContext(
"com.sun.star.configuration.ConfigurationProvider",
remote_context)
current_prop_state = config.createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationUpdateAccess",
(nodepath_prop, enableasync_prop))
current_value = current_prop_state.getPropertyValue("UILocale")
if current_value != "ru":
current_prop_state.replaceByName("UILocale", "ru")
current_prop_state.commitChanges()
config.flush()
document = desktop.loadComponentFromURL('private:factory/scalc', '_blank', 0, ())
But when document is open language is still not changed in UI (but changed in options, see screenshot)
How can I force Calc document to use options for UI via python code?
Note: when I restart Libre manually, language is applied correctly