Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. India
  4. How to translate a string into hindi
QtWS25 Last Chance

How to translate a string into hindi

Scheduled Pinned Locked Moved India
9 Posts 4 Posters 5.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    arkenoid
    wrote on 3 Apr 2013, 08:43 last edited by
    #1

    hello all..
    i am new to qt. and i want to convert the english text to hindi. But i couldnot find any devnagari family supported in Qfont..
    I could convert text into various fonts like times new roman, sans serif etc, but not in hindi..

    @ QFont f("Dev Kruti 010",12,QFont::Bold);
    QFont g("Times New Roman",12,QFont::Bold);
    ui->hindiEdit->setFont(f);
    ui->englishEdit->setFont(g);@

    But i could get hindi font in hindiEdit, rather some english family font is displayed..
    can anyone help me in this?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      arkenoid
      wrote on 3 Apr 2013, 08:48 last edited by
      #2

      I also tried using Qtextcodec but could not succed in this...

      @QString encoded_string = "blah blah"; // Some ISO 8859-5 encoded text.
      QTextCodec::setCodecForLocale(QTextCodec::codecForName("U-0973"));
      QByteArray string = QTextCodec::fromUnicode("ram");//QTextCodec::fromUnicode("encoded_string");
      ui->hindiEdit->setText(string);@

      here error is generated like this one:
      @/home/hello50/mainwindow.cpp:26: error: cannot call member function 'QByteArray QTextCodec::fromUnicode(const QString&) const' without object@

      I could not identify the error in this.. and hence unable to resolve the error.. can any one help me ?

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vishu
        wrote on 1 Aug 2013, 05:58 last edited by
        #3

        hello @arkenold.. i too stuck here only can you explain if you have solved it please....(basically i want to display kannada language)

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dreamerindia
          wrote on 2 Aug 2013, 06:32 last edited by
          #4

          May be this links help you...

          "http://qt-project.org/wiki/How_to_create_a_multi_language_application":http://qt-project.org/wiki/How_to_create_a_multi_language_application

          "http://qt-project.org/forums/viewthread/7236":http://qt-project.org/forums/viewthread/7236

          ~Ravivarman~

          1 Reply Last reply
          0
          • V Offline
            V Offline
            vishu
            wrote on 2 Aug 2013, 06:35 last edited by
            #5

            Thanks for your reply, in Qt 4.8.1 i got it done by all languages but in Qt 5.0.2 its somewhat bit hectic to do.. so trying out it..
            Thanks

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dreamerindia
              wrote on 2 Aug 2013, 06:39 last edited by
              #6

              you can aslo see qtranslator.may be below code helps you.

              @#include <iostream.h>
              #include <qapplication.h>
              #include <qtranslator.h>
              #include <qlabel.h>
              #include <qpushbutton.h>
              #include <qlayout.h>
              #include <qmultilineedit.h>
              #include <qmenubar.h>
              #include <qpopupmenu.h>

              class ExampleWidget : public QWidget
              {
              public:
              ExampleWidget( QWidget *parent = 0, const char *name = 0 );
              ~ExampleWidget();
              private:
              };

              ExampleWidget::ExampleWidget( QWidget *parent, const char *name )
              : QWidget( parent, name )
              {

              QBoxLayout *topLayout = new QVBoxLayout( this, 5 );

              QMenuBar menubar = new QMenuBar( this );
              menubar->setSeparator( QMenuBar::InWindowsStyle );
              QPopupMenu
              popup;
              popup = new QPopupMenu( this );
              popup->insertItem( tr("&Quit"), qApp, SLOT(quit()) );
              menubar->insertItem( tr("&File"), popup );

              topLayout->setMenuBar( menubar );

              QBoxLayout *buttons = new QHBoxLayout( topLayout);

              int i;
              for ( i = 1; i <= 4; i++ ) {

              QPushButton* but = new QPushButton( this );
              QString s = tr("Button %1").arg(i);
              but->setText( s );

              buttons->addWidget( but, 10 );
              }

              QMultiLineEdit *bigWidget = new QMultiLineEdit( this );
              bigWidget->setText( tr("This widget will get all the remaining space") );
              bigWidget->setFrameStyle( QFrame::Panel | QFrame::Plain );

              topLayout->addWidget( bigWidget);

              QLabel* sb = new QLabel( this );
              sb->setText(tr("Let's pretend this is a status bar"));
              sb->setFrameStyle( QFrame::Panel | QFrame::Sunken );
              sb->setFixedHeight( sb->sizeHint().height() );
              sb->setAlignment( AlignVCenter | AlignLeft );

              topLayout->addWidget( sb );

              topLayout->activate();
              }

              ExampleWidget::~ExampleWidget()
              {
              }

              int main( int argc, char **argv )
              {
              QApplication a( argc, argv );

              if(argc < 2) {
              cout << "Usage: ./i18n -[gb|big5]\n";
              exit(1);
              }

              a.setFont(QFont("Times", 16, QFont::Normal));

              QTranslator *translator = new QTranslator(0);
              if(!strcmp(argv[1], "-gb")){

              translator->load("i18n_gb.qm", ".");
              } else if(!strcmp(argv[1], "-big5")){

              translator->load("i18n_big5.qm", ".");
              }
              a.installTranslator(translator);

              ExampleWidget f;
              a.setMainWidget(&f);
              f.show();

              return a.exec();
              }
              @

              ~Ravivarman~

              1 Reply Last reply
              0
              • V Offline
                V Offline
                vishu
                wrote on 2 Aug 2013, 07:31 last edited by
                #7

                Thanks for your reply..
                actually my UI is done in QML file.. and in and i generated the .ts files and released the .qm files also but still it displaying the boxes,,, But the same code working for QT 4.8.1. not for 5.0.1

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  vishu
                  wrote on 28 Aug 2013, 11:43 last edited by
                  #8

                  I have solved it three weeks back it has been done dynamically too..

                  thanks

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    praveen0991kr
                    wrote on 4 Feb 2014, 11:03 last edited by
                    #9

                    vishu can u share your example I am searching for the same application if yes mail me at--: praveen0991kr@gmail.com

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved