<QtTranslation>

번역 대상 문자열 표시. 더 보기...

Header: #include <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 로 식별되는 번역된 문자열을 반환합니다. 일치하는 문자열이 발견되지 않으면 id 자체를 반환합니다. 정상적인 상황에서는 이런 일이 발생해서는 안 됩니다.

n 이 0 이상인 경우, 결과 문자열에서 %n 가 나타나는 모든 위치가 n 의 10진수 표현으로 대체됩니다. 또한, 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를 이용한 국제화.

매크로 문서

QT_TRANSLATE_NOOP3(context, sourceText, disambiguation)

UTF-8로 인코딩된 문자열 리터럴 sourceText 을, 지정된 context 에서 지정된 disambiguation 을 사용하여 지연 번역되도록 표시합니다. context 은 일반적으로 클래스이며, 문자열 리터럴로 지정되어야 합니다. 문자열 리터럴 disambiguation 은 외관상 동일한 문자열을 구별하기 위한 짧은 의미론적 태그여야 합니다.

이 매크로는 lupdate가 해당 문자열을 수집하도록 지시하며, sourceText 및 disambiguation 로 전달된 두 문자열 리터럴로 구성된 익명 구조체로 확장됩니다.

예시:

static struct { 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를 이용한 국제화항목도 참조하십시오 .

QT_TRANSLATE_NOOP(context, sourceText)

UTF-8로 인코딩된 문자열 리터럴 sourceText 을 지정된 context 에서 지연 번역되도록 표시합니다. 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를 이용한 국제화항목도 참조하십시오 .

QT_TRANSLATE_N_NOOP3(context, sourceText, comment)

주어진 context 에서 주어진 comment 을 사용하여 분자 의존 지연 변환을 위해 UTF-8로 인코딩된 문자열 리터럴 sourceText 을 표시합니다. context 은 일반적으로 클래스이며, 문자열 리터럴로 지정되어야 합니다. 문자열 리터럴 comment 은 외관상 동일한 문자열을 구별하기 위한 짧은 의미론적 태그여야 합니다.

이 매크로는 lupdate가 해당 문자열을 수집하도록 지시하며, sourceText 및 comment 로 전달된 두 문자열 리터럴로 구성된 익명 구조체로 확장됩니다.

예시:

static struct { 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를 이용한 국제화항목도 참조하십시오 .

QT_TRANSLATE_N_NOOP(context, sourceText)

주어진 ` context`에서 분자(numerator)에 의존적인 지연 변환을 위해 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를 이용한 국제화항목도 참조하십시오 .

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를 이용한 국제화항목도 참조하십시오 .

[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)

현재 컨텍스트(클래스)에서 sourceText 라는 UTF-8 인코딩된 문자열 리터럴을 지연 번역 대상으로 지정합니다.

이 매크로는 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를 이용한 국제화항목도 참조하십시오 .

QT_TR_N_NOOP(sourceText)

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

이 매크로는 lupdate가 해당 문자열을 수집하도록 지시하며, sourceText 자체로 확장됩니다.

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

예시:

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_NOOP 및 Qt를 이용한 국제화항목도 참조하십시오 .

© 2026 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.