Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can't apply translation for some files.
Qt 6.11 is out! See what's new in the release blog

Can't apply translation for some files.

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 3.2k Views 1 Watching
  • 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
    Anticross
    wrote on last edited by
    #1

    I have ts file with translation of many files including @RoutingPhonesModel.h@ file. But translation for this file don't applies. The following code: @ public: QVariant headerData(int section, Qt::Orientation orientation, int role) const {
    if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
    switch(section) {
    case ePort: return tr("Port");
    case eType: return tr("Type");
    case eNote: return tr("Note");
    case ePhone: return tr("Phone");
    }
    return QVariant();
    }@
    is shown in linguist as translated. But when program executes in this place I see original text w/o translation.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      Have you executed lrelease? It will produces QM files out of TS files. For more details please have a look at "Qt Linguist Manual":http://qt-project.org/doc/qt-4.8/linguist-manager.html.

      http://anavi.org/

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Anticross
        wrote on last edited by
        #3

        bq. Have you executed lrelease? It will produces QM files out of TS files. For more details please have a look at Qt Linguist Manual [qt-project.org].

        Yes, I execute lupdate, then make translation and then execute lrelease. But translation applied not to all files. Maybe something wrong with code or settings in Visual Studio addin.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          leon.anavi
          wrote on last edited by
          #4

          [quote author="Anticross" date="1352104364"]
          Yes, I execute lupdate, then make translation and then execute lrelease. But translation applied not to all files. Maybe something wrong with code or settings in Visual Studio addin.[/quote]

          Please try to run qmake before running lupdate. And finally run lrelease.

          http://anavi.org/

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giesbert
            wrote on last edited by
            #5

            [quote author="Anticross" date="1352099322"]I have ts file with translation of many files including @RoutingPhonesModel.h@ file. But translation for this file don't applies. The following code: @ public: QVariant headerData(int section, Qt::Orientation orientation, int role) const {
            if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
            switch(section) {
            case ePort: return tr("Port");
            case eType: return tr("Type");
            case eNote: return tr("Note");
            case ePhone: return tr("Phone");
            }
            return QVariant();
            }@
            is shown in linguist as translated. But when program executes in this place I see original text w/o translation.[/quote]

            Might be that you have an inline problem with the translation.
            In general, I would never make virtual methods (which means all methods of a model) inline.

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Anticross
              wrote on last edited by
              #6

              Class RoutingPhonesModel inhreits QAbstractItemModel @class RoutingPhonesModel : public QAbstractItemModel@ And hederData method is realisation. So I don't know how can a make this realization otherwise.

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                Are you sure that the translator is created before the RoutingPhonesModel is created?

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  Anticross
                  wrote on last edited by
                  #8

                  bq. Are you sure that the translator is created before the RoutingPhonesModel is created?

                  What do you mean ? I install translator before all application windows created:
                  @QApplication::setWindowIcon(QPixmap(":/Images/logo.png"));

                  // language choose and apply
                  const Descriptor & descriptor = GET_DOCUMENT(DocOptions).getDescriptor(PROP_GENERAL);
                  DescriptionPtr description = descriptor.value(PROP_LANGUAGE);
                  int langID = description->value(PROP_VALUE).toInt();
                  
                  Properties props = GET_DOCUMENT(DocLanguages).getLanguageByID(langID);
                  
                  QTranslator local(0);
                  local.load(props.valueS(PROP_LOCAL), ".");
                  
                  QTranslator core(0);
                  core.load(props.valueS(PROP_CORE), ".");
                  
                  a.installTranslator(&core);
                  a.installTranslator(&local);
                  
                  //end
                  
                  MainWindow w;
                  w.show();
                  w.updateAutorisationUI();
                  w.start();
                  return a.exec();
                  

                  @

                  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