summaryrefslogtreecommitdiff
path: root/wizards/source/scriptforge/SF_Services.xba
diff options
context:
space:
mode:
Diffstat (limited to 'wizards/source/scriptforge/SF_Services.xba')
-rw-r--r--wizards/source/scriptforge/SF_Services.xba28
1 files changed, 25 insertions, 3 deletions
diff --git a/wizards/source/scriptforge/SF_Services.xba b/wizards/source/scriptforge/SF_Services.xba
index c6910aea5e50..b2932553d919 100644
--- a/wizards/source/scriptforge/SF_Services.xba
+++ b/wizards/source/scriptforge/SF_Services.xba
@@ -521,16 +521,20 @@ Public Function _NewL10N(Optional ByVal pvArgs As Variant) As Variant
''' Use one of the Names listed in https://www.iana.org/assignments/character-sets/character-sets.xhtml
''' Note that LibreOffice probably does not implement all existing sets
''' Default = UTF-8
+''' Locale2: fallback Locale to select if Locale po file does not exist (typically "en-US")
+''' Encoding2: Encoding of the 2nd Locale file
''' Returns: the instance or Nothing
''' Exceptions:
''' UNKNOWNFILEERROR The PO file does not exist
Dim oL10N As Variant ' Return value
Dim sFolderName As String ' Folder containing the PO files
-Dim sLocale As String ' Passed argument or that of the user session
+Dim sLocale As String ' Passed argument or that of the user session
+Dim sLocale2 As String ' Alias for Locale2
Dim oLocale As Variant ' com.sun.star.lang.Locale
Dim sPOFile As String ' PO file must exist
Dim sEncoding As String ' Alias for Encoding
+Dim sEncoding2 As String ' Alias for Encoding2
If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
@@ -547,18 +551,36 @@ Check:
sLocale = pvArgs(1)
End If
If Len(sLocale) = 0 Then ' Called from Python, the Locale argument may be the zero-length string
- Set oLocale = SF_Utils._GetUNOService("SystemLocale")
+ Set oLocale = SF_Utils._GetUNOService("OfficeLocale")
sLocale = oLocale.Language & "-" & oLocale.Country
End If
If UBound(pvArgs) >= 2 Then
+ If IsMissing(pvArgs(2)) Or IsEmpty(pvArgs(2)) Then pvArgs(2) = "UTF-8"
If Not SF_Utils._Validate(pvArgs(2), "Encoding (Arg2)", V_STRING) Then GoTo Catch
sEncoding = pvArgs(2)
Else
sEncoding = "UTF-8"
End If
+ sLocale2 = ""
+ If UBound(pvArgs) >= 3 Then
+ If Not SF_Utils._Validate(pvArgs(3), "Locale2 (Arg3)", V_STRING) Then GoTo Catch
+ sLocale2 = pvArgs(3)
+ End If
+ If UBound(pvArgs) >= 4 Then
+ If Not SF_Utils._Validate(pvArgs(4), "Encoding2 (Arg4)", V_STRING) Then GoTo Catch
+ sEncoding2 = pvArgs(4)
+ Else
+ sEncoding2 = "UTF-8"
+ End If
If Len(sFolderName) > 0 Then
sPOFile = SF_FileSystem.BuildPath(sFolderName, sLocale & ".po")
- If Not SF_FileSystem.FileExists(sPOFile) Then GoTo CatchNotExists
+ If Not SF_FileSystem.FileExists(sPOFile) Then
+ If Len(sLocale2) = 0 Then GoTo CatchNotExists ' No fallback => error
+ ' Try the fallback
+ sPOFile = SF_FileSystem.BuildPath(sFolderName, sLocale2 & ".po")
+ If Not SF_FileSystem.FileExists(sPOFile) Then GoTo CatchNotExists
+ sEncoding = sEncoding2
+ End If
End If
End If