Crowdin does not allow you to upload *.ts directly from the link. Write this program is not to be able.
How regularly is the archive with translations in crowdin updates?
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
Re: How regularly is the archive with translations in crowdin updates?
I don't think it's necessary to upload, just to download. Can't we just add something like
Code: Select all
LANG_CODE = "bg"
import urllib.request
with urllib.request.urlopen(f'https://crowdin.com/backend/download/project/freecad/{LANG_CODE}.zip') as response:
zip_data = response.read()
Re: How regularly is the archive with translations in crowdin updates?
We can and it works. But kisolre wants an archive with the latest changes. And if you download the archive in the way you suggested, there will still be translations from September 6, and today is already the 13th. Recent translations can be downloaded only one file at a time through the Crowdin interface. Although the method you proposed is good for saving traffic.chennes wrote: ↑Sun Sep 12, 2021 8:31 pmI don't think it's necessary to upload, just to download. Can't we just add something likeCode: Select all
LANG_CODE = "bg" import urllib.request with urllib.request.urlopen(f'https://crowdin.com/backend/download/project/freecad/{LANG_CODE}.zip') as response: zip_data = response.read()
I think you can download fresh translations only manually, then throw them into \ts folder and the my script will do everything by itself.
Maybe there is something like in the Crowdin REST API?:
Code: Select all
https://crowdin.com/backend/download/project/freecad/ru/Arch.ts
Last edited by Evgeniy on Sun Sep 12, 2021 10:34 pm, edited 1 time in total.
Re: How regularly is the archive with translations in crowdin updates?
I'm look REST API of Crowdin.
May be that?
https://support.crowdin.com/ru/api/pre-translate/
Is possible to send POST request from FreeCAD? And get response?
Last edited by Evgeniy on Sun Sep 12, 2021 10:42 pm, edited 2 times in total.
Re: How regularly is the archive with translations in crowdin updates?
Make sure you are using APIv2: https://support.crowdin.com/api/v2/
And yes, you can use Python to sent a POST request, so if you wanted this to be a FreeCAD WB that would be possible.
ETA: In particular, this looks promising... https://support.crowdin.com/api/v2/#ope ... files.post
And yes, you can use Python to sent a POST request, so if you wanted this to be a FreeCAD WB that would be possible.
ETA: In particular, this looks promising... https://support.crowdin.com/api/v2/#ope ... files.post
Re: How regularly is the archive with translations in crowdin updates?
I think there is no such possibility through the REST API...
Re: How regularly is the archive with translations in crowdin updates?
As far as I can tell, you can access every single feature of CrowdIn through the API -- in this case, sending a POST request to:
with a payload like:
Should give a response like:
where that url is a location you can download the translation from. Presumably there's an API call to get a list of the fileIDs, but I haven't looked for it yet. Did this not work for you? I haven't tested it, but it certainly looks from the documentation like exactly what we need.
Code: Select all
https://crowdin.com/api/v2/projects/freecad/translations/builds/files/{fileId}
Code: Select all
{
"targetLanguageId": "bg",
"exportAsXliff": false,
"skipUntranslatedStrings": false,
"skipUntranslatedFiles": false,
"exportApprovedOnly": false
}
Code: Select all
{
"data":
{
"url": "https://production-enterprise-importer.downloads.crowdin.com/992000002/2/14.xliff?response-content-disposition=attachment%3B%20filename%3D%22APP.xliff%22&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190920%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190920T093121Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Signature=439ebd69a1b7e4c23e6d17891a491c94f832e0c82e4692dedb35a6cd1e624b62",
"expireIn": "2019-09-20T10:31:21+00:00",
"etag": "ebd69a1b7e4c23e6d17891a491c94f832e0c82e4692dedb35a6cd1e624b62"
}
}
Re: How regularly is the archive with translations in crowdin updates?
Better if you showed code on python... instead requests and response.chennes wrote: ↑Mon Sep 13, 2021 2:01 am As far as I can tell, you can access every single feature of CrowdIn through the API -- in this case, sending a POST request to:with a payload like:Code: Select all
https://crowdin.com/api/v2/projects/freecad/translations/builds/files/{fileId}
Should give a response like:Code: Select all
{ "targetLanguageId": "bg", "exportAsXliff": false, "skipUntranslatedStrings": false, "skipUntranslatedFiles": false, "exportApprovedOnly": false }
where that url is a location you can download the translation from. Presumably there's an API call to get a list of the fileIDs, but I haven't looked for it yet. Did this not work for you? I haven't tested it, but it certainly looks from the documentation like exactly what we need.Code: Select all
{ "data": { "url": "https://production-enterprise-importer.downloads.crowdin.com/992000002/2/14.xliff?response-content-disposition=attachment%3B%20filename%3D%22APP.xliff%22&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190920%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190920T093121Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Signature=439ebd69a1b7e4c23e6d17891a491c94f832e0c82e4692dedb35a6cd1e624b62", "expireIn": "2019-09-20T10:31:21+00:00", "etag": "ebd69a1b7e4c23e6d17891a491c94f832e0c82e4692dedb35a6cd1e624b62" } }
Code: Select all
from urllib import parse, request
data ={
"targetLanguageId": "bg",
"exportAsXliff": False,
"skipUntranslatedStrings": False,
"skipUntranslatedFiles": False,
"exportApprovedOnly": False
}
data = json.dumps(data)
data = parse.urlencode(data).encode()
req = request.Request("https://crowdin.com/api/v2/projects/freecad/translations/builds/files/549", data=data) # this will make the method "POST"
resp = request.urlopen(req)
And where get {fileId}?
Other variant:
Code: Select all
import requests
import json
url = "https://crowdin.com/api/v2/projects/freecad/translations/builds/files/549"
body ={
"targetLanguageId": "bg",
"exportAsXliff": False,
"skipUntranslatedStrings": False,
"skipUntranslatedFiles": False,
"exportApprovedOnly": False
}
headers = {'content-type': 'application/json'}
req = requests.post(url, data=json.dumps(body), headers=headers)
print(req.text)
Re: How regularly is the archive with translations in crowdin updates?
I'm just pasting in information from the documentation:
https://support.crowdin.com/api/v2/#ope ... files.post
That page says you get the file ID from the List Files command:
https://support.crowdin.com/api/v2/#ope ... es.getMany
https://support.crowdin.com/api/v2/#ope ... files.post
That page says you get the file ID from the List Files command:
https://support.crowdin.com/api/v2/#ope ... es.getMany
Re: How regularly is the archive with translations in crowdin updates?
I understand this.chennes wrote: ↑Mon Sep 13, 2021 2:08 pm I'm just pasting in information from the documentation:
https://support.crowdin.com/api/v2/#ope ... files.post
That page says you get the file ID from the List Files command:
https://support.crowdin.com/api/v2/#ope ... es.getMany
Code: Select all
import requests
import json
url = "https://crowdin.com/api/v2/projects/286/files"
body ={
}
headers = {'content-type': 'application/json'}
req = requests.post(url, data=json.dumps(body), headers=headers)
print(req.text)
And if I understand correctly, the user must create a token in the profile. A fairly complex script.
Of course, it is convenient when everything is done with one button, but I am not so familiar with the Crowdin API...
And diving into this API may take a lot of time...
It's probably better to make do with what we have for now.