Skip to content
  • 0 Votes
    8 Posts
    3k Views
    Pablo J. RoginaP

    @Phill

    parsing the language files and then storing the limited subset I need in a dictionary

    I don't want to convince you about my idea, but based on my experience it looks like you are heading to re-invent the wheel. A parser for .ts files? A map for "translatable string" KEY -> "translated string" VALUE? Let's see below.

    (I'm using Python) may be the best option

    I assume you're using PyQt , if so you have most of the same tools for Qt translations. See here.

    @mrjj There are tr()/translate() functions (with some caveats) but the idea is the same: all the strings wrapped within tr()/translate() will be copied into .ts files upon using pylupdate5 (lupdate equivalent)

    if I cant use the QTranslaor that is being used to translate the ui

    The main thing is that only one translator is used at a time by Qt to translate the UI. You can install tons of translators for the UI with

    qApp->installTranslator(& aTranslator)

    but (from Qt documentation):

    Multiple translation files can be installed in an application. Translations are searched for in the reverse order in which they were installed, so the most recently installed translation file is searched for translations first and the earliest translation file is searched last. The search stops as soon as a translation containing a matching string is found.

  • 0 Votes
    2 Posts
    924 Views
    mrjjM

    hi
    I started with
    http://doc.qt.io/qt-5/internationalization.html

    and then
    the "Dynamic Language Switching"
    from this book
    http://www.bogotobogo.com/cplusplus/files/c-gui-programming-with-qt-4-2ndedition.pdf

    On windows you can change the locale to test if it will switch. I assume
    you can do the same in OSX.