Skip to content

Add recursive subfolder support for offline translation update(Local folder (for offline use) ) in Language Tools extension #92

Description

@Huaweidev

Is your feature request related to a problem? Please describe.

When using the Language Tools module in 3D Slicer, the "Local folder (for offline use)" feature does not support recursively traversing subfolders.
As a result, if my downloaded translation files are organized within subdirectories, the tool fails to detect and update them automatically.
Currently, I have to manually move all .ts files into the same directory level before updating, which is inconvenient and error-prone.

I downloaded all component translation files for a single specified language from this URL:
https://hosted.weblate.org/download/3d-slicer/-/fr/?format=zip
It will download a file named 3d-slicer-fr.zip, and its format is:

\---3d-slicer
    +---3d-slicer
    |   \---translations
    |           Slicer_en-US.ts
    |           Slicer_fr-FR.ts
    |
    +---ctk
    |   \---translations
    |           CTK_en-US.ts
    |           CTK_fr.ts
    |
    +---glossary
    |   \---glossary
    |           fr.tbx
    |
    +---languagepacks
    |   \---translations
    |           LanguagePacks_en-US.ts
    |           LanguagePacks_fr.ts
    |
    +---monaiauto3dseg
    |   \---translations
    |           MONAIAuto3DSeg_en-US.ts
    |           MONAIAuto3DSeg_fr.ts
    |
    +---monailabel
    |   \---translations
    |           MONAILabel_en-US.ts
    |           MONAILabel_fr.ts
    |
    +---slicerigt
    |   \---translations
    |           SlicerIGT_en-US.ts
    |           SlicerIGT_fr.ts
    |
    +---slicervmtk
    |   \---translations
    |           SlicerVMTK_en-US.ts
    |           SlicerVMTK_fr.ts
    |
    +---stc-seg-103
    |   \---translations
    |           STC-SEG-103_en-US.ts
    |           STC-SEG-103_fr.ts
    |
    +---totalsegmentator
    |   \---translations
    |           TotalSegmentator_en-US.ts
    |           TotalSegmentator_fr.ts
    |
    \---tutorialmaker
        \---translations
                TutorialMaker_en-US.ts
                TutorialMaker_fr.ts

When I directly update the translation files for the 3d-slicer folder, I receive the following error, I have to manually move all the TS files into the same-level directory just to update the translation files properly, which is inconvenient, especially when I need to continuously test the translation results.
Image

Traceback (most recent call last):
  File "C:\ProgramData\slicer.org\Slicer 5.8.1\bin\Python\slicer\util.py", line 3303, in tryWithErrorDisplay
    yield
  File "C:/ProgramData/slicer.org/Slicer 5.8.1/slicer.org/Extensions-33241/LanguagePacks/lib/Slicer-5.8/qt-scripted-modules/LanguageTools.py", line 409, in onUpdateButton
    self.logic.copyTsFilesFromFolder(self.ui.localTsFolderPathLineEdit.currentPath, self.ui.latestTsFileOnlyCheckBox.checked)
  File "C:/ProgramData/slicer.org/Slicer 5.8.1/slicer.org/Extensions-33241/LanguagePacks/lib/Slicer-5.8/qt-scripted-modules/LanguageTools.py", line 572, in copyTsFilesFromFolder
    raise ValueError(_("No .ts files were found in the specified location."))
ValueError: No .ts files were found in the specified location.

Describe the solution you'd like

Please add support for recursive scanning of subfolders when selecting a local folder for offline language updates.
The tool should be able to automatically detect translation files located in any nested subdirectories under the selected path.

Describe alternatives you've considered

  • Manually flattening the folder structure before each update.
  • Writing an external script to copy all translation files into a single folder before running the Language Tools update.

Additional context

This enhancement would be especially helpful when translation files are organized by module or component (e.g., /Modules/SegmentEditor/, /Modules/VolumeRendering/, etc.), which is a common structure when syncing files from Weblate or similar platforms.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions