wizards/source/scriptforge/SF_Root.xba  |   10 +++++++---
 wizards/source/scriptforge/SF_Utils.xba |    5 +++++
 2 files changed, 12 insertions(+), 3 deletions(-)

New commits:
commit 7e834362a868979e8d703ff61bc22772b671e678
Author:     Jean-Pierre Ledure <j...@ledure.be>
AuthorDate: Tue Mar 8 15:53:37 2022 +0100
Commit:     Jean-Pierre Ledure <j...@ledure.be>
CommitDate: Tue Mar 8 19:53:14 2022 +0100

    ScriptForge - 'SF_Root) load user interface from code when locale=en
    
    The user interface is loaded in the user's language
    at the first use of Scriptforge during the LO session.
    
    So far the labels were always loaded from the relevant
    .po file.
    Now they are loaded in memory by code when the user's
    language = "en".
    
    Objective = gain in performance.
    
    Additionally the default language is set to
       SF_Platform.OfficeLocale
    i.o.
       SF_Platform.SystemLocale
    
    Internal change, no impact on documentation
    
    Change-Id: Ia0d1235f8ca6a42141a5481fe80b5bec1d53a7e3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131214
    Tested-by: Jean-Pierre Ledure <j...@ledure.be>
    Tested-by: Jenkins
    Reviewed-by: Jean-Pierre Ledure <j...@ledure.be>

diff --git a/wizards/source/scriptforge/SF_Root.xba 
b/wizards/source/scriptforge/SF_Root.xba
index 46cdec9f7ea5..d7c4cc639737 100644
--- a/wizards/source/scriptforge/SF_Root.xba
+++ b/wizards/source/scriptforge/SF_Root.xba
@@ -61,6 +61,7 @@ Private SearchOptions         As Object       &apos; 
com.sun.star.util.SearchOptions
 Private SystemLocale           As Object       &apos; com.sun.star.lang.Locale
 Private OfficeLocale           As Object       &apos; com.sun.star.lang.Locale
 Private FormatLocale           As Object       &apos; com.sun.star.lang.Locale
+Private LocaleData                     As Object       &apos; 
com.sun.star.i18n.LocaleData
 Private PrinterServer          As Object       &apos; 
com.sun.star.awt.PrinterServer
 Private CharacterClass         As Object       &apos; 
com.sun.star.i18n.CharacterClassification
 Private FileAccess                     As Object       &apos; 
com.sun.star.ucb.SimpleFileAccess
@@ -121,9 +122,10 @@ Private Sub Class_Initialize()
        Set DispatchHelper = Nothing
        Set TextSearch = Nothing
        Set SearchOptions = Nothing
+       Set SystemLocale = Nothing
        Set OfficeLocale = Nothing
        Set FormatLocale = Nothing
-       Set SystemLocale = Nothing
+       Set LocaleData = Nothing
        Set PrinterServer = Nothing
        Set CharacterClass = Nothing
        Set FileAccess = Nothing
@@ -289,10 +291,12 @@ Try:
                &apos;  Build the po file name
                With SF_FileSystem
                        sInstallFolder = ._SFInstallFolder()    &apos;  
ScriptForge installation folder
-                       sLocale = 
SF_Utils._GetUNOService(&quot;SystemLocale&quot;).Language
+                       sLocale = 
SF_Utils._GetUNOService(&quot;OfficeLocale&quot;).Language
                        sPOFolder = .BuildPath(sInstallFolder, &quot;po&quot;)
                        sPOFile = .BuildPath(sPOFolder, sLocale &amp; 
&quot;.po&quot;)
-                       If Not .FileExists(sPOFile) Then        &apos;  File 
not found =&gt; load texts from code below
+                       If sLocale = &quot;en&quot; Then                        
                &apos;  Interface loaded by code i.o. read from po file
+                               psMode = &quot;ADDTEXT&quot;
+                       ElseIf Not .FileExists(sPOFile) Then    &apos;  File 
not found =&gt; load texts from code below
                                psMode = &quot;ADDTEXT&quot;
                        Else
                                Set Interface = 
CreateScriptService(&quot;L10N&quot;, sPOFolder, sLocale)
diff --git a/wizards/source/scriptforge/SF_Utils.xba 
b/wizards/source/scriptforge/SF_Utils.xba
index a6a4f49abe4d..28aed74fa19f 100644
--- a/wizards/source/scriptforge/SF_Utils.xba
+++ b/wizards/source/scriptforge/SF_Utils.xba
@@ -393,6 +393,11 @@ Dim oDefaultContext As Object
                                        Set .Introspection = 
CreateUnoService(&quot;com.sun.star.beans.Introspection&quot;)
                                End If
                                Set _GetUNOService = .Introspection
+                       Case &quot;LocaleData&quot;
+                               If IsEmpty(.LocaleData) Or IsNull(.LocaleData) 
Then
+                                       Set .LocaleData = 
CreateUnoService(&quot;com.sun.star.i18n.LocaleData&quot;)
+                               End If
+                               Set _GetUNOService = .LocaleData
                        Case &quot;MacroExpander&quot;
                                Set oDefaultContext = GetDefaultContext()
                                If Not IsNull(oDefaultContext) Then Set 
_GetUNOService = 
oDefaultContext.getValueByName(&quot;/singletons/com.sun.star.util.theMacroExpander&quot;)

Reply via email to