返回介绍

QTranslatorMessage Class

发布于 2019-10-04 15:03:42 字数 8019 浏览 973 评论 0 收藏 0

The API for this class is under development and is subject to change.
We do not recommend the use of this class for production work at this time.

The QTranslatorMessage class contains a translator message and its properties. More...

#include <qtranslator.h>

List of all member functions.

Public Members

  • QTranslatorMessage ()
  • QTranslatorMessage ( constchar*context, constchar*sourceText, constchar*comment, constQString&translation = QString::null )
  • QTranslatorMessage ( QDataStream&stream )
  • QTranslatorMessage ( constQTranslatorMessage&m )
  • QTranslatorMessage & operator= ( constQTranslatorMessage&m )
  • uint hash () const
  • const char * context () const
  • const char * sourceText () const
  • const char * comment () const
  • void setTranslation ( constQString&translation )
  • QString translation () const
  • enum Prefix { NoPrefix, Hash, HashContext, HashContextSourceText, HashContextSourceTextComment }
  • void write ( QDataStream&stream, boolstrip = FALSE, Prefixprefix = HashContextSourceTextComment ) const
  • Prefix commonPrefix ( constQTranslatorMessage&m ) const
  • bool operator== ( constQTranslatorMessage&m ) const
  • bool operator!= ( constQTranslatorMessage&m ) const
  • bool operator< ( constQTranslatorMessage&m ) const
  • bool operator<= ( constQTranslatorMessage&m ) const
  • bool operator> ( constQTranslatorMessage&m ) const
  • bool operator>= ( constQTranslatorMessage&m ) const

Detailed Description

The QTranslatorMessage class contains a translator message and its properties.

This class is of no interest to most applications. It is useful for translation tools such as Qt Linguist. It is provided simply to make the API complete and regular.

For a QTranslator object, a lookup key is a triple (context, source text, comment) that uniquely identifies a message. An extended key is a quadruple (hash, context, source text, comment), where hash is computed from the source text and the comment. Unless you plan to read and write messages yourself, you need not worry about the hash value.

QTranslatorMessage stores this triple or quadruple and the relevant translation if there is any.

See also QTranslator, Environment Classes and Internationalization with Qt.


Member Type Documentation

QTranslatorMessage::Prefix

Let (h, c, s, m) be the extended key. The possible prefixes are

  • QTranslatorMessage::NoPrefix - no prefix
  • QTranslatorMessage::Hash - only (h)
  • QTranslatorMessage::HashContext - only (h, c)
  • QTranslatorMessage::HashContextSourceText - only (h, c, s)
  • QTranslatorMessage::HashContextSourceTextComment - the whole extended key, (h, c, s, m)

See also write() and commonPrefix().


Member Function Documentation

QTranslatorMessage::QTranslatorMessage ()

Constructs a translator message with the extended key (0, 0, 0, 0) and QString::null as translation.

QTranslatorMessage::QTranslatorMessage ( constchar*context, constchar*sourceText, constchar*comment, constQString&translation = QString::null )

Constructs an translator message with the extended key (h, context, sourceText, comment), where h is computed from sourceText and comment, and possibly with a translation.

QTranslatorMessage::QTranslatorMessage ( QDataStream&stream )

Constructs a translator message read from the stream. The resulting message may have any combination of content.

See also QTranslator::save().

QTranslatorMessage::QTranslatorMessage ( constQTranslatorMessage&m )

Constructs a copy of translator message m.

const char * QTranslatorMessage::comment () const

Returns the comment for this message (e.g. "File|Save").

Prefix QTranslatorMessage::commonPrefix ( constQTranslatorMessage&m ) const

Returns the widest lookup prefix that is common to this translator message and to message m.

For example, if the extended key is for this message is (71, "PrintDialog", "Yes", "Print?") and that for m is (71, "PrintDialog", "No", "Print?"), this function returns HashContext.

See also write().

const char * QTranslatorMessage::context () const

Returns the context for this message (e.g. "MyDialog").

uint QTranslatorMessage::hash () const

Returns the hash value used internally to represent the lookup key. This value is zero only if this translator message was constructed from a stream containing invalid data.

The hashing function is unspecified, but it will remain unchanged in future versions of Qt.

bool QTranslatorMessage::operator!= ( constQTranslatorMessage&m ) const

Returns TRUE if the extended key of this object is different from that of m; otherwise returns FALSE.

bool QTranslatorMessage::operator< ( constQTranslatorMessage&m ) const

Returns TRUE if the extended key of this object is lexicographically before than that of m; otherwise returns FALSE.

bool QTranslatorMessage::operator<= ( constQTranslatorMessage&m ) const

Returns TRUE if the extended key of this object is lexicographically before that of m or if they are equal; otherwise returns FALSE.

QTranslatorMessage& QTranslatorMessage::operator= ( constQTranslatorMessage&m )

Assigns message m to this translator message and returns a reference to this translator message.

bool QTranslatorMessage::operator== ( constQTranslatorMessage&m ) const

Returns TRUE if the extended key of this object is equal to that of m; otherwise returns FALSE.

bool QTranslatorMessage::operator> ( constQTranslatorMessage&m ) const

Returns TRUE if the extended key of this object is lexicographically after that of m; otherwise returns FALSE.

bool QTranslatorMessage::operator>= ( constQTranslatorMessage&m ) const

Returns TRUE if the extended key of this object is lexicographically after that of m or if they are equal; otherwise returns FALSE.

void QTranslatorMessage::setTranslation ( constQString&translation )

Sets the translation of the source text to translation.

See also translation().

const char * QTranslatorMessage::sourceText () const

Returns the source text of this message (e.g. "&Save").

QString QTranslatorMessage::translation () const

Returns the translation of the source text (e.g., "&Sauvegarder").

See also setTranslation().

void QTranslatorMessage::write ( QDataStream&stream, boolstrip = FALSE, Prefixprefix = HashContextSourceTextComment ) const

Writes this translator message to the stream. If strip is FALSE (the default), all the information in the message is written. If strip is TRUE, only the part of the extended key specified by prefix is written with the translation (HashContextSourceTextComment by default).

See also commonPrefix().

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文