Skip to content

QtWS: Super Early Bird Tickets Available!

  • 0 Votes
    4 Posts
    217 Views
    Christian EhrlicherC

    @TechieTab said in QT Linguist tool not picking up right translation:

    How to adjust QT accordingly?

    I don't know why you want to adjust Qt here. The ts-file needs to be UTF-8 so fix your script, Latin1 can not be used here - Отказ can not be displayed with the latin1-charset so I doubt you're using latin1 at all...

  • 0 Votes
    4 Posts
    244 Views
    O

    Ok, here is my progress. Here the CMakeLists.txt of my plugin

    set(TS_FILES i18n/MyPlugin_en.ts i18n/MyPlugin_fr.ts ) # Adding translations qt_add_translations(MyPlugin TS_FILES ${TS_FILES} LUPDATE_OPTIONS -no-obsolete OUTPUT QM_FILES) install(FILES ${qm_files} DESTINATION ${CMAKE_INSTALL_BINDIR})

    Initially the MyPlugin_*.ts files are empty, so I need to go to the i18n folder and to run lupdate there. Then I translate strings.

    Finally, I compile. There is no error but the strings of MyPlugin are not translated.

    Any idea about what is missing?

  • 0 Votes
    3 Posts
    206 Views
    S

    A QTranslator handles translations from a single translation file. After that the QTranslator is installed for the application. If you have multiple QTranslators installed translations will be looked up from newest to oldest.

  • 0 Votes
    4 Posts
    577 Views
    S

    I just redid the project with qmake an here everything works out of the box. Also adding an icon, which I was not able to do with the official documentation.

    So I expect there is something wrong with the creation process of CMakeListe.txt?

  • 0 Votes
    9 Posts
    2k Views
    R

    Ok, so I removed all the tr() entries from my code and things are working. I guess the UI form file was the key to solving the issue. Thanks for the help, guys!

  • 0 Votes
    4 Posts
    3k Views
    G

    @J-Hilk Thanks, even though that was not the answer I expected, you showed me a shortcut that saves me from using the command line. It will save me time. Have a nice day!

  • 0 Votes
    3 Posts
    301 Views
    D

    @Christian-Ehrlicher Yes, nothing changes, but I moved my class to a namespace.

  • 0 Votes
    3 Posts
    548 Views
    D

    @Dmitriano Figured this out!

    I add qt-everywhere-src-6.2.2\qttranslations\translations\qtbase_ru.ts to the project and load qtbase_ru.qm with the Translator in C++ code.

  • 0 Votes
    4 Posts
    831 Views
    M

    I think you can bundle lupdate in your application and create qm file on the fly.

    P.S. : TS files are just xml files, so you can change them in your own application, via user feedback or something else

  • 0 Votes
    3 Posts
    555 Views
    C

    @KroMignon LOVE YOU!
    Thank you very much, worked w/out problems, and made me understand my mistake.
    note: Needed to update .ts file and release .qm file after changing code.

  • 0 Votes
    2 Posts
    2k Views
    Marco PellinM

    In the end everything was fine with the example above.
    I just had to update and release my translation files, because in the meantime I changed the name of a .qml file, and the filename is directly linked into the .ts files created by linguist and used by Qt.
    I feel a bit ashamed but yes, it was really trivial and kinda stupid :)

  • 0 Votes
    13 Posts
    3k Views
    ?

    @Zoltan I have the same problem, must I do?

  • 0 Votes
    5 Posts
    2k Views
    S

    Thanks for the advice mrjj. I used the translate functions and the save and restore to ensure that each section has a logical coordinate system that makes sense to it.

  • 0 Votes
    2 Posts
    1k Views
    SGaistS

    Hi,

    You should rather store the original error message in the database and to the translation when showing the database content.

  • 0 Votes
    12 Posts
    7k Views
    jovereschJ

    I am having this exact problem. I compiled my project for an embedded arm device, linux desktop, and windows desktop. The windows and linux hosts display the characters correctly, where the embedded device just shows nothing.

    I'm using the Noto fonts https://www.google.com/get/noto/#sans-hans and am positive it is being used on the linux desktop, since if I don't copy the font into the same directory as the application, it just shows blocks. When the font is in the directory, it shows everything properly.

    I tried the same thing with the embedded build, and nothing shows up. The font being loaded, since if it's not in the directory, it complains that it can't load it. Is there some extra switch or rendering tool/application that embedded linux needs? I've tried with both 'linuxfb' and 'egl' platforms with no success.

    Thanks in advance for any help.

  • 0 Votes
    4 Posts
    2k Views
    mrjjM

    @AlaaM ¨
    Hi I think you can have multiple translators(file) active, so when you switch language
    its best to remove old one or it might get messy as the old one would also be searched.
    But if completely different language, i doubt anything crazy will happen.

    http://www.informit.com/articles/article.aspx?p=1405555&seqNum=3

  • 0 Votes
    4 Posts
    1k Views
    SGaistS

    Don't worry, that kind of things happens frequently ;)

    You're welcome !

    Since you have it working now, please mark the thread as solved using the "Topic Tool" button so other forum users may know a solution has been found :)

  • 0 Votes
    6 Posts
    2k Views
    R

    Finally I'm able to automatically copy the qt translation files and create resource file from the pro file:

    TRANSLATIONS = myapp_cs.ts \ myapp_xx.ts QT_TRANSLATIONS = qtbase_cs.qm #------------------------------------------------- # create lang folder QM_DIR = $$shadowed($${PWD})/lang mkpath($${QM_DIR}) mkpath($${QM_DIR}/lang) #------------------------------------------------- # copy system translation files to lang folder for(FILE,QT_TRANSLATIONS){ FILE = $$shell_path($$[QT_INSTALL_TRANSLATIONS]/$${FILE}) system($${QMAKE_COPY} $${FILE} $$shell_path($${QM_DIR}/lang)) } #------------------------------------------------- #generate qm files directly from qmake for(FILE,TRANSLATIONS){ QM_FILE = $$shell_path($${QM_DIR}/lang/$$replace(FILE,.ts,.qm)) system(lrelease $${FILE} -qm $${QM_FILE}) } #------------------------------------------------- #create resource file with translations win32:system(cd $$shell_path($${QM_DIR}) & rcc --project -o lang.qrc) unix:system(cd $$shell_path($${QM_DIR}) ; rcc --project -o lang.qrc) RESOURCES += $${QM_DIR}/lang.qrc #------------------------------------------------- # extra target to generate ts translation files lupdate.commands = lupdate $$_PRO_FILE_ lupdate.depends = FORCE QMAKE_EXTRA_TARGETS += lupdate #------------------------------------------------- # extra compiler to generate qm translation files lrelease.input = TRANSLATIONS lrelease.output = $${QM_DIR}/lang/${QMAKE_FILE_BASE}.qm lrelease.commands = lrelease ${QMAKE_FILE_NAME} -qm ${QMAKE_FILE_OUT} lrelease.CONFIG += no_link target_predeps QMAKE_EXTRA_COMPILERS += lrelease
  • 0 Votes
    13 Posts
    6k Views
    K

    @SGaist OK. Thanks for the answer. I'll give a try.

  • 0 Votes
    6 Posts
    2k Views
    M

    The standard translations for Ok, Cancel, Save had been moved into <name>QPlatformTheme</name>
    They are missing now in all the old qt_??.ts and are only available in the newer qtbase_??.ts

    I had copied the QPlatformTheme messages into the ts-files I needed.

    Markus