Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    QT Translatoion => How to Include macros in .ts language files

    General and Desktop
    transparentbord translations transfer transform transforms pain
    2
    3
    1049
    Loading More Posts
    • 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
      Atdhe last edited by

      #include "questions.h"
      #include <QTranslator>
      #include <QString>
      #include <QtGlobal>
      #include <QtDebug>

      static const char * const qdefault[] = {
      QT_TR_NOOP("Was steht auf deiner Visitenkarte?"),
      QT_TR_NOOP("Worum geht’s in deinem Job?"),
      QT_TR_NOOP("Wie schaut dein Werdegang aus?"),
      QT_TR_NOOP("Ginge es auch ohne deinen Werdegang?"),
      QT_TR_NOOP("Was ist das Coolste an deinem Job?"),
      QT_TR_NOOP("Welche Einschränkungen bringt der Job mit sich?"),
      QT_TR_NOOP("3 Ratschläge an dein 14-jähriges Ich?")
      };
      static const char * const qdefault_en[] = {
      QT_TR_NOOP("What's written on your business card?"),
      QT_TR_NOOP("What's your job about?"),
      QT_TR_NOOP("What's your background?"),
      QT_TR_NOOP("Could someone with a different background do your job?"),
      QT_TR_NOOP("What's the coolest thing about your job?"),
      QT_TR_NOOP("What are the limitations of your job?"),
      QT_TR_NOOP("3 pieces of advice for your 14-year-old self?")
      };
      static const char * const qdefault_it[] = {
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP("")
      };
      static const char * const qdefault_fr[] = {
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP("")
      };
      static const char * const qdefault_es[] = {
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP("")
      };
      static const char * const qstudent[] = {
      QT_TR_NOOP("Wer bist du und was machst du?"),
      QT_TR_NOOP("Worum geht's in deinem Studium?"),
      QT_TR_NOOP("Wie bist du zu diesem Studium gekommen?"),
      QT_TR_NOOP("Welche Voraussetzungen sind nötig?"),
      QT_TR_NOOP("Was ist das Coolste an deinem Studium?"),
      QT_TR_NOOP("Was ist die größte Herausforderung?"),
      QT_TR_NOOP("3 Dinge, die du nach deinem Studium machen möchtest?"),
      QT_TR_NOOP("Der wichtigste Ratschlag in deinem Leben?")
      };
      static const char * const qstudent_en[] = {
      QT_TR_NOOP("Who are you and what do you do?"),
      QT_TR_NOOP("What are your studies about?"),
      QT_TR_NOOP("How did you come to your studies?"),
      QT_TR_NOOP("What requirements are necessary?"),
      QT_TR_NOOP("What’s the coolest part about your studies?"),
      QT_TR_NOOP("What are the biggest limitations in your studies?"),
      QT_TR_NOOP("3 things you want to do after your studies?"),
      QT_TR_NOOP("The most important piece of advice for you?")
      };
      static const char * const qstudent_it[] = {
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP("")
      };
      static const char * const qstudent_fr[] = {
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP("")
      };
      static const char * const qstudent_es[] = {
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP(""),
      QT_TR_NOOP("")
      };

      // Länge der Fragen in millisekunden
      qint64 qdefault_len[]=
      {
      15000,
      120000,
      120000,
      30000,
      30000,
      30000,
      30000
      };
      qint64 qstudent_len[]=
      {
      15000,
      120000,
      120000,
      30000,
      30000,
      30000,
      30000,
      20000
      };

      questions::questions()
      {
      }
      int questions::count(const QString interviewtype)
      {
      if(!interviewtype.compare("standard"))
      {
      return sizeof(qdefault)/sizeof(const char * const);
      }
      else if(!interviewtype.compare("student"))
      {
      return sizeof(qstudent)/sizeof(const char * const);
      }
      return 0;
      }

      void questions::get(const QString interviewtype, const QString lang, int i, QString & ret)
      {
      if((i<0)||(i>=count(interviewtype))) return;
      if(!lang.compare("en"))
      {
      if(!interviewtype.compare("standard"))
      {
      ret.append(tr(qdefault_en[i]));
      }

          else if(!interviewtype.compare("student"))
          {
              ret.append(tr(qstudent_en[i]));
          }
      
      }
      else if(!lang.compare("it"))
      {
      
          if(!interviewtype.compare("standard"))
          {
              ret.append(tr(qdefault_it[i]));
          }
      
          else if(!interviewtype.compare("student"))
          {
              ret.append(tr(qstudent_it[i]));
          }
      }
      else if(!lang.compare("fr"))
      {
      
          if(!interviewtype.compare("standard"))
          {
              ret.append(tr(qdefault_fr[i]));
          }
      
          else if(!interviewtype.compare("student"))
          {
              ret.append(tr(qstudent_fr[i]));
          }
      }
      else if(!lang.compare("es"))
      {
      
          if(!interviewtype.compare("standard"))
          {
              ret.append(tr(qdefault_es[i]));
          }
      
          else if(!interviewtype.compare("student"))
          {
              ret.append(tr(qstudent_es[i]));
          }
      }
      else
      {
          if(!interviewtype.compare("standard"))
          {
              ret.append(tr(qdefault[i]));
          }
          else if(!interviewtype.compare("student"))
          {
              ret.append(tr(qstudent[i]));
          }
      }
      return ;
      

      }
      qint64 questions::getLength(const QString &interviewtype,int i)
      {
      if((i<0)||(i>=count(interviewtype))) return 0;
      if(!interviewtype.compare("standard"))
      {
      return qdefault_len[i];
      }
      else if(!interviewtype.compare("student"))
      {
      return qstudent_len[i];
      }
      }

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        Can you share your project's setup information ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • A
          Atdhe last edited by

          i cant share that, why its a private one, i just need to how to change this Qt_tr_noop to tr, and not include inside static i just want to use the tr().

          1 Reply Last reply Reply Quote 0
          • First post
            Last post