2
0

translator.h 1.3 KB

123456789101112131415161718192021222324252627282930
  1. #ifndef TRANSLATOR_H
  2. #define TRANSLATOR_H
  3. #include "src/opl.h"
  4. /*!
  5. * \brief The ATranslator class is responsible for managing the QTranslator used for providing localisations. Translations
  6. * are planned, but are not currently being worked on. The way QT language tools are working with CMAKE, there are some
  7. * considerations for when works on translation actually start. See [here](https://bugreports.qt.io/browse/QTBUG-41736)
  8. * and [here](https://bugreports.qt.io/browse/QTBUG-76410).
  9. * Long story short, make sure to use a version of CMake that is 3.16 or earlier, or 3.19.2 or later.
  10. *
  11. * The translation source files (.ts) are located at /l10n and once compiled, the translation binaries
  12. * are at `$BINDIR/l10n/` and can be accessed via `OPL::L10N_FILES`.
  13. *
  14. * When a QTranslator is installed, the UI is updated through [QWidget::changeEvent()](https://doc.qt.io/qt-5/qwidget.html#changeEvent).
  15. *
  16. */
  17. class Translator : public QObject {
  18. Q_OBJECT
  19. public:
  20. /*!
  21. * \brief Installs a QTranslator with the selected language. Defaults to English. Call this function before constructing the Main Window.
  22. */
  23. static void installTranslator(OPL::Translation language = OPL::Translation::English);
  24. private:
  25. static QTranslator *translator;
  26. };
  27. #endif // TRANSLATOR_H