Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
TranslationLoader Namespace Reference

Functions

QList< QString > qtTranslationCandidates ()
 Every directory that may hold Qt's own translations, in order of preference.
QList< QString > qtTranslationPaths ()
 The candidates that actually exist, most likely first, so no caller searches a path that is not there.
QList< QString > applicationTranslationPaths (const QString &_installedPath)
 The directories to search for an application's own translation files, in order of preference.
TranslationLoadResult loadFrom (QTranslator &_translator, const QString &_nameHint, const QList< QString > &_directories)
 Loads the first _nameHint + language translation file found in _directories into _translator.
TranslationLoadResult loadQt (QTranslator &_translator, const QString &_lang)
 Loads Qt's own translation for _lang, which covers the strings of Qt's own dialogs.
QList< QString > availableLanguages (const QString &_prefix, const QList< QString > &_directories)
 The language codes of the <prefix><lang>.qm files in _directories, sorted by code.
TranslationLoadResult loadApplication (QTranslator &_translator, const QString &_prefix, const QString &_lang, const QList< QString > &_directories)
 Loads the <prefix><_lang>.qm translation file from _directories into _translator.

Function Documentation

◆ applicationTranslationPaths()

QList< QString > TranslationLoader::applicationTranslationPaths ( const QString & _installedPath)

The directories to search for an application's own translation files, in order of preference.

Parameters
_installedPathThe location the platform installs the translation files in, derived from the executable's path.
Returns
The installed location, followed by the executable's own directory: a build tree keeps the .qm files next to the binary instead of in the installed layout, so a developer build would otherwise find no translations at all.
Here is the caller graph for this function:

◆ availableLanguages()

QList< QString > TranslationLoader::availableLanguages ( const QString & _prefix,
const QList< QString > & _directories )

The language codes of the <prefix><lang>.qm files in _directories, sorted by code.

Lets a language selector offer exactly the languages that can be loaded.

Here is the caller graph for this function:

◆ loadApplication()

TranslationLoadResult TranslationLoader::loadApplication ( QTranslator & _translator,
const QString & _prefix,
const QString & _lang,
const QList< QString > & _directories )

Loads the <prefix><_lang>.qm translation file from _directories into _translator.

Parameters
_translatorThe translator to load into; must not also be used for Qt's own translation.
_prefixThe translation file prefix, e.g. "cockatrice" or "oracle".
_langThe language code, e.g. "de". An empty language loads nothing.
_directoriesThe directories to search, in order of preference.
Returns
What the search found.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadFrom()

TranslationLoadResult TranslationLoader::loadFrom ( QTranslator & _translator,
const QString & _nameHint,
const QList< QString > & _directories )

Loads the first _nameHint + language translation file found in _directories into _translator.

QTranslator discards whatever it held before every load, so each translation file needs its own translator; loading a second file into the first one silently drops the first.

Parameters
_translatorThe translator to load into.
_nameHintThe translation file name without its language and suffix, e.g. "qt_de" or "cockatrice_de".
_directoriesThe directories to search, in order of preference.
Returns
What the search found.
Here is the caller graph for this function:

◆ loadQt()

TranslationLoadResult TranslationLoader::loadQt ( QTranslator & _translator,
const QString & _lang )

Loads Qt's own translation for _lang, which covers the strings of Qt's own dialogs.

Parameters
_translatorThe translator to load into; must not also be used for an application translation.
_langThe language code, e.g. "de". An empty language loads nothing.
Returns
What the search found.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ qtTranslationCandidates()

QList< QString > TranslationLoader::qtTranslationCandidates ( )

Every directory that may hold Qt's own translations, in order of preference.

More than one entry is needed because a relocated Qt (Flatpak, AppImage, a bundled SDK) can report a prefix-relative translations path that does not exist: the KDE runtime reports /usr/translations while its qt_*.qm files live in /usr/share/qt6/translations.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ qtTranslationPaths()

QList< QString > TranslationLoader::qtTranslationPaths ( )

The candidates that actually exist, most likely first, so no caller searches a path that is not there.

Here is the call graph for this function:
Here is the caller graph for this function: