×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    7

    Translation not showing - tr()

    I am trying to make a sample application that supports two languages.
    the problem i am facing is that its not showing translation.

    when i debuged it, found that translation file is not at its correct location

    98.600 Debug: Application path: "C:/Private/20059659"
    98.600 Debug: Binary path: "C:/Private/20059659"
    98.600 Debug: Found Translation_la: false

    i am using carbide and my translation file is in same folder with code files

    here is my code
    Code:
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
        qInstallMsgHandler(myMessageOutput);
        QTranslator translator(0);
        bool bFound = false;
        QDir dir(".");
        QString trPath;
        qDebug() << "Application path: " << dir.currentPath();
        qDebug() << "Binary path: " << QCoreApplication::applicationDirPath();
        trPath = QCoreApplication::applicationDirPath() + "Translation_la";
        bFound = translator.load(trPath);
        //bFound = translator.load("Translation_la");
        qDebug() << "Found Translation_la: " << bFound; 
        app.installTranslator(&translator);
        QPushButton hello(QPushButton::tr("Hello Translation World!"));
        hello.show();
        return app.exec();
    }
    here is my translation file

    HTML Code:
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE TS>
    <TS version="2.0" language="ur_PK" sourcelanguage="en_US">
    <context>
        <name>QPushButton</name>
        <message>
            <location filename="main.cpp" line="49"/>
            <source>Hello Translation World!</source>
            <translatorcomment>\u062e\u0648\u0634\u0020\u062a\u0631\u062c\u0645\u06c1\u0020\u0648\u0631\u0644\u0688!</translatorcomment>
            <translation>\u062e\u0648\u0634\u0020\u062a\u0631\u062c\u0645\u06c1\u0020\u0648\u0631\u0644\u0688!</translation>
        </message>
    </context>
    <context>
        <name>Translation</name>
        <message>
            <location filename="Translation.ui" line="13"/>
            <source>Translation</source>
            <translatorcomment>\u062a\u0631\u062c\u0645\u06c1</translatorcomment>
            <translation>\u062a\u0631\u062c\u0645\u06c1</translation>
        </message>
    </context>
    </TS>
    i have build .qm file using QT Linguist

  2. #2
    Nokia Developer Expert
    Join Date
    Feb 2008
    Posts
    183

    Re: Translation not showing - tr()

    You might wanna put debug print with your filename appended to the trPath. It might reveal that you are missing a "/" between path and your filename.

  3. #3
    Registered User
    Join Date
    May 2009
    Location
    Greece
    Posts
    191

    Re: Translation not showing - tr()

    May be the following two posts will help you:
    http://www.developer.nokia.com/Commu...ian&highlight=
    http://www.developer.nokia.com/Commu...ils&highlight=

    You have compiled the .ts files with Qt Linguist, the .qm files are generated but have you defined in the .pro file that the .qm files will be copied at the same directory as the executable (where the executable will be installed)?

    The following lines do what i mention:
    Code:
    symbian: {
    addFiles.sources = helloworld_fi.qm helloworld_en.qm
    addFiles.path = .
    DEPLOYMENT += addFiles
    }

  4. #4
    Registered User
    Join Date
    Aug 2011
    Posts
    7

    Re: Translation not showing - tr()

    you were right about the file path,

    21.585 Debug: Application path: "C:/Private/20059659"
    21.585 Debug: Binary path: "C:/Private/20059659"
    21.590 Debug: Found Translation_la: "C:/Private/20059659/Translation_la" false

    though it did not solve the problem, file is still not found

  5. #5
    Registered User
    Join Date
    Aug 2011
    Posts
    7

    Re: Translation not showing - tr()

    thanks favoritas37

    Quote Originally Posted by favoritas37 View Post
    Code:
    symbian: {
    addFiles.sources = helloworld_fi.qm helloworld_en.qm
    addFiles.path = .
    DEPLOYMENT += addFiles
    }
    this solved my problem, but translation is showing up as unicode i.e \u1234
    even when i used trUtf8();

    i have to look at that now.

  6. #6
    Registered User
    Join Date
    Apr 2009
    Posts
    506

    Re: Translation not showing - tr()

    because its better to use QApplication::translate() instread of tr()
    Symbian & Qt developer. http://vladest.org

Similar Threads

  1. Text translation
    By AndreiDutu in forum Qt
    Replies: 2
    Last Post: 2010-11-15, 14:50
  2. Grid icons not showing( Only numbers are showing)
    By Hitangshu in forum Symbian User Interface
    Replies: 2
    Last Post: 2009-03-24, 14:41
  3. languange translation
    By sandy_zeng in forum Symbian
    Replies: 3
    Last Post: 2007-10-28, 08:34
  4. Looking for translation software
    By isiebeck in forum Symbian
    Replies: 1
    Last Post: 2005-01-19, 18:24

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×