Page 1 of 2 12 LastLast
Results 1 to 20 of 22

Thread: QTranslator??

  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 QTranslator??

    I am coding a program multilanguage, as
    http://www.java2s.com/Code/Cpp/Qt/UsingQTranslator.htm
    but I don't know how to make data. Could you create a data for me?
    thanks

  2. #2
    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??

    I could create "a data" for you but then I would be the one "coding a program multilanguage"

    It is all there in the docs: Linguist manual

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

    nthung (13th 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 ChrisW67 View Post
    I could create "a data" for you but then I would be the one "coding a program multilanguage"
    It is all there in the docs: Linguist manual
    This is may data, but it is still errors

    Qt Code:
    1. <!DOCTYPE TS><TS>
    2. <defaultcodec>iso8859-1</defaultcodec>
    3. <context>
    4. <name>QRadioButton</name>
    5. <message>
    6. <source>English</source>
    7. <translation type="unfinished">Xin </translation>
    8. </message>
    9. <name>QRadioButton</name>
    10. <message>
    11. <source>Swedish</source>
    12. <translation type="unfinished">Xin2 </translation>
    13. </message>
    14. </context>
    15. </TS>
    To copy to clipboard, switch view to plain text mode 

    THanks

  5. #4
    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??

    Are we supposed to guess what you are doing with that file, what is generating an error message, and what that message is?

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

    nthung (13th October 2011)

  7. #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 ChrisW67 View Post
    Are we supposed to guess what you are doing with that file, what is generating an error message, and what that message is?
    When i open it by
    Qt Code:
    1. Qt Linguist
    To copy to clipboard, switch view to plain text mode 
    it has no error or warning.

  8. #6
    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??

    Uh huh. So what is the problem then?

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

    nthung (13th October 2011)

  10. #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 ChrisW67 View Post
    Uh huh. So what is the problem then?
    Sory

    Could you give me an full example with its data?
    Thanks

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

    Default Re: QTranslator??

    Quote Originally Posted by nthung View Post
    Sory

    Could you give me an full example with its data?
    Thanks
    Example of a problem?
    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.


  12. #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??

    I like this problem: Fermat's Last Theorem Simple statement of problem, devilishly complex answer

    The pro file:
    Qt Code:
    1. TEMPLATE = app
    2. TARGET =
    3. DEPENDPATH += .
    4. INCLUDEPATH += .
    5.  
    6. # Input
    7. SOURCES += main.cpp
    8.  
    9. TRANSLATIONS += \
    10. simple_example_es.ts \
    11. simple_example_fr.ts
    To copy to clipboard, switch view to plain text mode 
    The program:
    Qt Code:
    1. #include <QtCore>
    2. #include <QDebug>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QCoreApplication app(argc, argv);
    7.  
    8. QTranslator translator;
    9. translator.load("simple_example_es");
    10. // translator.load("simple_example_fr");
    11. app.installTranslator(&translator);
    12.  
    13. qDebug() << QObject::tr("It is easy enough!");
    14.  
    15. return app.exec();
    16. }
    To copy to clipboard, switch view to plain text mode 
    Then:
    Qt Code:
    1. qmake
    2. lupdate simple_example.pro
    3. linguist simple_example_es.ts // input your translations to Spanish and mark as finished
    4. linguist simple_example_fr.ts // ditto for French
    5. lrelease simple_example.pro
    6. make
    7. ./simple_example
    To copy to clipboard, switch view to plain text mode 
    Output:
    Qt Code:
    1. "Es muy fácil!"
    To copy to clipboard, switch view to plain text mode 
    Try changing the loaded translation.

    Apologies to any Spanish speakers if I have mangled your language... that's a Google Translate.

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

    nthung (14th October 2011)

  14. #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??

    thanks so much.
    Could you post data for me to run.?Because i don't see an example about data.
    this is an example
    http://doc.qt.nokia.com/latest/linguist-trollprint.html
    but i can not run it as introduction.
    Last edited by nthung; 14th October 2011 at 09:09.

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

    Default Re: QTranslator??

    What data do you want? Chris gave you a complete example with all the 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.


  16. #12
    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.

  17. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 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.


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

    nthung (14th October 2011)

  19. #14
    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.

  20. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 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.


  21. #16
    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 

  22. #17
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 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.


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

    nthung (14th October 2011)

  24. #18
    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 

  25. #19
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 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.


  26. #20
    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 

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.