Results 1 to 20 of 22

Thread: QTranslator??

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2009
    Posts
    59
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTranslator??

    Quote Originally Posted by wysota View Post
    What data do you want? Chris gave you a complete example with all the files.
    I alway thanks you so much for good supports.
    But I want to run one of examples in installed directory(C:\dev\Qt\2010.05\qt\examples\linguist) to understand about QTranslator.
    I run them but none of them can run. I run lupdate, lrelease commands them raise erorrs. Maybe Qt installed incorrectly?
    When i run
    Qt Code:
    1. hellotr
    To copy to clipboard, switch view to plain text mode 
    project and check
    Qt Code:
    1. bool resultLaod=translator.load("hellotr_la");
    2. then the resultLaod=false.
    To copy to clipboard, switch view to plain text mode 
    Thanks
    Last edited by nthung; 14th October 2011 at 11:09.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTranslator??

    What do you do step by step to build an example?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    nthung (14th October 2011)

  4. #3
    Join Date
    Nov 2009
    Posts
    59
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTranslator??

    Quote Originally Posted by wysota View Post
    What do you do step by step to build an example?
    Could you send me the one of examples then i run successfully?
    Do you think that I installed Qt incorrectly?
    Last edited by nthung; 14th October 2011 at 11:16.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTranslator??

    No I couldn't. What good would it be if I send you the same files you already have? Just answer my previous question.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #5
    Join Date
    Nov 2009
    Posts
    59
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTranslator??

    Quote Originally Posted by wysota View Post
    No I couldn't. What good would it be if I send you the same files you already have? Just answer my previous question.
    thanks
    I opened it by QtCreator then run
    This is my project
    Qt Code:
    1. /****************************************************************************
    2. **
    3. ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    4. ** All rights reserved.
    5. ** Contact: Nokia Corporation (qt-info@nokia.com)
    6. **
    7. ** This file is part of the examples of the Qt Toolkit.
    8. **
    9. ** $QT_BEGIN_LICENSE:BSD$
    10. ** You may use this file under the terms of the BSD license as follows:
    11. **
    12. ** "Redistribution and use in source and binary forms, with or without
    13. ** modification, are permitted provided that the following conditions are
    14. ** met:
    15. ** * Redistributions of source code must retain the above copyright
    16. ** notice, this list of conditions and the following disclaimer.
    17. ** * Redistributions in binary form must reproduce the above copyright
    18. ** notice, this list of conditions and the following disclaimer in
    19. ** the documentation and/or other materials provided with the
    20. ** distribution.
    21. ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
    22. ** the names of its contributors may be used to endorse or promote
    23. ** products derived from this software without specific prior written
    24. ** permission.
    25. **
    26. ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    27. ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    28. ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    29. ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    30. ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    31. ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    32. ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    33. ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    34. ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    35. ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    36. ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
    37. ** $QT_END_LICENSE$
    38. **
    39. ****************************************************************************/
    40.  
    41. #include <QApplication>
    42. #include <QPushButton>
    43. #include <QDebug>
    44. //! [0]
    45. #include <QTranslator>
    46. //! [0]
    47.  
    48. //! [1] //! [2]
    49. int main(int argc, char *argv[])
    50. //! [1] //! [3] //! [4]
    51. {
    52. QApplication app(argc, argv);
    53. //! [3]
    54.  
    55. //! [5]
    56. QTranslator translator;
    57. //! [5] //! [6]
    58. bool x=translator.load("hellotr_la");
    59. if(x==false)
    60. qDebug()<<"Load fialed";
    61. //! [6] //! [7]
    62. app.installTranslator(&translator);
    63. //! [4] //! [7]
    64.  
    65. //! [8]
    66. QPushButton hello(QPushButton::tr("Hello world!"));
    67. //! [8]
    68. hello.resize(100, 30);
    69.  
    70. hello.show();
    71. return app.exec();
    72. }
    73. //! [2]
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. !symbian: error(Only include this file for Symbian platforms)
    2.  
    3. RSS_RULES ="group_name=\"QtExamples\";"
    4.  
    5. vendorinfo = \
    6. "; Localised Vendor name" \
    7. "%{\"Nokia, Qt\"}" \
    8. " " \
    9. "; Unique Vendor name" \
    10. ":\"Nokia, Qt\"" \
    11. " "
    12.  
    13. examples_deployment.pkg_prerules += vendorinfo
    14. DEPLOYMENT += examples_deployment
    15.  
    16. isEmpty(ICON):ICON = $$QT_SOURCE_TREE/src/s60installs/qt.svg
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. #! [0]
    2. SOURCES = main.cpp
    3. #! [0] #! [1]
    4. TRANSLATIONS = hellotr_la.ts
    5. #! [1]
    6.  
    7. # install
    8. target.path = $$[QT_INSTALL_EXAMPLES]/linguist/hellotr
    9. sources.files = $$SOURCES *.pro
    10. sources.path = $$[QT_INSTALL_EXAMPLES]/linguist/hellotr
    11. INSTALLS += target sources
    12.  
    13. symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <!DOCTYPE TS>
    3. <TS version="2.0" language="en_GB">
    4. <context>
    5. <name>QPushButton</name>
    6. <message>
    7. <source>Hello world!</source>
    8. <translation>Xin chao</translation>
    9. </message>
    10. </context>
    11. </TS>
    To copy to clipboard, switch view to plain text mode 

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTranslator??

    Where did you put these files?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. The following user says thank you to wysota for this useful post:

    nthung (14th October 2011)

  9. #7
    Join Date
    Nov 2009
    Posts
    59
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTranslator??

    Quote Originally Posted by wysota View Post
    Where did you put these files?
    The same directory
    C:\dev\Qt\2010.05\qt\examples\linguist\hellotr
    Qt Code:
    1. bool resultLaod=translator.load("hellotr_la");
    2. then the resultLaod=false.
    To copy to clipboard, switch view to plain text mode 

  10. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTranslator??

    Copy them elsewhere, run qmake and make.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #9
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QTranslator??

    Dead easy... I really cannot see the problem
    Qt Code:
    1. $ cd /tmp
    2. $ cp -r /usr/share/qt4/examples/linguist/hellotr .
    3. $ cd hellotr
    4. $ qmake
    5. $ make
    6.  
    7. $ lupdate hellotr.pro
    8. ...
    9. Updating 'hellotr_la.ts'...
    10. Found 1 source text(s) (1 new and 0 already existing)
    11. $ linguist hellotr_la.ts # translate the string
    12. $ lrelease hellotr.pro
    13. ...
    14. Updating '/tmp/hellotr/hellotr_la.qm'...
    15. Generated 1 translation(s) (1 finished and 0 unfinished)
    16. $ ./hellotr
    To copy to clipboard, switch view to plain text mode 

  12. #10
    Join Date
    Nov 2009
    Posts
    59
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTranslator??

    Quote Originally Posted by ChrisW67 View Post
    Dead easy... I really cannot see the problem
    Qt Code:
    1. $ cd /tmp
    2. $ cp -r /usr/share/qt4/examples/linguist/hellotr .
    3. $ cd hellotr
    4. $ qmake
    5. $ make
    6.  
    7. $ lupdate hellotr.pro
    8. ...
    9. Updating 'hellotr_la.ts'...
    10. Found 1 source text(s) (1 new and 0 already existing)
    11. $ linguist hellotr_la.ts # translate the string
    12. $ lrelease hellotr.pro
    13. ...
    14. Updating '/tmp/hellotr/hellotr_la.qm'...
    15. Generated 1 translation(s) (1 finished and 0 unfinished)
    16. $ ./hellotr
    To copy to clipboard, switch view to plain text mode 
    thanks
    Qt Code:
    1. bool loadReturn=translator.load(locale);
    To copy to clipboard, switch view to plain text mode 
    loadReturn=false. So it can translate.
    Why is loadReturn =flase not true???
    mycomputer can't run above commands.
    Last edited by nthung; 15th October 2011 at 03:07.

  13. #11
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QTranslator??

    That code doesn't appear in the hellotr example. Anyway, upon reading the friendly manual (QTranslator::load()) I discover that:
    Loads filename + suffix (".qm" if the suffix is not specified), which may be an absolute file name or relative to directory. Returns true if the translation is successfully loaded; otherwise returns false.
    What is the value of the variable locale? Does it correspond to a *.qm file?
    Last edited by ChrisW67; 15th October 2011 at 03:51.

  14. The following user says thank you to ChrisW67 for this useful post:

    nthung (15th October 2011)

Similar Threads

  1. QTranslator is not working in autostart!
    By MisterIKS in forum Qt Programming
    Replies: 2
    Last Post: 27th June 2010, 08:36
  2. Help with QTranslator
    By aarelovich in forum Qt Programming
    Replies: 1
    Last Post: 24th July 2009, 22:38
  3. Want to use QTranslator
    By santhoshv84 in forum Qt Programming
    Replies: 1
    Last Post: 27th August 2008, 15:13
  4. QDesigner + Qtranslator + QComboBox
    By Atikae in forum Qt Programming
    Replies: 3
    Last Post: 11th July 2008, 15:41
  5. Switch QTranslator at runtime?
    By whitefurrows in forum Qt Programming
    Replies: 22
    Last Post: 6th November 2006, 11:32

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
  •  
Qt is a trademark of The Qt Company.