![]() |
KVIrc 5.2.6
Developer APIs
|
Holds the localization functions. More...
#include <KviLocale.h>
Classes | |
struct | EncodingDescription |
Public Member Functions | |
QTextCodec * | codecForName (const char *pcName) |
Returns the codec associated to the given translation. | |
EncodingDescription * | encodingDescription (int iIdx) |
Returns the description of the encoding used. | |
const char * | encodingGroup (int iIdx) |
Returns the description of the encoding used. | |
bool | findCatalogue (QString &szBuffer, const QString &szName, const QString &szLocaleDir) |
Finds the catalogue. | |
KviMessageCatalogue * | getLoadedCatalogue (const QString &szName) |
Returns the loaded catalogue. | |
KviMessageCatalogue * | loadCatalogue (const QString &szName, const QString &szLocaleDir) |
Loads the catalogue. | |
const QString & | localeName () const |
Returns the language code of the localization. | |
const char * | translate (const char *pcText, const char *pcContext) |
Translates the given text from the given context. | |
const QString & | translateToQString (const char *pcText, const char *pcContext) |
Translates the given text from the given context. | |
bool | unloadCatalogue (const QString &szName) |
Unloads a catalogue. | |
Static Public Member Functions | |
static void | done () |
Destroys the class instance. | |
static void | init (QApplication *pApp, const QString &szLocaleDir, const QString &szForceLocaleDir) |
Initializes the class instance. | |
static KviLocale * | instance () |
Returns the instance of the class. | |
Static Public Attributes | |
static QString | g_szLang = "" |
Protected Member Functions | |
KviLocale (QApplication *pApp, const QString &szLocaleDir, const QString &szForceLocaleDir) | |
Constructs the KviLocale object. | |
~KviLocale () | |
Destroys the object. | |
Protected Attributes | |
QApplication * | m_pApp |
Static Private Attributes | |
static KviLocale * | m_pSelf = nullptr |
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_pCatalogueDict, g_pMainCatalogue, g_pSmartCodecDict, g_pTranslator, g_szDefaultLocalePath, g_szLang, KviEnvironment::getVariable(), KVI_FORCE_LOCALE_FILE_NAME, kvi_strEqualCI(), m_pApp, KviCString::ptr(), KviFileUtils::readFile(), szBuffer, and KviCString::toLower().
Referenced by init(), and instance().
|
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(), KviCString::findFirstIdx(), g_pSmartCodecDict, kvi_strEqualCIN(), KviSmartTextCodec::ok(), KviCString::ptr(), and KviCString::replaceAll().
Referenced by KviApplication::defaultSrvCodec(), KviApplication::defaultTextCodec(), KviIrcConnection::setEncoding(), KviWindow::setTextEncoding(), KviApplication::setup(), KviIrcConnection::setupSrvCodec(), and KviIrcConnection::setupTextCodec().
|
static |
Destroys the class instance.
pApp | The main application |
References m_pSelf.
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, and supported_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(), szBuffer, 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 g_pCatalogueDict.
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 KviLocale(), and m_pSelf.
Referenced by KviApplication::loadDirectories().
|
inlinestatic |
Returns the instance of the class.
References KviLocale(), and m_pSelf.
Referenced by KviWindow::createSystemTextEncodingPopup(), KviApplication::defaultSrvCodec(), KviApplication::defaultTextCodec(), IrcNetworkDetailsWidget::fillData(), IrcServerDetailsWidget::fillData(), KviApplication::getGlobalKvircDirectory(), KviApplication::getLocalKvircDirectory(), IrcNetworkDetailsWidget::IrcNetworkDetailsWidget(), IrcServerDetailsWidget::IrcServerDetailsWidget(), KviKvsCoreFunctions::KVSCF(), KviKvsCoreFunctions::KVSCF(), KviKvsCoreSimpleCommands::KVSCSC(), KviKvsCoreSimpleCommands::KVSCSC(), KviModuleManager::loadModule(), TipWindow::nextTip(), OptionsWidget_soundGeneral::OptionsWidget_soundGeneral(), OptionsWidget_textEncoding::OptionsWidget_textEncoding(), KviIrcServerParser::parseNumericCodePageSet(), TipWindow::prevTip(), KviIrcConnection::setEncoding(), KviWindow::setTextEncoding(), KviApplication::setup(), 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 findCatalogue(), g_pCatalogueDict, KviMessageCatalogue::load(), and szBuffer.
Referenced by KviKvsCoreFunctions::KVSCF(), KviModuleManager::loadModule(), translate(), and translateToQString().
|
inline |
Returns the language code of the localization.
References g_szLang.
Referenced by KviApplication::getGlobalKvircDirectory(), KviApplication::getLocalKvircDirectory(), KviKvsCoreFunctions::KVSCF(), 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 g_pCatalogueDict, g_pMainCatalogue, g_szDefaultLocalePath, 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 g_pCatalogueDict, g_pMainCatalogue, g_szDefaultLocalePath, loadCatalogue(), and KviMessageCatalogue::translateToQString().
bool KviLocale::unloadCatalogue | ( | const QString & | szName | ) |
Unloads a catalogue.
szName | The catalogue to unload |
References g_pCatalogueDict.
Referenced by KviModuleManager::loadModule(), and KviModuleManager::unloadModule().
|
static |
Referenced by findCatalogue(), KviLocale(), and localeName().
|
protected |
Referenced by KviLocale(), and ~KviLocale().
Referenced by done(), init(), and instance().