Search the Community
Showing results for tags 'Crowdin'.
-
Today I want to present my current project. This is UDF for crowdin.net website API In fact, not yet finished but functional. #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 #Tidy_Parameters=/sort_funcs /reel #include <FileConstants.au3> #include <MsgBoxConstants.au3> _Crowdin_Example_1() Func _Crowdin_Example_1() Local $sACCOUNT_API_KEY = '...' Local $sPROJECT_API_KEY = '...' Local $sPROJECT_identifier = '...' Local $output = '' _Crowdin_Project_Identifier($sPROJECT_identifier) _Crowdin_Project_ApiKey($sPROJECT_API_KEY) _Crowdin_AccountKey($sACCOUNT_API_KEY) $output = _Crowdin_DirectoryCreate('Directory for testing CrowdinAPI') MsgBox(0, '_Crowdin_DirectoryCreate', $output) Exit $output = _Crowdin_GetProjectInfo() MsgBox(0, '_Crowdin_GetProjectInfo', $output) $output = _Crowdin_GetSupportedLanguages() MsgBox(0, '_Crowdin_GetSupportedLanguages', $output) $output = _Crowdin_TranslationExport() MsgBox(0, '_Crowdin_TranslationExport', $output) $output = _Crowdin_TranslationStatus() MsgBox(0, '_Crowdin_TranslationStatus', $output) $output = _Crowdin_TranslationDownload('all', @ScriptDir & '\Crowdin_test_DownloadTranslations.zip') $output = _Crowdin_GetProjects('mLipok') MsgBox(0, '_Crowdin_GetProjects', $output) $output = _Crowdin_DirectoryCreate('Directory for testing CrowdinAPI') MsgBox(0, '_Crowdin_DirectoryCreate', $output) ;~ $output = ;~ MsgBox(0, '', $output) EndFunc ;==>_Crowdin_Example_1 #Region CrowdinAPI - Functions ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Crowdin_GetProjectInfo ; Description ...: Get Crowdin Project details. ; Syntax ........: _Crowdin_GetProjectInfo() ; Parameters ....: ; Return values .: None ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Crowdin_GetProjectInfo() Local $sURL = 'https://api.crowdin.com/api/project/' & _Crowdin_Project_Identifier() & '/info?key=' & _Crowdin_Project_ApiKey() ConsoleWrite('! ' & $sURL & @CRLF) Local $oXmlHttp = ObjCreate("Microsoft.XMLHTTP") $oXmlHttp.Open('POST', $sURL, False) $oXmlHttp.Send() Local $output = $oXmlHttp.ResponseText $oXmlHttp = '' Return $output EndFunc ;==>_Crowdin_GetProjectInfo ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Crowdin_GetSupportedLanguages ; Description ...: ; Syntax ........: _Crowdin_GetSupportedLanguages() ; Parameters ....: ; Return values .: None ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Crowdin_GetSupportedLanguages() Local $sURL = 'https://api.crowdin.com/api/supported-languages' ConsoleWrite('! ' & $sURL & @CRLF) Local $oXmlHttp = ObjCreate("Microsoft.XMLHTTP") $oXmlHttp.Open('GET', $sURL, False) $oXmlHttp.Send() Local $output = $oXmlHttp.ResponseText $oXmlHttp = '' Return $output EndFunc ;==>_Crowdin_GetSupportedLanguages ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Crowdin_TranslationExport ; Description ...: ; Syntax ........: _Crowdin_TranslationExport() ; Parameters ....: ; Return values .: None ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Crowdin_TranslationExport() Local $sURL = 'https://api.crowdin.com/api/project/' & _Crowdin_Project_Identifier() & '/export?key=' & _Crowdin_Project_ApiKey() ConsoleWrite('! ' & $sURL & @CRLF) Local $oXmlHttp = ObjCreate("Microsoft.XMLHTTP") $oXmlHttp.Open('GET', $sURL, False) $oXmlHttp.Send() Local $output = $oXmlHttp.ResponseText $oXmlHttp = '' Return $output EndFunc ;==>_Crowdin_TranslationExport ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Crowdin_TranslationStatus ; Description ...: Track your Crowdin project translation progress by language. Default response format is XML. ; Syntax ........: _Crowdin_TranslationStatus() ; Parameters ....: ; Return values .: None ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://crowdin.com/page/api/status ; Example .......: No ; =============================================================================================================================== Func _Crowdin_TranslationStatus() Local $sURL = 'https://api.crowdin.com/api/project/' & _Crowdin_Project_Identifier() & '/status?key=' & _Crowdin_Project_ApiKey() ConsoleWrite('! ' & $sURL & @CRLF) Local $oXmlHttp = ObjCreate("Microsoft.XMLHTTP") $oXmlHttp.Open('POST', $sURL, False) $oXmlHttp.Send() Local $output = $oXmlHttp.ResponseText $oXmlHttp = '' Return $output EndFunc ;==>_Crowdin_TranslationExport ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Crowdin_TranslationDownload ; Description ...: Download ZIP file with translations. You can choose the language of translation you need or download all of them at once. ; Syntax ........: _Crowdin_TranslationDownload([$sPackage = 'all'[, $sZIP_FileFullPath = '']]) ; Parameters ....: $sPackage - [optional] a string value. Default is 'all'. ; $sZIP_FileFullPath - [optional] a string value. Default is ''. ; Return values .: None ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://crowdin.com/page/api/download ; Example .......: No ; =============================================================================================================================== Func _Crowdin_TranslationDownload($sPackage = 'all', $sZIP_FileFullPath = '') ; GET https://api.crowdin.com/api/project/{project-identifier}/download/{package}.zip?key={project-key} Local $sURL = 'https://api.crowdin.com/api/project/' & _Crowdin_Project_Identifier() & '/download/' & $sPackage & '.zip?key=' & _Crowdin_Project_ApiKey() ConsoleWrite('! ' & $sURL & @CRLF) Local $oXmlHttp = ObjCreate("Microsoft.XMLHTTP") $oXmlHttp.Open('GET', $sURL, False) $oXmlHttp.Send() Local $output = $oXmlHttp.ResponseBody ;~ Local $type = $oXmlHttp.ResponseType ;~ MsgBox(0, VarGetType($type) & '='&$type&'=' , VarGetType($output)) ;~ MsgBox(0, '', BinaryLen($output)) If $sZIP_FileFullPath <> '' Then Local $hFile = FileOpen($sZIP_FileFullPath, $FO_OVERWRITE + $FO_BINARY) FileWrite($hFile, $output) FileClose($hFile) EndIf $oXmlHttp = '' Return $output EndFunc ;==>_Crowdin_TranslationDownload ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Crowdin_GetProjects ; Description ...: Get Crowdin Project details. ; Syntax ........: _Crowdin_GetProjects($sLoginName) ; Parameters ....: $sLoginName - A string value. Your Crowdin Account login name. ; Return values .: None ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://crowdin.com/page/api/get-projects ; Example .......: No ; =============================================================================================================================== Func _Crowdin_GetProjects($sLoginName) ; https://api.crowdin.com/api/account/get-projects?account-key={account-key} Local $sURL = 'https://api.crowdin.com/api/account/get-projects?account-key=' & _Crowdin_AccountKey() & '&login=' & $sLoginName ConsoleWrite('! ' & $sURL & @CRLF) Local $oXmlHttp = ObjCreate("Microsoft.XMLHTTP") $oXmlHttp.Open('POST', $sURL, False) $oXmlHttp.Send('') Local $output = $oXmlHttp.ResponseText $oXmlHttp = '' Return $output EndFunc ;==>_Crowdin_GetProjects ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Crowdin_DirectoryCreate ; Description ...: Add directory to Crowdin project. ; Syntax ........: _Crowdin_DirectoryCreate($sDirectoryName) ; Parameters ....: $sDirectoryName - A string value. ; Return values .: None ; Author ........: Your mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://crowdin.com/page/api/add-directory ; Example .......: No ; =============================================================================================================================== Func _Crowdin_DirectoryCreate($sDirectoryName) ; https://api.crowdin.com/api/project/{project-identifier}/add-directory?key={project-key} Local $sURL = 'https://api.crowdin.com/api/project/' & _Crowdin_Project_Identifier() & '/add-directory?key=' & _Crowdin_Project_ApiKey() & '&name=' & $sDirectoryName ConsoleWrite('! ' & $sURL & @CRLF) Local $oXmlHttp = ObjCreate("Microsoft.XMLHTTP") $oXmlHttp.Open('POST', $sURL, False) $oXmlHttp.Send('') Local $output = $oXmlHttp.ResponseText $oXmlHttp = '' Return $output EndFunc ;==>_Crowdin_GetProjects #EndRegion CrowdinAPI - Functions #Region CrowdinAPI - SETUP ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Crowdin_Project_ApiKey ; Description ...: ; Syntax ........: _Crowdin_Project_ApiKey([$vApiKey = Default]) ; Parameters ....: $vApiKey - [optional] a variant value. Default is Default. ; Return values .: None ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://crowdin.com/page/api/authentication ; Example .......: No ; =============================================================================================================================== Func _Crowdin_Project_ApiKey($vApiKey = Default) Local Static $sPROJECT_API_KEY = '' If $vApiKey = Default Then Return $sPROJECT_API_KEY Else $sPROJECT_API_KEY = $vApiKey Return $sPROJECT_API_KEY EndIf EndFunc ;==>_Crowdin_Project_ApiKey ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Crowdin_Project_Identifier ; Description ...: ; Syntax ........: _Crowdin_Project_Identifier([$vIdentifier = Default]) ; Parameters ....: $vIdentifier - [optional] a variant value. Default is Default. ; Return values .: None ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://crowdin.com/page/api/authentication ; Example .......: No ; =============================================================================================================================== Func _Crowdin_Project_Identifier($vIdentifier = Default) Local Static $sPROJECT_identifier = '' If $vIdentifier = Default Then Return $sPROJECT_identifier Else $sPROJECT_identifier = $vIdentifier Return $sPROJECT_identifier EndIf EndFunc ;==>_Crowdin_Project_Identifier ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Crowdin_AccountKey ; Description ...: ; Syntax ........: _Crowdin_AccountKey([$vAccountKey = Default]) ; Parameters ....: $vAccountKey - [optional] A variant value. Default is Default. ; Return values .: None ; Author ........: mLipok ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://crowdin.com/settings#user-profile-api-key ; Example .......: No ; =============================================================================================================================== Func _Crowdin_AccountKey($vAccountKey = Default) Local Static $sACCOUNT_API_KEY = '' If $vAccountKey = Default Then Return $sACCOUNT_API_KEY Else $sACCOUNT_API_KEY = $vAccountKey Return $sACCOUNT_API_KEY EndIf EndFunc ;==>_Crowdin_AccountKey #EndRegion CrowdinAPI - SETUP CrowdinAPI_v0.1.au3 have fun, mLipok
-
I am in the process of creating a UDF for CrowdinAPI. I have a problem with one function. https://crowdin.com/page/api/get-projects This is my implementation. Func _Crowdin_GetProjects() ; https://api.crowdin.com/api/account/get-projects?account-key={account-key} Local $sURL = 'https://api.crowdin.com/api/account/get-projects?account-key=' & _Crowdin_AccountKey() ConsoleWrite('! ' & $sURL & @CRLF) Local $oXmlHttp = ObjCreate("MSXML2.XMLHTTP.3.0") $oXmlHttp.Open('POST', $sURL, False) $oXmlHttp.Send() Local $output = $oXmlHttp.ResponseText $oXmlHttp = '' Return $output EndFunc ;==>_Crowdin_GetProjects Func _Crowdin_AccountKey($vAccountKey = Default) Local Static $sACCOUNT_API_KEY = '' If $vAccountKey = Default Then Return $sACCOUNT_API_KEY Else $sACCOUNT_API_KEY = $vAccountKey Return $sACCOUNT_API_KEY EndIf EndFunc ;==>_Crowdin_AccountKey I do not know how to use: login={crowdin-login-name} curl -F "login={crowdin-login-name}" https://api.crowdin.com/api/account/get-projects?account-key={account-key} Thank you in advance for any help. mLipok