Multi diag tools
Classes | Functions
Mdt::Translation Namespace Reference

Some utilities for application translations. More...

Classes

class  LanguageCode
 LanguageCode is a 2 letter ISO 639-1 laguage representation. More...
 
class  LanguageCodeList
 LanguageCodeList holds a list of LanguageCode. More...
 
class  LanguageSelection
 LanguageSelection facilitates the creation of multi-language applications. More...
 
class  LanguageSelectionActionList
 Helper class to create actions for language selection. More...
 
class  LanguageSelectionMenu
 The LanguageSelectionMenu class provides a language selection menu. More...
 
class  QmFileName
 Representation of a .qm translation file name. More...
 
class  TranslationInfo
 Value class that stores informations about a translation. More...
 
class  TranslationInfoList
 Container that contains a list of TranslationInfo. More...
 

Functions

Mdt::Expected< Mdt::Translation::TranslationInfoListfindTranslations (const Mdt::FileSystem::PathList &pathPrefixList)
 Find translations in a set of directories. More...
 
QString findTranslationsRoot (const Mdt::FileSystem::PathList &pathPrefixList)
 Find the root directory of translations. More...
 
QString findDirectoryRoot (const QString &directory, const QStringList &possibleSubdirectories, const QString &expectedQmFileBaseName, const Mdt::FileSystem::PathList &pathPrefixList)
 Find the root directory of translations. More...
 
QString findDirectoryRoot (const QString &directory, const QStringList &possibleSubdirectories, const Mdt::FileSystem::PathList &pathPrefixList)
 Find the root directory of translations. More...
 
bool isTranslationDirectory (const QString &directoryPath, const QString &expectedQmFileBaseName=QString())
 Check if a directory is a translation directory. More...
 

Detailed Description

Some utilities for application translations.

Function Documentation

QString MDT_TRANSLATION_CORE_EXPORT Mdt::Translation::findDirectoryRoot ( const QString &  directory,
const QStringList &  possibleSubdirectories,
const QString &  expectedQmFileBaseName,
const Mdt::FileSystem::PathList pathPrefixList 
)

Find the root directory of translations.

For a given path prefix, a subdirectory, named directory, will be located in possibleSubdirectories .

A path is considered as the expected translation only if a QM file, for which the base name is expectedQmFileBaseName , exists.

If pathPrefixList contains at least 1 non empty path, directory will only be located starting from prefixes in it. Else, system path prefixes will be used.

See also
findDirectoryRoot(const QString &, const QStringList &, const Mdt::FileSystem::PathList &)

Definition at line 73 of file FindTranslation.cpp.

QString MDT_TRANSLATION_CORE_EXPORT Mdt::Translation::findDirectoryRoot ( const QString &  directory,
const QStringList &  possibleSubdirectories,
const Mdt::FileSystem::PathList pathPrefixList 
)

Find the root directory of translations.

For a given path prefix, a subdirectory, named directory, will be located in possibleSubdirectories .

A path is considered as the expected translation only if it contains at least one a QM file.

If pathPrefixList contains at least 1 non empty path, directory will only be located starting from prefixes in it. Else, system path prefixes will be used.

See also
findDirectoryRoot(const QString &, const QStringList &, const QString &, const Mdt::FileSystem::PathList &)

Definition at line 99 of file FindTranslation.cpp.

Mdt::Expected< Mdt::Translation::TranslationInfoList > MDT_TRANSLATION_CORE_EXPORT Mdt::Translation::findTranslations ( const Mdt::FileSystem::PathList pathPrefixList)

Find translations in a set of directories.

Translations are searched in directories defined using findTranslationsRoot().

Precondition
pathPrefixList must contain at least one path.

Definition at line 40 of file FindTranslation.cpp.

QString MDT_TRANSLATION_CORE_EXPORT Mdt::Translation::findTranslationsRoot ( const Mdt::FileSystem::PathList pathPrefixList)

Find the root directory of translations.

For a given path prefix, a subdirectory, named translations, will be located. It is considered as a translation directory if it contains at least 1 *.qm file.

Precondition
pathPrefixList must contain at least one path.

Definition at line 66 of file FindTranslation.cpp.

bool MDT_TRANSLATION_CORE_EXPORT Mdt::Translation::isTranslationDirectory ( const QString &  directoryPath,
const QString &  expectedQmFileBaseName = QString() 
)

Check if a directory is a translation directory.

Will check if the directory directoryPath contains at least 1 QM file.

If expectedQmFileBaseName is set, the directory is considered a translation directory only if it contains at least 1 QM file named <expectedQmFileBaseName>_<xy>.qm .

bool matches = isTranslationDirectory("/opt/Qt5/translations", "qtbase");
// matches will be true only if /opt/Qt5/translations/ contains qtbase_en.qm or qtbase_fr.qm, etc..

Definition at line 104 of file FindTranslation.cpp.