Skip to content
  • Initial translation language with QTranslator

    Solved General and Desktop qtranslator
    9
    0 Votes
    9 Posts
    655 Views
    O
    Not sure why I am having so many problems in something which looks very straightforward. Nothing really seems to work. [image: b0f3e8c1-3c1d-40c6-9ad7-168ea335d4db.png] The only time that I have been successful in the User Interface displaying a non-default translation language was with QLocale::setDefault. I believe that I am just going to go and try with this approach. My overall language detection logic in main.cpp is going to be something like: 0. Check if user has already explicitly set an application language If that is the case, skip to step 3 This information is going to be stored in an external configuration file outside the application. 1. Detect user's default locale with QLocale::QLocale() 2. Check if user's default locale has an available translation in the application If they do not, either do nothing else, or explicitly change the current locale to match with the default translation language (for the sake of readability) I need to think exactly how I am going to match the results but QLocale has both QLocale::language() and QLocale::name() and that should be more than enough. 3. Change default locale to expected locale using QLocale::setDefault I am not planning in adding my languages to my application. So, I am not really worried about having a big switch statement.
  • 0 Votes
    5 Posts
    1k Views
    P
    @SGaist said in QMenu And QSqlQueryModel translation problem !: QEvent::LanguageChange @ SGaist Hi bro <3 i didn't know about QEvent::LanguageChange before really thank you, i will check it <3
  • Translated string in multiple languages

    Unsolved General and Desktop qtranslator multilingual
    8
    0 Votes
    8 Posts
    4k 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
    9 Posts
    4k Views
    kshegunovK
    @oberluz No problem, although the merit should go to @SGaist who actually sensed what the problem is. :) Cheers!
  • QTranslator ru-en && UTF-8

    Solved General and Desktop qtranslator utf-8 encoding
    7
    0 Votes
    7 Posts
    3k Views
    0
    @SGaist That is true, thanks!
  • 0 Votes
    32 Posts
    16k Views
    mrjjM
    @mbnoimi Ok, why if I can ask?
  • QTranslator

    General and Desktop qtranslator
    8
    0 Votes
    8 Posts
    3k Views
    A
    #include <QCoreApplication> ....... qApp-> Like a global pointer: QApplication* qApp
  • 0 Votes
    3 Posts
    5k Views
    SGaistS
    Hi and welcome to devnet, Glad you found out and thanks for sharing ! Since you have it working now, please update the thread title prepending [solved] so other forum users may know that a solution has been found :)
  • 0 Votes
    2 Posts
    971 Views
    SGaistS
    Hi and welcome to devnet, Can you share a minimal sample code that shows this behavior ?