ScriptCollection 4.2.57__py3-none-any.whl → 4.2.58__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -36,7 +36,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
36
36
  from .ProgramRunnerPopen import ProgramRunnerPopen
37
37
  from .SCLog import SCLog, LogLevel
38
38
 
39
- version = "4.2.57"
39
+ version = "4.2.58"
40
40
  __version__ = version
41
41
 
42
42
  class VSCodeWorkspaceShellTask:
@@ -3123,6 +3123,7 @@ OCR-content:
3123
3123
  #sync existing files
3124
3124
  self.__sync_xlf2_files(base_file_xml, language_files_with_content)
3125
3125
 
3126
+
3126
3127
  @GeneralUtilities.check_arguments
3127
3128
  def translate_xlf_files_in_folder(self, folder: str, base_language: str, libre_translate_api_server: str):
3128
3129
  """Translates all .xlf files directly in the given folder (non-recursive)."""
@@ -157,7 +157,7 @@ class TFCPS_CodeUnitSpecific_NodeJS_Functions(TFCPS_CodeUnitSpecific_Base):
157
157
  @GeneralUtilities.check_arguments
158
158
  def get_available_cultures_for_angular_app(self)->None:
159
159
  return self._protected_sc.get_available_cultures_for_angular_app(self.get_codeunit_folder()+"/angular.json")
160
-
160
+
161
161
  @GeneralUtilities.check_arguments
162
162
  def __ensure_translations_exist(self,languages:list[str])->None:
163
163
  base_file=os.path.join(self.get_codeunit_folder(),"Other","Resources","Translations",f"messages.xlf")
@@ -166,7 +166,6 @@ class TFCPS_CodeUnitSpecific_NodeJS_Functions(TFCPS_CodeUnitSpecific_Base):
166
166
  if not os.path.isfile(target_file):
167
167
  GeneralUtilities.ensure_file_exists(target_file)
168
168
  GeneralUtilities.write_text_to_file(target_file, GeneralUtilities.read_text_from_file(base_file))
169
-
170
169
  #set new attribute
171
170
  tree = ET.parse(target_file)
172
171
  root = tree.getroot()
@@ -197,12 +196,22 @@ class TFCPS_CodeUnitSpecific_NodeJS_Functions(TFCPS_CodeUnitSpecific_Base):
197
196
  self._protected_sc.sync_xlf2_files("messages",languages,os.path.join(self.get_codeunit_folder(),"Other","Resources","Translations"))
198
197
 
199
198
  @GeneralUtilities.check_arguments
200
- def translate_safe(self)->None:
201
- pass#TODO if ~/.ScriptCollection/TranslationService.txt exists: use this and call translate(...)
202
-
199
+ def translate_safe(self,base_language:str="en")->None:
200
+ """Translates XLF files if a translation service is configured. The translation service can be configured by creating a file at ~/.ScriptCollection/TranslationServiceProperties.txt with the content 'LibreTranslateAPI=your_api_server_url'."""
201
+ translationservice_file:str=self._protected_sc.get_global_cache_folder()+"/TranslationServiceProperties.txt"
202
+ api_server:str=None
203
+ if os.path.isfile(translationservice_file):
204
+ lines=GeneralUtilities.read_nonempty_lines_from_file(translationservice_file)
205
+ for line in lines:
206
+ if line.startswith("LibreTranslateAPI="):
207
+ api_server=line.replace("LibreTranslateAPI=","").strip()
208
+ GeneralUtilities.assert_not_null(api_server,"No translation service configured. Please create a file at ~/.ScriptCollection/TranslationServiceProperties.txt with the content 'LibreTranslateAPI=your_api_server_url' to enable automatic translation of XLF files.")
209
+ self.translate(api_server,base_language)
210
+
203
211
  @GeneralUtilities.check_arguments
204
- def translate(self,api_server:str)->None:
205
- pass#TODO if Other/Resources/Translations exists: call sc.translate_messages_in_folder(...)
212
+ def translate(self,api_server:str,base_language:str="en")->None:
213
+ folder:str=os.path.join(self.get_codeunit_folder(),"Other","Resources","Translations")
214
+ self._protected_sc.translate_xlf_files_in_folder(folder, base_language, api_server)
206
215
 
207
216
  class TFCPS_CodeUnitSpecific_NodeJS_CLI:
208
217
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ScriptCollection
3
- Version: 4.2.57
3
+ Version: 4.2.58
4
4
  Summary: The ScriptCollection is the place for reusable scripts.
5
5
  Home-page: https://github.com/anionDev/ScriptCollection
6
6
  Author: Marius Göcke
@@ -9,7 +9,7 @@ ScriptCollection/ProgramRunnerMock.py,sha256=uTu-aFle1W_oKjeQEmuPsFPQpvo0kRf2FrR
9
9
  ScriptCollection/ProgramRunnerPopen.py,sha256=BPY7-ZMIlqT7JOKz8qlB5c0laF2Js-ijzqk09GxZC48,3821
10
10
  ScriptCollection/ProgramRunnerSudo.py,sha256=_khC3xuTdrPoLluBJZWfldltmmuKltABJPcbjZSFW-4,4835
11
11
  ScriptCollection/SCLog.py,sha256=8TRy1LeYMsPOIuWUcnUNNbO5pd-cNBS-3cn-kdzP8FU,4768
12
- ScriptCollection/ScriptCollectionCore.py,sha256=jjGd7cbFB-FpsXsymVoFcF_M9wXIZ2AIttcRfiXl8IU,174895
12
+ ScriptCollection/ScriptCollectionCore.py,sha256=c-wSuEa8_T_-GC-iE3fNO7Yr7gB92b4R1zAwQN2-QSM,174896
13
13
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  ScriptCollection/OCIImages/AbstractImageHandler.py,sha256=83qDMILwxhH9DbC0sb358Vu8PXEysmJJyap_6gECZqs,1627
15
15
  ScriptCollection/OCIImages/OCIImageManager.py,sha256=aBogkSXNDyi8NO11N-s03nuFJEv7PyJ-wjHuYYeZfvs,6662
@@ -43,12 +43,12 @@ ScriptCollection/TFCPS/Flutter/TFCPS_CodeUnitSpecific_Flutter.py,sha256=U8oBAOLR
43
43
  ScriptCollection/TFCPS/Flutter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
44
  ScriptCollection/TFCPS/Go/TFCPS_CodeUnitSpecific_Go.py,sha256=kyx26AnT1-LySFA46wfJ9yZUKYdMWTD0U2XZfSQbuB0,3497
45
45
  ScriptCollection/TFCPS/Go/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
- ScriptCollection/TFCPS/NodeJS/TFCPS_CodeUnitSpecific_NodeJS.py,sha256=Kkyyof6DML7jUdES5GmIXQ_yVMJ1xnJbZmbIAqls3IE,11816
46
+ ScriptCollection/TFCPS/NodeJS/TFCPS_CodeUnitSpecific_NodeJS.py,sha256=kL37qJNwH6E-CAJqcHbdnc0K0uGjHQ8XD1RXZOdcw1M,12850
47
47
  ScriptCollection/TFCPS/NodeJS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
48
  ScriptCollection/TFCPS/Python/TFCPS_CodeUnitSpecific_Python.py,sha256=nLw_eSUd_56jjgfcAvtUyzecSZ14mYmNJl0iu-1YNVk,13496
49
49
  ScriptCollection/TFCPS/Python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
- scriptcollection-4.2.57.dist-info/METADATA,sha256=iMa7-_9uZdnhT-dv-aA7iTfCkOk5d8-Os0jqzuyFT1Y,7690
51
- scriptcollection-4.2.57.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
52
- scriptcollection-4.2.57.dist-info/entry_points.txt,sha256=27XwAJEcaMEc1be0Ec1vKHCbiU4Ziu8jKL-SqsrYOIQ,4680
53
- scriptcollection-4.2.57.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
54
- scriptcollection-4.2.57.dist-info/RECORD,,
50
+ scriptcollection-4.2.58.dist-info/METADATA,sha256=Lm4CyXwLiuq4Qr6srolxs5gr6CRuojWuzOeD9x0qonY,7690
51
+ scriptcollection-4.2.58.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
52
+ scriptcollection-4.2.58.dist-info/entry_points.txt,sha256=27XwAJEcaMEc1be0Ec1vKHCbiU4Ziu8jKL-SqsrYOIQ,4680
53
+ scriptcollection-4.2.58.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
54
+ scriptcollection-4.2.58.dist-info/RECORD,,