Results 1 to 3 of 3

Thread: What is needed to set language for resource (qrc) to use?

  1. #1
    Join Date
    Jun 2014
    Posts
    98
    Thanks
    43
    Thanked 4 Times in 4 Posts
    Platforms
    Windows

    Default What is needed to set language for resource (qrc) to use?

    (Note I am working in Python (PySide))

    I have something like the following in my .qrc file (some other stuff is deleted):
    Qt Code:
    1. <!DOCTYPE RCC>
    2. <RCC version="1.0">
    3.  
    4. <qresource>
    5. <file>qt_fr.qm</file>
    6. </qresource>
    7.  
    8. <qresource>
    9. <file alias="index.html">help/index.html</file>
    10. </qresource>
    11.  
    12. <qresource lang="fr">
    13. <file alias="index.html">help/index_fr.html</file>
    14. </qresource>
    15.  
    16. </RCC>
    To copy to clipboard, switch view to plain text mode 

    To my chagrin, I'm not sure how to activate the 'fr' language trigger so that the correct alias is chosen, and index_fr.html is used.

    What I have right now in main() is:

    Qt Code:
    1. locale = 'fr'
    2. app = QtGui.QApplication(sys.argv)
    3. qtTranslator = QtCore.QTranslator()
    4. if qtTranslator.load("qt_" + locale, ":/"):
    5. app.installTranslator(qtTranslator)
    6. form = HelpForm("index.html")
    7. form.show()
    8. sys.exit(app.exec_())
    To copy to clipboard, switch view to plain text mode 

    Where HelpForm basically displays index.html. But even though I have 'fr' as my locale, it is still just showing me the index.html file, not index_fr.html, as I thought I had asked for in the qrc file (which successfully compiled and I loaded the resource_rc.py file in my module).

    Can anyone help me find the minimal requirements to get this to work?
    Last edited by neuronet; 27th January 2015 at 05:05.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: What is needed to set language for resource (qrc) to use?

    You don't seem to set the locale, so Qt will still see whatever the system has set.

    See QLocale::setDefault().

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    neuronet (27th January 2015)

  4. #3
    Join Date
    Jun 2014
    Posts
    98
    Thanks
    43
    Thanked 4 Times in 4 Posts
    Platforms
    Windows

    Default Re: What is needed to set language for resource (qrc) to use?

    Quote Originally Posted by anda_skoa View Post
    You don't seem to set the locale, so Qt will still see whatever the system has set.
    See QLocale::setDefault().
    That fixes it. For Python users, I just added the following (recall locale='fr'):
    Qt Code:
    1. newLocale = QtCore.QLocale(locale)
    2. QLocale.setDefault(newLocale)
    To copy to clipboard, switch view to plain text mode 
    And it works.
    Last edited by neuronet; 27th January 2015 at 13:55.

Similar Threads

  1. Minimum required to emit a signal
    By davethomaspilot in forum Newbie
    Replies: 35
    Last Post: 22nd February 2013, 12:56
  2. Replies: 0
    Last Post: 8th April 2011, 16:04
  3. Replies: 3
    Last Post: 28th September 2010, 10:48
  4. Problem with Russian lang. in QtDemo apps on Ubuntu 9.10
    By sergey_85 in forum Qt Programming
    Replies: 0
    Last Post: 19th June 2010, 20:28
  5. Can we invoke other lang. scripts through QT
    By yogeshkarpate in forum Newbie
    Replies: 1
    Last Post: 14th August 2009, 10:43

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.