-
Notifications
You must be signed in to change notification settings - Fork 458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve i18n support #1162
base: master
Are you sure you want to change the base?
Improve i18n support #1162
Conversation
@jcfr Is this relevant. It has been outstanding for more than 1 year. |
Yes, let's keep it open. |
Can it be merged? |
286e5e4
to
3e1ea33
Compare
@carlos-luque I re-based the topic we worked on during one of the project week. Is it something you could test ? |
This commit adds CMake function "SlicerFunctionAddPythonScriptTrFilesTargets" used to ensure input expected by lupdate/lrelease translation tools are generated. The CMake function associates custom commands with each python scripts and also adds a convenience target called "Add<TargetName>PythonScriptTrFiles" to explicitly regenerate the .py.tr files. The custom commands generate the .py.tr files by invoking a python cli (CMake/Rewrite.py) replacing calls to "slicer.util.tr" with "QT_TRANSLATE_NOOP". The python cli "CMake/Rewrite.py" internally uses the astor python package. Updates SlicerConfig to set Slicer_BUILD_I18N_SUPPORT, Slicer_UPDATE_TRANSLATION and Slicer_LANGUAGES. Co-authored-by: Carlos Luque <[email protected]>
Removes the dependency of library to *.qm files and instead add the target GenerateSlicerTranslationQMFiles allowing to explicitly re-generate the '*.qm" files..
This commit adds GenerateSlicerTranslationTemplates target allowing to generate "<BaseName>_untranslated.ts" files. To facilitate their distribution, the files are generated in the directory "<CMAKE_BINARY_DIR>/TranslationTemplates".
After talking with "Carlos Luque <[email protected]>", we decided to keep the file simpler. This could be revisited later. Co-authored-by: Carlos Luque <[email protected]>
3e1ea33
to
71e06d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very nice. Do we have a solution for translation of scripteddesigner modules (that generate module widget from a .ui file)?
import astor | ||
|
||
|
||
class RewriteTr(ast.NodeTransformer): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this function (and the whole file) do?
@@ -94,12 +96,12 @@ def setup(self): | |||
inputFiducialsNodeSelector.addEnabled = False | |||
inputFiducialsNodeSelector.removeEnabled = False | |||
inputFiducialsNodeSelector.connect('currentNodeChanged(bool)', self.enableOrDisableCreateButton) | |||
pathFormLayout.addRow("Input Fiducials:", inputFiducialsNodeSelector) | |||
pathFormLayout.addRow(tr("EndoscopyWidget", "Input Fiducials:"), inputFiducialsNodeSelector) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tr() arguments are in not in this order (see https://doc.qt.io/qt-5/qobject.html#tr).
It should be tr("Input Fiducials:", "EndoscopyWidget")
.
self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)', | ||
inputFiducialsNodeSelector, 'setMRMLScene(vtkMRMLScene*)') | ||
|
||
# CreatePath button | ||
createPathButton = qt.QPushButton("Create path") | ||
createPathButton = qt.QPushButton(tr("EndoscopyWidget", "Create path")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of hardcoding "EndoscopyWidget" everywhere, could we add a mixin to the class, which would add the class name automatically? It would simplify the syntax to tr("Create path")
.
slicer.i18n.tr()
)<ModuleName>_untranslated.ts
filesGenerateSlicerTranslationTemplates
andGenerateSlicerTranslationQMFiles
See https://github.com/NA-MIC/ProjectWeek/blob/master/PW31_2019_Boston/Projects/Globalization3DSlicer_OHIF/README.md#progress-and-next-steps