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

ENH: Improve logic searching translation files for custom app #5021

Conversation

Thibault-Pelletier
Copy link
Contributor

@Thibault-Pelletier Thibault-Pelletier commented Jun 30, 2020

  • Change Slicer_LANGUAGES from a GLOBAL property to a CACHE variable
    allowing language generation to be modified in the context of custom
    applications.

  • Change behavior for missing translation files when disabling translation
    updates to allow custom applications to translate subparts of the
    application only.

  • Fix qSlicerCoreApplication::loadTranslations to find generic forms of TS
    files when present.

@Thibault-Pelletier Thibault-Pelletier force-pushed the enh_internationalization branch from 6dda38c to 8718b06 Compare June 30, 2020 10:54
Copy link
Contributor

@lassoan lassoan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The content looks good to me. I have a few concerns about coding style - see inline comments.

CMake/SlicerMacroTranslation.cmake Outdated Show resolved Hide resolved
Base/QTCore/qSlicerCoreApplication.cxx Outdated Show resolved Hide resolved
Base/QTCore/qSlicerCoreApplication.cxx Outdated Show resolved Hide resolved
Base/QTCore/qSlicerCoreApplication.cxx Outdated Show resolved Hide resolved
Base/QTCore/qSlicerCoreApplication.cxx Outdated Show resolved Hide resolved
Base/QTCore/qSlicerCoreApplication.cxx Outdated Show resolved Hide resolved
Copy link
Member

@jcfr jcfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution 👍

Few nitpicks and this will be good for integration

If you some more bandwidth, another pull request that would need a little more work is this one: Slicer/SlicerGitSVNArchive#1162

CMakeLists.txt Outdated Show resolved Hide resolved
@lassoan
Copy link
Contributor

lassoan commented Jul 9, 2020

@Thibault-Pelletier Thanks again for your contribution. Would you like us to fix this up or you would be available to do it?

@Thibault-Pelletier
Copy link
Contributor Author

Hi everyone,
Thank you very much for the feedbacks, I will integrate these changes and update my commit (hopefully by today or tomorrow at latest).

@jcfr the Slicer/SlicerGitSVNArchive#1162 PR seems interesting. We are currently tackling this type of functionalities and for now we are using PyQt5 lupdate executable to parse the python files for translation methods and the following decorator to make the widgets translatable while capturing the context :

def translatable(cls):
  """Decorator to add translation support to the decorated class.

  Decorator needs to be used for both Qt widgets and other widgets to allow translation to work properly
  """
  def tr(self, name):
    return qt.QCoreApplication.translate(self.__class__.__name__, name)

  setattr(cls, 'tr', tr)
  return cls

@Thibault-Pelletier Thibault-Pelletier force-pushed the enh_internationalization branch 2 times, most recently from e3c995d to 70acd03 Compare July 10, 2020 09:22
* Change Slicer_LANGUAGES from a GLOBAL property to a CACHE variable
  allowing language generation to be modified in the context of custom
  applications.

* Change behavior for missing translation files when disabling translation
  updates to allow custom applications to translate subparts of the
  application only.

* Fix qSlicerCoreApplication::loadTranslations to find generic forms of TS
  files when present.

Co-authored-by: Andras Lasso <[email protected]>
Co-authored-by: Jean-Christophe Fillion-Robin <[email protected]>
@jcfr jcfr force-pushed the enh_internationalization branch from 70acd03 to 3b791a5 Compare November 26, 2021 15:53
@jcfr jcfr changed the title ENH: Improve internationalization support ENH: Improve logic searching translation files for custom app Nov 26, 2021
@jcfr
Copy link
Member

jcfr commented Nov 26, 2021

I will further update the topic considering changes made in Slicer/SlicerGitSVNArchive#1162

@jcfr jcfr mentioned this pull request Nov 30, 2021
@lassoan
Copy link
Contributor

lassoan commented Jan 20, 2022

This is now merged in cd5cdbd.
We plan to implement lots of i18n improvements (for scripted modules, extensions, etc.) in the coming months.

@lassoan lassoan closed this Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants