hydrogen 1.1.1
Translations Class Reference

Translations manager. More...

#include <Translations.h>

Inheritance diagram for Translations:
Object

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. More...
 
static bool loadTranslation (QStringList languages, QTranslator &tor, QString sFileName, QString sDirectory=H2Core::Filesystem::i18n_dir())
 
- Static Public Member Functions inherited from Object
static void set_count (bool flag)
 enable/disable class instances counting More...
 
static bool count_active ()
 return true if class instances counting is enabled More...
 
static unsigned objects_count ()
 return the number of objects More...
 
static void write_objects_map_to (std::ostream &out)
 output the full objects map to a given ostream More...
 
static void write_objects_map_to_cerr ()
 output objects map to stderr More...
 
static int bootstrap (Logger *logger, bool count=false)
 must be called before any Object instantiation ! More...
 
static Loggerlogger ()
 return the logger instance More...
 

Additional Inherited Members

- Public Member Functions inherited from Object
 ~Object ()
 destructor More...
 
 Object (const Object &obj)
 copy constructor More...
 
 Object (const char *class_name)
 constructor More...
 
const char * class_name () const
 return the class name More...
 
virtual QString toQString (const QString &sPrefix, bool bShort=true) const
 Formatted string version for debugging purposes. More...
 
void Print (bool bShort=true) const
 Prints content of toQString() via DEBUGLOG. More...
 
- Static Public Attributes inherited from Object
static QString sPrintIndention = " "
 String used to format the debugging string output of some core classes. More...
 
- Static Protected Attributes inherited from Object
static Logger__logger = nullptr
 logger instance pointer More...
 

Detailed Description

Translations manager.

Member Function Documentation

◆ availableTranslations()

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

◆ 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.

◆ loadTranslation()

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