KVIrc
4.9.2
DeveloperAPIs
|
Holds the localization functions. More...
#include <KviLocale.h>
Classes | |
struct | _EncodingDescription |
Holds the encoding data. More... | |
Public Types | |
typedef struct KviLocale::_EncodingDescription | EncodingDescription |
Public Member Functions | |
QTextCodec * | codecForName (const char *pcName) |
Returns the codec associated to the given translation. More... | |
unsigned int | count () |
Returns the number of instances of the class. More... | |
EncodingDescription * | encodingDescription (int iIdx) |
Returns the description of the encoding used. More... | |
const char * | encodingGroup (int iIdx) |
Returns the description of the encoding used. More... | |
bool | findCatalogue (QString &szBuffer, const QString &szName, const QString &szLocaleDir) |
Finds the catalogue. More... | |
KviMessageCatalogue * | getLoadedCatalogue (const QString &szName) |
Returns the loaded catalogue. More... | |
KviMessageCatalogue * | loadCatalogue (const QString &szName, const QString &szLocaleDir) |
Loads the catalogue. More... | |
const KviCString & | localeName () |
Returns the language code of the localization. More... | |
const char * | translate (const char *pcText, const char *pcContext) |
Translates the given text from the given context. More... | |
const QString & | translateToQString (const char *pcText, const char *pcContext) |
Translates the given text from the given context. More... | |
bool | unloadCatalogue (const QString &szName) |
Unloads a catalogue. More... | |
Static Public Member Functions | |
static void | done () |
Destroys the class instance. More... | |
static void | init (QApplication *pApp, const QString &szLocaleDir, const QString &szForceLocaleDir) |
Initializes the class instance. More... | |
static KviLocale * | instance () |
Returns the instance of the class. More... | |
Static Public Attributes | |
static KviCString | g_szLang = "" |
Protected Member Functions | |
KviLocale (QApplication *pApp, const QString &szLocaleDir, const QString &szForceLocaleDir) | |
Constructs the KviLocale object. More... | |
~KviLocale () | |
Destroys the object. More... | |
Protected Attributes | |
QApplication * | m_pApp |
Static Private Attributes | |
static KviLocale * | m_pSelf = nullptr |
static unsigned int | m_uCount = 0 |
Holds the localization functions.
|
protected |
Constructs the KviLocale object.
pApp | The main application |
szLocaleDir | The directory containing the localizations |
szForceLocaleDir | The directory forced by the user |
References KviCString::cutFromFirst(), KviFileUtils::fileExists(), findCatalogue(), g_pMainCatalogue, g_szDefaultLocalePath, g_szLang, KviEnvironment::getVariable(), KviCString::hasData(), KviCString::isEmpty(), KVI_FORCE_LOCALE_FILE_NAME, kvi_strEqualCI(), KviCString::len(), KviMessageCatalogue::load(), m_pApp, KviCString::ptr(), KviFileUtils::readFile(), KviPointerHashTable< Key, T >::setAutoDelete(), szBuffer, KviCString::toLower(), and KviCString::trim().
Referenced by init().
|
protected |
Destroys the object.
References g_pCatalogueDict, g_pMainCatalogue, g_pSmartCodecDict, g_pTranslator, and m_pApp.
QTextCodec * KviLocale::codecForName | ( | const char * | pcName | ) |
Returns the codec associated to the given translation.
pcName | The name of the translation |
References KviCString::cutFromFirst(), KviPointerHashTable< Key, T >::find(), KviCString::findFirstIdx(), kvi_strEqualCIN(), KviSmartTextCodec::ok(), KviCString::ptr(), KviPointerHashTable< Key, T >::replace(), and KviCString::replaceAll().
Referenced by KviApplication::defaultSrvCodec(), KviApplication::defaultTextCodec(), KviMessageCatalogue::load(), KviIrcServerParser::parseNumericCodePageSet(), KviIrcConnection::setEncoding(), KviWindow::setTextEncoding(), KviApplication::setup(), KviIrcConnection::setupSrvCodec(), and KviIrcConnection::setupTextCodec().
|
inline |
|
static |
Destroys the class instance.
pApp | The main application |
References count(), m_pSelf, and m_uCount.
Referenced by KviApplication::~KviApplication().
KviLocale::EncodingDescription * KviLocale::encodingDescription | ( | int | iIdx | ) |
Returns the description of the encoding used.
iIdx | The index of the description |
References KVI_NUM_ENCODINGS.
Referenced by KviWindow::createSystemTextEncodingPopup(), IrcNetworkDetailsWidget::fillData(), IrcServerDetailsWidget::fillData(), IrcNetworkDetailsWidget::IrcNetworkDetailsWidget(), IrcServerDetailsWidget::IrcServerDetailsWidget(), OptionsWidget_soundGeneral::OptionsWidget_soundGeneral(), and OptionsWidget_textEncoding::OptionsWidget_textEncoding().
const char * KviLocale::encodingGroup | ( | int | iIdx | ) |
Returns the description of the encoding used.
iIdx | The index of the group |
References encoding_groups, and KVI_NUM_ENCODING_GROUPS.
Referenced by KviWindow::createSystemTextEncodingPopup().
bool KviLocale::findCatalogue | ( | QString & | szBuffer, |
const QString & | szName, | ||
const QString & | szLocaleDir | ||
) |
Finds the catalogue.
This function attempts to determine the current locale and then load the corresponding translation file from the KVIrc locale directory. Returns true if the locale was correctly set; i.e. the locale is C or POSIX (no translation needed) or the locale is correctly defined and the translation map was successfully loaded
szBuffer | The buffer where to store the translation full path |
szName | The name of the translation file |
szLocaleDir | The directory where the localizations are stored |
References KviCString::cutFromFirst(), KviQString::ensureLastCharIs(), KviFileUtils::fileExists(), KviCString::findFirstIdx(), g_szLang, KVI_PATH_SEPARATOR_CHAR, KviCString::ptr(), and KviCString::toLower().
Referenced by KviLocale(), and loadCatalogue().
KviMessageCatalogue * KviLocale::getLoadedCatalogue | ( | const QString & | szName | ) |
Returns the loaded catalogue.
szName | The name of the catalogue to get |
References KviPointerHashTable< Key, T >::find().
Referenced by KviKvsCoreFunctions::KVSCF().
|
static |
Initializes the class instance.
pApp | The main application |
szLocaleDir | The directory containing the localizations |
szForceLocaleDir | The directory forced by the user |
References count(), KviLocale(), m_pSelf, and m_uCount.
Referenced by KviApplication::loadDirectories().
|
inlinestatic |
Returns the instance of the class.
Referenced by KviWindow::createSystemTextEncodingPopup(), KviApplication::defaultSrvCodec(), KviApplication::defaultTextCodec(), IrcNetworkDetailsWidget::fillData(), IrcServerDetailsWidget::fillData(), KviApplication::getGlobalKvircDirectory(), KviApplication::getLocalKvircDirectory(), IrcNetworkDetailsWidget::IrcNetworkDetailsWidget(), IrcServerDetailsWidget::IrcServerDetailsWidget(), KviKvsCoreFunctions::KVSCF(), KviKvsCoreSimpleCommands::KVSCSC(), KviMessageCatalogue::load(), KviModuleManager::loadModule(), TipWindow::nextTip(), OptionsWidget_soundGeneral::OptionsWidget_soundGeneral(), OptionsWidget_textEncoding::OptionsWidget_textEncoding(), KviIrcServerParser::parseNumericCodePageSet(), TipWindow::prevTip(), KviIrcConnection::setEncoding(), KviWindow::setTextEncoding(), KviApplication::setup(), KviMenuBar::setupHelpPopup(), KviIrcConnection::setupSrvCodec(), KviIrcConnection::setupTextCodec(), and KviModuleManager::unloadModule().
KviMessageCatalogue * KviLocale::loadCatalogue | ( | const QString & | szName, |
const QString & | szLocaleDir | ||
) |
Loads the catalogue.
szName | The name of the catalogue |
szLocaleDir | The directory where to look for the catalogue |
References KviPointerHashTable< Key, T >::find(), findCatalogue(), KviPointerHashTable< Key, T >::insert(), KviMessageCatalogue::load(), and szBuffer.
Referenced by KviKvsCoreFunctions::KVSCF(), KviKvsCoreSimpleCommands::KVSCSC(), KviModuleManager::loadModule(), translate(), and translateToQString().
|
inline |
Returns the language code of the localization.
Referenced by KviApplication::getLocalKvircDirectory(), TipWindow::nextTip(), OptionsWidget_textEncoding::OptionsWidget_textEncoding(), and TipWindow::prevTip().
const char * KviLocale::translate | ( | const char * | pcText, |
const char * | pcContext | ||
) |
Translates the given text from the given context.
pcText | The text to translate |
pcContext | The context where to look for the text |
References KviPointerHashTable< Key, T >::find(), g_pMainCatalogue, g_szDefaultLocalePath, KviPointerHashTable< Key, T >::insert(), loadCatalogue(), and KviMessageCatalogue::translate().
const QString & KviLocale::translateToQString | ( | const char * | pcText, |
const char * | pcContext | ||
) |
Translates the given text from the given context.
pcText | The text to translate |
pcContext | The context where to look for the text |
References KviPointerHashTable< Key, T >::find(), g_pMainCatalogue, g_szDefaultLocalePath, KviPointerHashTable< Key, T >::insert(), loadCatalogue(), and KviMessageCatalogue::translateToQString().
bool KviLocale::unloadCatalogue | ( | const QString & | szName | ) |
Unloads a catalogue.
szName | The catalogue to unload |
References KviPointerHashTable< Key, T >::remove().
Referenced by KviModuleManager::loadModule(), and KviModuleManager::unloadModule().
|
static |
Referenced by findCatalogue(), and KviLocale().
|
protected |
Referenced by KviLocale(), and ~KviLocale().