Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Translation approach for non-gui application with auto-generated code parts
Forum Updated to NodeBB v4.3 + New Features

Translation approach for non-gui application with auto-generated code parts

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 354 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    devjb
    wrote on last edited by
    #1

    I'am developing a framework that consists of several qt-based backend libraries without a gui (frontend will follow later).

    The applications, that use those libraries contain a lot of sourcecode, which will be generated by a 3rd party code-preprocessor.

    In case those auto generated code modules contain strings (they do a lot), I want the code-generator to generate translation files for them, on a per module basis.

    What would be the workflow to get those translation files loaded at runtime for the corresponding source modules.

    Example (just what I think it should look like):

    1. Code generator provides:

      • concrete-foo.cpp
      • concrete-foo.h
      • concrete-foo-de.ts
      • concrete-foo-en.ts
    2. Backend library contains a fooLoader, which does stuff with the autogenerated source code parts.

    3. fooLoader will have a QString giveMeALocalizedString(someStringIndex) -method which I can use to access strings at runtime. That probably would have to lookup the *.ts files somehow.

    4. fooLoader will have a setLanguage(languageDescriptor)-method that shall switch the used language for it at runtime.

    The tutorials for QT I found so far for internationalization only cover cases where you have a Gui application and translate your whole application from one point on using a qtranslator attached to the qApplication.

    I feel that my needs are not covered by such an approach. But I have also not that much experience with qt's translation system.

    Do my above ideas sound ok? If yes, how should I implement the functionality in my application, my auto generated code and my consuming backend libs?

    Thank you in advance

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      It's QCoreApplication::installTranslator - the QTranslator example is a little bit misleading here since it uses a QApplication: https://doc.qt.io/qt-5/qtranslator.html#details

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3
      • D Offline
        D Offline
        devjb
        wrote on last edited by
        #3

        Thanks, so a QTranslator on the application level is the only possibility and users have to load all the available qm files delivered with the library manually in their application?

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by Christian Ehrlicher
          #4

          It's the same what Qt is doing - they're providing the qm files but you have to load them by your own.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          3

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved