Skip to content
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

Mark all user-visible strings as translatable in C++ #12

Closed
25 tasks done
lassoan opened this issue Aug 17, 2022 · 4 comments
Closed
25 tasks done

Mark all user-visible strings as translatable in C++ #12

lassoan opened this issue Aug 17, 2022 · 4 comments
Assignees

Comments

@lassoan
Copy link
Collaborator

lassoan commented Aug 17, 2022

Summary

Many strings that are specified in C++ source files have not been marked as translatable (e.g., by using the QObject::tr method). Slicer core, CTK library, and Slicer extensions source code needs to be improved so that all translatable strings are marked as such.

Evolution of modules marking tasks

@lassoan
Copy link
Collaborator Author

lassoan commented Aug 17, 2022

Qt seems to recommend two approaches for making tr() function available in non-QObject-based classes:

Probably option A is more clear and consistent - we can use tr() everywhere and only need to add a single line to the non-QObject-based class declaration. Of course, it would need to be tested if it indeed works as we expect.

lassoan pushed a commit to mhdiop/Sliceriml that referenced this issue Oct 12, 2022
Qt lupdate tool throws `Cannot invoke tr() like this` warnings when translation function is called using `q->tr(...)`.
The problem is that lupdate cannot determine the class name `tr()` is called on and therefore it does not know the translation context.
The solution is to spell out the class name in the call, for example `qSlicerScalarVolumeDisplayWidget::tr(...)`. More details are described here: https://github.com/Slicer/SlicerLanguagePacks/blob/main/DevelopersManual.md

see Slicer/SlicerLanguagePacks#12
lassoan pushed a commit to Slicer/Slicer that referenced this issue Oct 12, 2022
Qt lupdate tool throws `Cannot invoke tr() like this` warnings when translation function is called using `q->tr(...)`.
The problem is that lupdate cannot determine the class name `tr()` is called on and therefore it does not know the translation context.
The solution is to spell out the class name in the call, for example `qSlicerScalarVolumeDisplayWidget::tr(...)`. More details are described here: https://github.com/Slicer/SlicerLanguagePacks/blob/main/DevelopersManual.md

see Slicer/SlicerLanguagePacks#12
@mhdiop
Copy link
Collaborator

mhdiop commented Nov 21, 2022

I was wondering which approach we should use when it's about dealing with numbered arguments present on translatable strings. For example, when we have the following string :

QString("An update is available. Installed: %1. Available : %2.")
        .arg(installedVersion)
        .arg(onServerVersion);

Which translation approach should we consider ?

Option A

tr("An update is available. Installed: %1. Available: %2.")
        .arg(installedVersion)
        .arg(onServerVersion);

Option B

tr("%1 %2 %3. %4 %5.")
        .arg(tr("An update is available."))
        .arg(tr("Installed:"))
        .arg(installedVersion)
        .arg(tr("Available:"))
        .arg(onServerVersion);

Option C

tr("%1 %2. %3 %4.")
        .arg(tr("An update is available. Installed:"))
        .arg(installedVersion)
        .arg(tr("Available:"))
        .arg(onServerVersion);

The first option may be simpler and may offer more flexibility at translation time. It also offers a better context to the translation since the whole sentence is visible. However, the presence of arguments in translatable strings may not be understood by "non-tech" translators and may be mishandled.

For this, I think that, as with the & character, we can specify in the ongoing translation guide what they represent and how to handle them.

Here is another example of such strings where the text in the HTML code has numbered arguments and needs to be translated.

unnamed

mhdiop added a commit to mhdiop/Sliceriml that referenced this issue Nov 26, 2022
mhdiop added a commit to mhdiop/Sliceriml that referenced this issue Dec 18, 2022
mhdiop added a commit to mhdiop/Sliceriml that referenced this issue Dec 19, 2022
mhdiop added a commit to mhdiop/Sliceriml that referenced this issue Dec 19, 2022
Separation of SliceOrientationMarkerTypeComboBox item text and data so that to ease translations
See Slicer/SlicerLanguagePacks#12
lassoan pushed a commit to Slicer/Slicer that referenced this issue Dec 30, 2022
lassoan pushed a commit to Slicer/Slicer that referenced this issue Dec 30, 2022
Separation of SliceOrientationMarkerTypeComboBox item text and data so that to ease translations
See Slicer/SlicerLanguagePacks#12
mhdiop added a commit to mhdiop/Sliceriml that referenced this issue Jan 8, 2023
mhdiop added a commit to mhdiop/Sliceriml that referenced this issue Jan 9, 2023
mhdiop added a commit to mhdiop/Sliceriml that referenced this issue Jan 18, 2023
lassoan pushed a commit to mhdiop/Sliceriml that referenced this issue Jan 22, 2023
lassoan pushed a commit to mhdiop/Sliceriml that referenced this issue Feb 9, 2023
lassoan pushed a commit to mhdiop/Sliceriml that referenced this issue Feb 9, 2023
lassoan pushed a commit to Slicer/Slicer that referenced this issue Feb 9, 2023
lassoan added a commit to lassoan/Slicer that referenced this issue Feb 9, 2023
Some user-visible strings were not marked as translatable.

see Slicer/SlicerLanguagePacks#12
lassoan added a commit to Slicer/Slicer that referenced this issue Feb 9, 2023
Some user-visible strings were not marked as translatable.

see Slicer/SlicerLanguagePacks#12
mhdiop added a commit to mhdiop/CTK that referenced this issue Feb 13, 2023
Qt lupdate tool throws `Cannot invoke tr() like this` warnings when translation function is called using `q->tr(...)`.
The problem is that lupdate cannot determine the class name `tr()` is called on and therefore it does not know the translation context.
The solution is to spell out the class name in the call, for example `qSlicerScalarVolumeDisplayWidget::tr(...)`. More details are described here: https://github.com/Slicer/SlicerLanguagePacks/blob/main/DevelopersManual.md

see Slicer/SlicerLanguagePacks#17
see Slicer/SlicerLanguagePacks#12
lassoan pushed a commit to lassoan/Slicer that referenced this issue Sep 2, 2023
vtkMRMLI18N singleton class is responsible for internationalization related features in MRML.
It currently only stores a language translator.

A translator that uses Qt for translation is specified in qSlicerCoreApplication.

Enables fixing of these issues:
Slicer/SlicerLanguagePacks#12
Slicer#6647
Slicer#6177

Co-authored-by: Mouhamed DIOP <mouhamed.diop@esp.sn>
lassoan pushed a commit to Slicer/Slicer that referenced this issue Sep 2, 2023
vtkMRMLI18N singleton class is responsible for internationalization related features in MRML.
It currently only stores a language translator.

A translator that uses Qt for translation is specified in qSlicerCoreApplication.

Enables fixing of these issues:
Slicer/SlicerLanguagePacks#12
#6647
#6177

Co-authored-by: Mouhamed DIOP <mouhamed.diop@esp.sn>
mhdiop added a commit to mhdiop/Sliceriml that referenced this issue Sep 5, 2023
mhdiop added a commit to mhdiop/Sliceriml that referenced this issue Sep 6, 2023
mhdiop added a commit to mhdiop/Sliceriml that referenced this issue Sep 21, 2023
mhdiop added a commit to mhdiop/Sliceriml that referenced this issue Sep 21, 2023
lassoan pushed a commit to lassoan/Slicer that referenced this issue Sep 29, 2023
Segment Editor effects have now separate "name" (for modules to refer to the effect) and "title" (displayed on the GUI).

This partially fixes these issues:
- Slicer#6177
- Slicer/SlicerLanguagePacks#12
lassoan pushed a commit to lassoan/Slicer that referenced this issue Sep 29, 2023
Segment Editor effects have now separate "name" (for modules to refer to the effect) and "title" (displayed on the GUI).

This partially fixes these issues:
- Slicer#6177
- Slicer/SlicerLanguagePacks#12
lassoan pushed a commit to lassoan/Slicer that referenced this issue Sep 29, 2023
Segment Editor effects have now separate "name" (for modules to refer to the effect) and "title" (displayed on the GUI).

This partially fixes these issues:
- Slicer#6177
- Slicer/SlicerLanguagePacks#12
lassoan pushed a commit to lassoan/Slicer that referenced this issue Sep 29, 2023
Segment Editor effects have now separate "name" (for modules to refer to the effect) and "title" (displayed on the GUI).

This partially fixes these issues:
- Slicer#6177
- Slicer/SlicerLanguagePacks#12
lassoan pushed a commit to lassoan/Slicer that referenced this issue Sep 29, 2023
Segment Editor effects have now separate "name" (for modules to refer to the effect) and "title" (displayed on the GUI).

This partially fixes these issues:
- Slicer#6177
- Slicer/SlicerLanguagePacks#12
lassoan pushed a commit to lassoan/Slicer that referenced this issue Sep 29, 2023
Segment Editor effects have now separate "name" (for modules to refer to the effect) and "title" (displayed on the GUI).

This partially fixes these issues:
- Slicer#6177
- Slicer/SlicerLanguagePacks#12
lassoan pushed a commit to lassoan/Slicer that referenced this issue Sep 30, 2023
Segment Editor effects have now separate "name" (for modules to refer to the effect) and "title" (displayed on the GUI).

This partially fixes these issues:
- Slicer#6177
- Slicer/SlicerLanguagePacks#12
lassoan pushed a commit to lassoan/Slicer that referenced this issue Oct 3, 2023
Segment Editor effects have now separate "name" (for modules to refer to the effect) and "title" (displayed on the GUI).

This partially fixes these issues:
- Slicer#6177
- Slicer/SlicerLanguagePacks#12
lassoan pushed a commit to lassoan/Slicer that referenced this issue Oct 5, 2023
Segment Editor effects have now separate "name" (for modules to refer to the effect) and "title" (displayed on the GUI).

This partially fixes these issues:
- Slicer#6177
- Slicer/SlicerLanguagePacks#12
lassoan pushed a commit to Slicer/Slicer that referenced this issue Oct 5, 2023
Segment Editor effects have now separate "name" (for modules to refer to the effect) and "title" (displayed on the GUI).

This partially fixes these issues:
- #6177
- Slicer/SlicerLanguagePacks#12
@lassoan
Copy link
Collaborator Author

lassoan commented Feb 28, 2024

All problems are fixed or tracked in specific issues.

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

No branches or pull requests

2 participants