Results 1 to 2 of 2

Thread: Gui partially translated

  1. #1
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Gui partially translated

    Hi, I have a very strange problem: my application's gui is partially translated although I translated all strings with Qt Linguist. I'm using the following code to load the qm file.

    Qt Code:
    1. QTranslator appTranslator;
    2. QTranslator qtTranslator;
    3. QStringList uiLanguages;
    4. // uiLanguages crashes on Windows with 4.8.0 release builds
    5. #if (QT_VERSION >= 0x040801) || (QT_VERSION >= 0x040800 && !defined(Q_OS_WIN))
    6. uiLanguages = QLocale::system().uiLanguages();
    7. #else
    8. uiLanguages << QLocale::system().name();
    9. #endif
    10.  
    11. const QString &appTrPath = QCoreApplication::applicationDirPath()
    12. + QLatin1String(SHARE_PATH "/translations");
    13.  
    14. foreach (QString locale, uiLanguages) {
    15. #if (QT_VERSION >= 0x050000)
    16. locale = QLocale(locale).name();
    17. #else
    18. locale.replace(QLatin1Char('-'), QLatin1Char('_')); // work around QTBUG-25973
    19. #endif
    20. if (appTranslator.load(QLatin1String("myapp_") + locale, appTrPath)) {
    21. installTranslator(&appTranslator);
    22.  
    23. const QString &qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
    24. const QString &qtTrFile = QLatin1String("qt_") + locale;
    25. // Binary installer puts Qt tr files into creatorTrPath
    26. if (qtTranslator.load(qtTrFile, qtTrPath) || qtTranslator.load(qtTrFile, appTrPath)) {
    27. installTranslator(&qtTranslator);
    28. setProperty("qtc_locale", locale);
    29. }
    30. break;
    31. } else if (locale == QLatin1String("C") /* overrideLanguage == "English" */) {
    32. // use built-in
    33. break;
    34. } else if (locale.startsWith(QLatin1String("en")) /* "English" is built-in */) {
    35. // use built-in
    36. break;
    37. }
    38. }
    To copy to clipboard, switch view to plain text mode 

    Since some strings are correctly translated I presume that the qm file is loaded. I tryed to remove it and, as expected, no string is translated. I loaded the qm file in a binary editor to check reference to untranslated text and the missing strings are there.

    to create the qm files I follow the usual procedure:

    lupdate -no-obsolete *.cpp *.ui *.h -ts ../translations/*.ts
    (translation with Qt Linguist)
    cd ../translations
    lrelease *.ts

    Any idea how debug the problem?

    Thanks
    Giuseppe CalÃ

  2. #2
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Gui partially translated

    Solved. Untranslated strings come from static classes. Using "construct on first use" idiom fixed the issue.
    Giuseppe CalÃ

Similar Threads

  1. QDockWidget partially hidden
    By zzz9 in forum Qt Programming
    Replies: 0
    Last Post: 26th November 2012, 13:47
  2. PySide translations working just partially
    By jazuju in forum Qt Programming
    Replies: 0
    Last Post: 1st October 2012, 14:55
  3. QTcpSocket reads partially string
    By Edder in forum Qt Programming
    Replies: 1
    Last Post: 18th July 2012, 20:29
  4. Not all Widgets are Translated
    By Halcom in forum Qt Programming
    Replies: 8
    Last Post: 6th December 2010, 08:52
  5. Translated plugins
    By Illuminnator in forum Qt Programming
    Replies: 1
    Last Post: 25th January 2007, 17:34

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.