<QtTranslation> 프록시 페이지

함수

QString qtTrId(const char *id, int n = -1)

매크로

QT_TRANSLATE_NOOP3(context, sourceText, disambiguation)
QT_TRANSLATE_NOOP(context, sourceText)
QT_TRANSLATE_N_NOOP3(context, sourceText, comment)
QT_TRANSLATE_N_NOOP(context, sourceText)
QT_TRID_NOOP(id)
(since 6.3) QT_TRID_N_NOOP(id)
QT_TR_NOOP(sourceText)
QT_TR_N_NOOP(sourceText)

함수 문서

QString qtTrId(const char *id, int n = -1)

qtTrId 함수는 번역된 문자열을 찾아서 반환합니다.

id 로 식별되는 번역된 문자열을 반환합니다. 일치하는 문자열을 찾지 못하면 아이디 자체가 반환됩니다. 정상적인 조건에서는 이런 일이 발생하지 않아야 합니다.

n >= 0인 경우 결과 문자열에서 %n 의 모든 항목은 n 의 소수점 표현으로 대체됩니다. 또한 n 의 값에 따라 번역 텍스트가 달라질 수 있습니다.

메타 데이터 및 주석은 QObject::tr()에 대해 문서화된 대로 전달할 수 있습니다. 또한 이와 같은 소스 문자열 템플릿을 제공할 수도 있습니다:

//% <C string>

또는

\begincomment% <C string> \endcomment

예시:

    //% "%n fooish bar(s) found.\n"
    //% "Do you want to continue?"
    QString text = qtTrId("qtn_foo_bar", n);

이 함수에 사용하기에 적합한 QM 파일을 만들려면 lrelease 도구에 -idbased 옵션을 전달해야 합니다.

경고: 이 메서드를 호출하기 전에 모든 번역기가 설치된 경우에만 이 메서드가 다시 입력됩니다. 번역을 수행하는 동안 번역기를 설치하거나 제거하는 것은 지원되지 않습니다. 그렇게 하면 충돌이나 기타 바람직하지 않은 동작이 발생할 수 있습니다.

참고: 이 함수는 재진입입니다.

QObject::tr(), QCoreApplication::translate() 및 Qt XML로 국제화를참조하세요 .

매크로 문서

QT_TRANSLATE_NOOP3(context, sourceText, disambiguation)

주어진 context 을 주어진 disambiguation 으로 지연 번역하기 위해 UTF-8로 인코딩된 문자열 리터럴 sourceText 을 표시합니다. context 은 일반적으로 클래스이며 문자열 리터럴로도 지정해야 합니다. 문자열 리터럴 disambiguation 은 동일한 문자열을 구분하기 위한 짧은 시맨틱 태그여야 합니다.

매크로는 lupdate에게 문자열을 수집하도록 지시하고 sourceTextdisambiguation 으로 전달된 두 문자열 리터럴의 익명 구조체로 확장합니다.

예시:

static { const char *source; const char *comment; } greeting_strings[] =
{
    QT_TRANSLATE_NOOP3("FriendlyConversation", "Hello",
                       "A really friendly hello"),
    QT_TRANSLATE_NOOP3("FriendlyConversation", "Goodbye",
                       "A really friendly goodbye")
};

QString FriendlyConversation::greeting(int type)
{
    return tr(greeting_strings[type].source,
              greeting_strings[type].comment);
}

QString global_greeting(int type)
{
    return qApp->translate("FriendlyConversation",
                           greeting_strings[type].source,
                           greeting_strings[type].comment);
}

QT_TR_NOOP(), QT_TRANSLATE_NOOP() 및 Qt XML을 사용한 국제화를참조하십시오 .

QT_TRANSLATE_NOOP(context, sourceText)

주어진 context 에서 지연 번역을 위해 UTF-8로 인코딩된 문자열 리터럴 sourceText 을 표시합니다. context 은 일반적으로 클래스 이름이며 문자열 리터럴로도 지정해야 합니다.

이 매크로는 lupdate에 문자열을 수집하도록 지시하고 sourceText 자체로 확장합니다.

예시:

static const char *greeting_strings[] = {
    QT_TRANSLATE_NOOP("FriendlyConversation", "Hello"),
    QT_TRANSLATE_NOOP("FriendlyConversation", "Goodbye")
};

QString FriendlyConversation::greeting(int type)
{
    return tr(greeting_strings[type]);
}

QString global_greeting(int type)
{
    return qApp->translate("FriendlyConversation",
                           greeting_strings[type]);
}

QT_TR_NOOP(), QT_TRANSLATE_NOOP3() 및 Qt XML을 사용한 국제화를참조하십시오 .

QT_TRANSLATE_N_NOOP3(context, sourceText, comment)

주어진 context 에서 주어진 comment 을 사용하여 UTF-8 인코딩된 문자열 리터럴 sourceText 을 분자에 종속된 지연 번역으로 표시합니다. context 은 일반적으로 클래스이며 문자열 리터럴로도 지정해야 합니다. 문자열 리터럴 comment 은 동일한 문자열을 구분하기 위한 짧은 시맨틱 태그여야 합니다.

매크로는 lupdate에게 문자열을 수집하도록 지시하고 sourceTextcomment 으로 전달된 두 문자열 리터럴의 익명 구조체로 확장합니다.

예시:

static { const char * const source; const char * const comment; } status_strings[] = {
    QT_TRANSLATE_N_NOOP3("Message Status", "Hello, you have %n message(s)",
                         "A login message status"),
    QT_TRANSLATE_N_NOOP3("Message status", "You have %n new message(s)",
                         "A new message query status")
};

QString FriendlyConversation::greeting(int type, int count)
{
    return tr(status_strings[type].source,
              status_strings[type].comment, count);
}

QString global_greeting(int type, int count)
{
    return qApp->translate("Message Status",
                           status_strings[type].source,
                           status_strings[type].comment,
                           count);
}

QT_TR_NOOP(), QT_TRANSLATE_NOOP(), QT_TRANSLATE_NOOP3() 및 Qt XML을 사용한 국제화를참조하십시오 .

QT_TRANSLATE_N_NOOP(context, sourceText)

주어진 context 에서 분자 종속 지연 번역을 위해 UTF-8 인코딩된 문자열 리터럴 sourceText 을 표시합니다. context 은 일반적으로 클래스 이름이며 문자열 리터럴로도 지정해야 합니다.

이 매크로는 lupdate에 문자열을 수집하도록 지시하고 sourceText 자체로 확장합니다.

예시:

static const char * const greeting_strings[] = {
    QT_TRANSLATE_N_NOOP("Welcome Msg", "Hello, you have %n message(s)"),
    QT_TRANSLATE_N_NOOP("Welcome Msg", "Hi, you have %n message(s)")
};

QString global_greeting(int type, int msgcnt)
{
    return translate("Welcome Msg", greeting_strings[type], nullptr, msgcnt);
}

QT_TRANSLATE_NOOP(), QT_TRANSLATE_N_NOOP3() 및 Qt XML을 사용한 국제화를참조하십시오 .

QT_TRID_NOOP(id)

QT_TRID_NOOP 매크로는 동적 번역을 위한 ID를 표시합니다.

이 매크로의 유일한 목적은 qtTrId()와 같은 메타 데이터를 첨부하기 위한 앵커를 제공하는 것입니다.

매크로는 id 로 확장됩니다.

예시:

static const char * const ids[] = {
    //% "This is the first text."
    QT_TRID_NOOP("qtn_1st_text"),
    //% "This is the second text."
    QT_TRID_NOOP("qtn_2nd_text"),
    0
};

void TheClass::addLabels()
{
    for (int i = 0; ids[i]; ++i)
        new QLabel(qtTrId(ids[i]), this);
}

qtTrId() 및 Qt XML을 사용한 국제화를참조하십시오 .

[since 6.3] QT_TRID_N_NOOP(id)

QT_TRID_N_NOOP 매크로는 분자에 의존하는 동적 번역을 위한 ID를 표시합니다.

이 매크로의 유일한 목적은 qtTrId()와 같은 메타 데이터를 첨부하기 위한 앵커를 제공하는 것입니다.

매크로는 id 로 확장됩니다.

예제:

static const char * const ids[] = {
    //% "%n foo(s) found."
    QT_TRID_N_NOOP("qtn_foo"),
    //% "%n bar(s) found."
    QT_TRID_N_NOOP("qtn_bar"),
    0
};

QString result(int type, int n)
{
    return qtTrId(ids[type], n);
}

이 매크로는 Qt 6.3에 도입되었습니다.

qtTrId() 및 Qt를 사용한 국제화를참조하십시오 .

QT_TR_NOOP(sourceText)

현재 컨텍스트(클래스)에서 지연된 번역을 위해 UTF-8로 인코딩된 문자열 리터럴 sourceText 을 표시합니다.

이 매크로는 lupdate에 문자열을 수집하도록 지시하고 sourceText 자체로 확장합니다.

예시:

QString FriendlyConversation::greeting(int type)
{
    static const char *greeting_strings[] = {
        QT_TR_NOOP("Hello"),
        QT_TR_NOOP("Goodbye")
    };
    return tr(greeting_strings[type]);
}

매크로 QT_TR_NOOP_UTF8()은 동일하며 더 이상 사용되지 않으며, 다른 모든 _UTF8 매크로에도 적용됩니다.

QT_TRANSLATE_NOOP() 및 Qt XML을 사용한 국제화를참조하십시오 .

QT_TR_N_NOOP(sourceText)

현재 컨텍스트(클래스)에서 분자 종속 지연 번역을 위해 UTF-8로 인코딩된 문자열 리터럴 sourceText 을 표시합니다.

매크로는 lupdate에 문자열을 수집하도록 지시하고 sourceText 자체로 확장합니다.

매크로는 sourceText 로 확장됩니다.

예제:

static const char * const StatusClass::status_strings[] = {
    QT_TR_N_NOOP("There are %n new message(s)"),
    QT_TR_N_NOOP("There are %n total message(s)")
};

QString StatusClass::status(int type, int count)
{
    return tr(status_strings[type], nullptr, count);
}

QT_TR_NOOPQt XML을 사용한 국제화를참조하십시오 .

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.