hydrogen 1.2.3
Translations Class Reference

Translations manager. More...

#include <Translations.h>

Inheritance diagram for Translations:
Object< Translations > Base

Static Public Member Functions

static QStringList availableTranslations (QString sFileName, QString sDirectory=H2Core::Filesystem::i18n_dir())
 
static QString findTranslation (QStringList languages, QString sFileName, QString sDirectory=H2Core::Filesystem::i18n_dir())
 The standard QTranslation::load will prefer an exact match of a languae-REGION pair, regardless of its position in the preferred UI languages list.
 
static bool loadTranslation (QStringList languages, QTranslator &tor, QString sFileName, QString sDirectory=H2Core::Filesystem::i18n_dir())
 
- Static Public Member Functions inherited from Base
static const char * _class_name ()
 return the class name
 
static QString base_clock (const QString &sMsg)
 Measures the current time and stores it in __last_clock.
 
static QString base_clock_in (const QString &sMsg)
 
static int bootstrap (Logger *logger, bool count=false)
 must be called before any Object instantiation !
 
static bool count_active ()
 
static int getAliveObjectCount ()
 
static object_map_t getObjectMap ()
 
static Loggerlogger ()
 return the logger instance
 
static int objects_count ()
 
static void printObjectMapDiff (object_map_t map)
 Creates the difference between a snapshot of the object map and its current state and prints it to std::cout.
 
static void set_count (bool flag)
 enable/disable class instances counting
 
static void write_objects_map_to (std::ostream &out, object_map_t *map=nullptr)
 output the full objects map to a given ostream
 
static void write_objects_map_to_cerr ()
 output objects map to stderr
 

Additional Inherited Members

- Public Member Functions inherited from Object< Translations >
 Object ()
 
 Object (const Object< Translations > &other)
 
- Public Member Functions inherited from Base
 Base ()
 
 Base (const Base &other)
 
virtual const char * class_name () const
 
void Print (bool bShort=true) const
 Prints content of toQString() via DEBUGLOG.
 
virtual QString toQString (const QString &sPrefix="", bool bShort=true) const
 Formatted string version for debugging purposes.
 
- Static Public Attributes inherited from Base
static QString sPrintIndention = " "
 String used to format the debugging string output of some core classes.
 
- Protected Member Functions inherited from Object< Translations >
 ~Object ()
 
- Protected Member Functions inherited from Base
 ~Base ()
 
- Static Protected Member Functions inherited from Base
static void registerClass (const char *name, const atomic_obj_cpt_t *counters)
 
- Static Protected Attributes inherited from Base
static bool __count = false
 should we count class instances
 
static timeval __last_clock = { 0, 0 }
 
static Logger__logger = nullptr
 

Detailed Description

Translations manager.

Definition at line 41 of file Translations.h.

Member Function Documentation

◆ availableTranslations()

static QStringList availableTranslations ( QString sFileName,
QString sDirectory = H2Core::Filesystem::i18n_dir() )
inlinestatic

Definition at line 49 of file Translations.h.

◆ findTranslation()

static QString findTranslation ( QStringList languages,
QString sFileName,
QString sDirectory = H2Core::Filesystem::i18n_dir() )
inlinestatic

The standard QTranslation::load will prefer an exact match of a languae-REGION pair, regardless of its position in the preferred UI languages list.

This can lead, for instance, to Qt selecting Hungarian or Brazilian Portuguese just because they have exact matching translations, even if they're the last on the system's preferred UI language list. This seems wrong, as the user's preference for language should be considered more important than region, particularly here since Hydrogen has no particular region dependencies.

So instead, exhaustively search for a match for each of the user's preferred languages in turn.

Definition at line 80 of file Translations.h.

◆ loadTranslation()

static bool loadTranslation ( QStringList languages,
QTranslator & tor,
QString sFileName,
QString sDirectory = H2Core::Filesystem::i18n_dir() )
inlinestatic

Definition at line 102 of file Translations.h.