Results 1 to 3 of 3

Thread: Translations are compiled, but I can't get app to come up in Spanish

  1. #1
    Join Date
    Jul 2017
    Posts
    37
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Translations are compiled, but I can't get app to come up in Spanish

    I ran lupdate on my code and made two translation files, bezitopo_en.ts and bezitopo_es.ts . I compiled the program, getting .qm files, and tried to run the program in Spanish. It came up in English. What's wrong?

    Here's my main program:
    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication app(argc, argv);
    4. QTranslator translator;
    5. if (translator.load(QLocale(),QLatin1String("bezitopo"),QLatin1String("_"),QLatin1String(":")))
    6. app.installTranslator(&translator);
    7. TinWindow window;
    8. window.show();
    9. return app.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 
    Here's the relevant part of CMakeLists.txt:
    Qt Code:
    1. find_package(Qt5Core)
    2. find_package(Qt5Widgets)
    3. find_package(Qt5Gui)
    4. find_package(Qt5LinguistTools)
    5. qt5_add_resources(lib_resources viewtin.qrc)
    6. qt5_add_translation(qm_files bezitopo_en.ts bezitopo_es.ts)
    7.  
    8. add_executable(viewtin angle.cpp arc.cpp bezier.cpp bezier3d.cpp binio.cpp breakline.cpp
    9. cidialog.cpp circle.cpp cogo.cpp color.cpp
    10. contour.cpp csv.cpp document.cpp drawobj.cpp ellipsoid.cpp
    11. geoid.cpp geoidboundary.cpp halton.cpp kml.cpp
    12. latlong.cpp ldecimal.cpp linetype.cpp
    13. manysum.cpp measure.cpp measurebutton.cpp penwidth.cpp
    14. pnezd.cpp point.cpp pointlist.cpp polyline.cpp projection.cpp
    15. ps.cpp qindex.cpp quaternion.cpp random.cpp relprime.cpp rendercache.cpp
    16. rootfind.cpp segment.cpp spiral.cpp spolygon.cpp test.cpp tin.cpp
    17. tinwindow.cpp vball.cpp vcurve.cpp viewtin.cpp zoom.cpp zoombutton.cpp
    18. ${lib_resources} ${qm_files})
    To copy to clipboard, switch view to plain text mode 
    And here are the commands I tried:
    Qt Code:
    1. ~/build/bezitopo/dbg$ LANGUAGE=es_ES ./viewtin &
    2. ~/build/bezitopo/dbg$ LANGUAGE=es ./viewtin &
    3. ~/build/bezitopo/dbg$ LANG=es_ES.utf8 ./viewtin &
    4. ~/build/bezitopo/dbg$ LANG=es ./viewtin &
    5. ~/build/bezitopo/dbg$ LANG=es_CO ./viewtin &
    6. ~/build/bezitopo/dbg$ LANG=es_ES ./viewtin &
    To copy to clipboard, switch view to plain text mode 
    I brought the binary up in Okteta and looked for one of the strings in UTF-16, but didn't find it. What am I doing wrong? The resources (icons) work just fine.

  2. #2
    Join Date
    Jul 2017
    Posts
    37
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Translations are compiled, but I can't get app to come up in Spanish

    I tried adding the .qm files to the .qrc file, but it didn't compile. The .qm files are in the build directory; the icons are in the source directory.

  3. #3
    Join Date
    Jul 2017
    Posts
    37
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Translations are compiled, but I can't get app to come up in Spanish

    I ended up installing the .qm files.
    CMakeLists.txt:
    Qt Code:
    1. set(SHARE_DIR ${CMAKE_INSTALL_PREFIX}/share/bezitopo)
    2. install(FILES ${qm_files} DESTINATION share/bezitopo)
    To copy to clipboard, switch view to plain text mode 
    config.h.in:
    Qt Code:
    1. #define SHARE_DIR "@SHARE_DIR@"
    To copy to clipboard, switch view to plain text mode 
    Main program:
    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication app(argc, argv);
    4. QTranslator translator;
    5. if (translator.load(QLocale(),QLatin1String("bezitopo"),
    6. {
    7. //cout<<"Translations found in current directory"<<endl;
    8. app.installTranslator(&translator);
    9. }
    10. else if (translator.load(QLocale(),QLatin1String("bezitopo"),
    11. QLatin1String("_"),QLatin1String(SHARE_DIR)))
    12. {
    13. //cout<<"Translations found in share directory"<<endl;
    14. app.installTranslator(&translator);
    15. }
    16. TinWindow window;
    17. window.show();
    18. return app.exec();
    19. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Emulating Qt compiled code for MIPS in VirtualFrameBuffer(Qvfb in X11-X86 compiled)
    By sunil-vasudevan in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 22nd October 2012, 07:07
  2. Translating to spanish using Qt Linguist
    By tennisace in forum Qt Tools
    Replies: 0
    Last Post: 9th April 2012, 01:29
  3. Replies: 2
    Last Post: 10th December 2010, 00:01
  4. Replies: 3
    Last Post: 20th September 2010, 23:36
  5. Qt 4.2.x in Spanish
    By xgoan in forum Installation and Deployment
    Replies: 1
    Last Post: 1st March 2007, 07:00

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.