QT Translatoion => How to Include macros in .ts language files
-
#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];
}
} -
Hi,
Can you share your project's setup information ?