QtCraft API C++ classes QML types Handbook

QcChatText Namespace

Translatable chat lines and disconnect reasons of the server (decision E-094). More...

Header: #include <common/protocol/QcChatText.h>

Variables

const char[17] context
const QLatin1StringView messageKeyPrefix

Functions

QcMsg::ChatMessage counted(const char *key, int count, const QStringList &arguments = {})
QcMsg::Disconnect disconnect(const char *key, const QStringList &arguments = {})
QString display(const QcMsg::ChatMessage &message)
QString display(const QcMsg::Disconnect &message)
QString display(const QcMsg::ChatMessage &message, const std::function<QString (const QString &)> &contentText)
QString format(QStringView pattern, const QStringList &arguments)
QcMsg::ChatMessage message(const char *key, const QStringList &arguments = {})
QcMsg::ChatMessage message(const char *key, const QStringList &arguments, const QStringList &contentKeys)
QString messageKey(const char *key)
QcMsg::ChatMessage plain(const QString &text)

Detailed Description

The server sends a key, which is the English text with %1.. placeholders marked with QT_TRANSLATE_NOOP in context, and its arguments; the client translates the key and fills in the arguments. The message also carries the filled-in English text for lines without a key (player chat, free-form warnings).

Variable Documentation

const char[17] QcChatText::context

The translation context of the keys.

const QLatin1StringView QcChatText::messageKeyPrefix

The entry of QcMsg::ChatMessage::contentKeys for an argument that is itself a server message (key marked with QT_TRANSLATE_NOOP in context, the argument its English text): the client shows it translated (decision E-911; /help's lines of a command and its description).

Function Documentation

QcMsg::ChatMessage QcChatText::counted(const char *key, int count, const QStringList &arguments = {})

Returns a keyed line with a count: key (marked with QT_TRANSLATE_N_NOOP in context) has %n for count besides its %1.. arguments; the count travels as the last argument, and the client picks the plural form of its language.

QcMsg::Disconnect QcChatText::disconnect(const char *key, const QStringList &arguments = {})

Returns a Disconnect whose reason is the keyed line of key with arguments, as message() makes it.

QString QcChatText::display(const QcMsg::ChatMessage &message)

Returns the text of message to show: the translated key with its arguments, or the plain text.

QString QcChatText::display(const QcMsg::Disconnect &message)

Returns the reason of message to show, as for a chat line.

QString QcChatText::display(const QcMsg::ChatMessage &message, const std::function<QString (const QString &)> &contentText)

Returns the same with the content texts of the arguments that stand for one: contentText gives the text of a content key (empty when it knows none, then the argument stays).

QString QcChatText::format(QStringView pattern, const QStringList &arguments)

Returns pattern with %1 .. %99 replaced by arguments in one pass (arguments are not scanned again); placeholders without an argument stay as they are.

QcMsg::ChatMessage QcChatText::message(const char *key, const QStringList &arguments = {})

Returns a keyed line with arguments; key must be marked with QT_TRANSLATE_NOOP("QcServerMessages", ...).

QcMsg::ChatMessage QcChatText::message(const char *key, const QStringList &arguments, const QStringList &contentKeys)

Returns a keyed line whose arguments may stand for content texts (QcMsg::ChatMessage::contentKeys, decision E-873): contentKeys as long as arguments, empty entries for plain arguments.

QString QcChatText::messageKey(const char *key)

Returns the entry of QcMsg::ChatMessage::contentKeys for the server message key: messageKeyPrefix followed by key.

QcMsg::ChatMessage QcChatText::plain(const QString &text)

Returns an untranslated line of text (player chat, warnings from files).