From 1f842e3aa07af26776a8583e5b0ed1bdb178af9b Mon Sep 17 00:00:00 2001 From: Jean-Pierre Ledure Date: Tue, 9 Mar 2021 17:08:18 +0100 Subject: ScriptForge - (scriptforge.py) L10N class Addition of SF_L10N class Correction in Languages() property: selection of file based on *.po filter i.o. ??-??.po Change-Id: I5c57d1973265f2aeb7a3cfb4f507ffd50a28785a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112211 Tested-by: Jean-Pierre Ledure Tested-by: Jenkins Reviewed-by: Jean-Pierre Ledure --- wizards/source/scriptforge/SF_L10N.xba | 2 +- wizards/source/scriptforge/python/scriptforge.py | 29 +++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'wizards') diff --git a/wizards/source/scriptforge/SF_L10N.xba b/wizards/source/scriptforge/SF_L10N.xba index 8f526388d4c7..ced25a25bc78 100644 --- a/wizards/source/scriptforge/SF_L10N.xba +++ b/wizards/source/scriptforge/SF_L10N.xba @@ -661,7 +661,7 @@ Dim cstSubArgs As String If Len(_POFolder) > 0 Then _PropertyGet = ._ConvertFromUrl(_POFolder) Else _PropertyGet = "" Case "Languages" If Len(_POFolder) > 0 Then - vFiles = .Files(._ConvertFromUrl(_POFolder), "??-??.po") + vFiles = .Files(._ConvertFromUrl(_POFolder), "*.po") For i = 0 To UBound(vFiles) vFiles(i) = SF_FileSystem.GetBaseName(vFiles(i)) Next i diff --git a/wizards/source/scriptforge/python/scriptforge.py b/wizards/source/scriptforge/python/scriptforge.py index a131329308bb..7547367d3ed6 100644 --- a/wizards/source/scriptforge/python/scriptforge.py +++ b/wizards/source/scriptforge/python/scriptforge.py @@ -681,6 +681,33 @@ class SFScriptForge: # Alias for same function in FileSystem Basic module return self.SIMPLEEXEC('ScriptForge.SF_FileSystem._ConvertFromUrl', filename) + # ######################################################################### + # SF_L10N CLASS + # ######################################################################### + class SF_L10N(SFServices): + """ + This service provides a number of methods related to the translation of strings + with minimal impact on the program's source code. + The methods provided by the L10N service can be used mainly to: + Create POT files that can be used as templates for translation of all strings in the program. + Get translated strings at runtime for the language defined in the Locale property. + """ + # Mandatory class properties for service registration + serviceimplementation = 'basic' + servicename = 'ScriptForge.L10N' + serviceProperties = dict(Folder = False, Languages = False, Locale = False) + + def AddText(self, context = '', msgid = '', comment = ''): + return self.Execute(self.vbMethod, 'AddText', context, msgid, context) + + def ExportToPOTFile(self, filename, header = '', encoding= 'UTF-8'): + return self.Execute(self.vbMethod, 'ExportToPOTFile', filename, header, encoding) + + def GetText(self, msgid, *args): + return self.Execute(self.vbMethod, 'GetText', msgid, *args) + + _ = GetText + # ######################################################################### # SF_TextStream CLASS # ######################################################################### @@ -727,7 +754,7 @@ class SFScriptForge: # ######################################################################### class SF_Timer(SFServices): """ - The "Timer" service measures the amount of time it takes to run user scripts.. + The "Timer" service measures the amount of time it takes to run user scripts. """ # Mandatory class properties for service registration serviceimplementation = 'basic' -- cgit