QtCraft API C++ classes QML types Handbook

QcTranslations Class

Texts of the content by language and key (part of QcContentRegistry). More...

Header: #include <common/content/registry/QcTranslations.h>

Public Functions

void add(const QString &language, const QHash<QString, QString> &entries)
qsizetype count(const QString &language) const
bool has(const QString &key, const QString &language) const
QStringList keys(const QString &language) const
QStringList languages() const
const QHash<QString, QHash<QString, QString>> &tables() const
qsizetype total() const
QString translate(const QString &key, const QString &language) const

Static Public Members

const char *const fallbackLanguage

Detailed Description

Packs add or override entries; a lookup falls back to English and finally to the key itself.

Member Function Documentation

void QcTranslations::add(const QString &language, const QHash<QString, QString> &entries)

Adds the key-text pairs entries to language, overriding texts of the same key.

qsizetype QcTranslations::count(const QString &language) const

Returns the number of texts in language.

bool QcTranslations::has(const QString &key, const QString &language) const

Returns whether language itself has a text for key (no fallback).

QStringList QcTranslations::keys(const QString &language) const

Returns every key with a text in language (no English fallback), sorted.

QStringList QcTranslations::languages() const

Returns the languages that have texts, in no particular order.

const QHash<QString, QHash<QString, QString>> &QcTranslations::tables() const

Returns the texts per language, then per key (the content sync writes them as they are).

qsizetype QcTranslations::total() const

Returns the number of entries of all languages together (bounded by QcStreamLimits::maxTranslations, decision E-371).

QString QcTranslations::translate(const QString &key, const QString &language) const

Returns the text of key in language; falls back to English and finally to the key itself.

Member Variable Documentation

const char *const QcTranslations::fallbackLanguage

The language a lookup falls back to.