Slicer / SlicerLanguagePacks

3D Slicer extension for creating, editing, and storing translations for Slicer core and extensions
MIT License
8 stars 11 forks source link

CTK weblate issue #19

Closed spujol closed 1 year ago

spujol commented 1 year ago

I downloaded Slicer Preview Release 5.3.0-2023-03-07 on MacOSX 10.15.7 and installed the Language Packs Extension. I selected the languages French, Spanish, and Portuguese.

When I click on Update Translatation file I get an error message related to the download of the .ts files for CTK:

Traceback (most recent call last):
  File "/Applications/Slicer.app/Contents/lib/Slicer-5.3/qt-scripted-modules/SampleData.py", line 862, in downloadFile
    urllib.request.urlretrieve(uri, filePath, self.reportHook)
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/urllib/request.py", line 239, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/urllib/request.py", line 555, in error
    result = self._call_chain(*args)
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/urllib/request.py", line 747, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/urllib/request.py", line 555, in error
    result = self._call_chain(*args)
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/urllib/request.py", line 747, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/urllib/request.py", line 561, in error
    return self._call_chain(*args)
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/urllib/request.py", line 641, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Applications/Slicer.app/Contents/bin/Python/slicer/util.py", line 2973, in tryWithErrorDisplay
    yield
  File "/Applications/Slicer.app/Contents/Extensions-31625/LanguagePacks/lib/Slicer-5.3/qt-scripted-modules/LanguageTools.py", line 405, in onUpdateButton
    self.logic.downloadTsFilesFromWeblate(self.ui.weblateDownloadUrlEdit.text, self.selectedWeblateLanguages())
  File "/Applications/Slicer.app/Contents/Extensions-31625/LanguagePacks/lib/Slicer-5.3/qt-scripted-modules/LanguageTools.py", line 570, in downloadTsFilesFromWeblate
    tsFile = dataLogic.downloadFile(f'{downloadUrl}/{component}/{language}', self.temporaryFolder(), f'{filename}_{language}.ts')
  File "/Applications/Slicer.app/Contents/lib/Slicer-5.3/qt-scripted-modules/SampleData.py", line 866, in downloadFile
    raise ValueError(f"Failed to download {uri} to {filePath}")
ValueError: Failed to download https://hosted.weblate.org/download/3d-slicer/ctk/es-419 to /private/var/folders/kf/cb8yqf595pn2mc2vczzl16mh0000gn/T/Slicer-spujol/__SlicerTemp__2023-03-09_09+48+50.049/CTK_es-419.ts
lassoan commented 1 year ago

I guess this is due to no French translation has been created for CTK yet. As a quick fix, you can go to Weblate and add French translation for CTK.

I'll change the implementation to only log a warning if a translation file is not found.

Since this issue occurred in the LanguageTools module, in the future submit similar error reports to the issue tracker of the LanguagePacks extension (just to reduce noise in the Slicer issue tracker).

jcfr commented 1 year ago

similar error reports to the issue tracker of the LanguagePacks extension

Issue has been transferred :heavy_check_mark:

lassoan commented 1 year ago

This is very cool, I did not know that it is possible to move issues between repositories! (I see now that there is a "Transfer issue" action)