KVIrc  4.9.2
DeveloperAPIs
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Private Attributes | List of all members
KviLocale Class Reference

Holds the localization functions. More...

#include <KviLocale.h>

+ Inheritance diagram for KviLocale:

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...
 
EncodingDescriptionencodingDescription (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...
 
KviMessageCataloguegetLoadedCatalogue (const QString &szName)
 Returns the loaded catalogue. More...
 
KviMessageCatalogueloadCatalogue (const QString &szName, const QString &szLocaleDir)
 Loads the catalogue. More...
 
const KviCStringlocaleName ()
 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 KviLocaleinstance ()
 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 KviLocalem_pSelf = nullptr
 
static unsigned int m_uCount = 0
 

Detailed Description

Holds the localization functions.

Member Typedef Documentation

Constructor & Destructor Documentation

KviLocale::KviLocale ( QApplication *  pApp,
const QString &  szLocaleDir,
const QString &  szForceLocaleDir 
)
protected
KviLocale::~KviLocale ( )
protected

Destroys the object.

Returns
KviLocale

References g_pCatalogueDict, g_pMainCatalogue, g_pSmartCodecDict, g_pTranslator, and m_pApp.

Member Function Documentation

QTextCodec * KviLocale::codecForName ( const char *  pcName)
unsigned int KviLocale::count ( )
inline

Returns the number of instances of the class.

Returns
unsigned int

Referenced by done(), and init().

void KviLocale::done ( )
static

Destroys the class instance.

Parameters
pAppThe main application
Returns
void

References count(), m_pSelf, and m_uCount.

Referenced by KviApplication::~KviApplication().

KviLocale::EncodingDescription * KviLocale::encodingDescription ( int  iIdx)

Returns the description of the encoding used.

Parameters
iIdxThe index of the description
Warning
You MUST start iterating from 0 and terminate when you get an entry with a NULL pcName
Returns
EncodingDescription *

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.

Parameters
iIdxThe index of the group
Warning
You MUST start iterating from 0 and terminate when you get an entry with a NULL value
Returns
const char *

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

Parameters
szBufferThe buffer where to store the translation full path
szNameThe name of the translation file
szLocaleDirThe directory where the localizations are stored
Returns
bool

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.

Parameters
szNameThe name of the catalogue to get
Returns
KviMessageCatalogue *

References KviPointerHashTable< Key, T >::find().

Referenced by KviKvsCoreFunctions::KVSCF().

void KviLocale::init ( QApplication *  pApp,
const QString &  szLocaleDir,
const QString &  szForceLocaleDir 
)
static

Initializes the class instance.

Parameters
pAppThe main application
szLocaleDirThe directory containing the localizations
szForceLocaleDirThe directory forced by the user
Returns
void

References count(), KviLocale(), m_pSelf, and m_uCount.

Referenced by KviApplication::loadDirectories().

static KviLocale* KviLocale::instance ( )
inlinestatic
KviMessageCatalogue * KviLocale::loadCatalogue ( const QString &  szName,
const QString &  szLocaleDir 
)

Loads the catalogue.

Parameters
szNameThe name of the catalogue
szLocaleDirThe directory where to look for the catalogue
Returns
KviMessageCatalogue *

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().

const KviCString& KviLocale::localeName ( )
inline
const char * KviLocale::translate ( const char *  pcText,
const char *  pcContext 
)

Translates the given text from the given context.

Parameters
pcTextThe text to translate
pcContextThe context where to look for the text
Returns
const char *

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.

Parameters
pcTextThe text to translate
pcContextThe context where to look for the text
Returns
const QString &

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.

Parameters
szNameThe catalogue to unload
Returns
bool

References KviPointerHashTable< Key, T >::remove().

Referenced by KviModuleManager::loadModule(), and KviModuleManager::unloadModule().

Member Data Documentation

KviCString KviLocale::g_szLang = ""
static

Referenced by findCatalogue(), and KviLocale().

QApplication* KviLocale::m_pApp
protected

Referenced by KviLocale(), and ~KviLocale().

KviLocale * KviLocale::m_pSelf = nullptr
staticprivate

Referenced by done(), and init().

unsigned int KviLocale::m_uCount = 0
staticprivate

Referenced by done(), and init().


The documentation for this class was generated from the following files: