kodi
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
CLangCodeExpander Class Reference

Public Types

enum  LANGFORMATS { ISO_639_1, ISO_639_2, ENGLISH_NAME }
 
enum  LANG_LIST { DEFAULT, INCLUDE_ADDONS, INCLUDE_USERDEFINED, INCLUDE_ADDONS_USERDEFINED }
 

Public Member Functions

void LoadUserCodes (const TiXmlElement *pRootElement)
 
void Clear ()
 
bool Lookup (const std::string &code, std::string &desc)
 
bool Lookup (const int code, std::string &desc)
 
bool CompareFullLanguageNames (const std::string &lang1, const std::string &lang2)
 Determines if two english language names represent the same language. More...
 
bool CompareISO639Codes (const std::string &code1, const std::string &code2)
 Determines if two languages given as ISO 639-1, ISO 639-2/T, or ISO 639-2/B codes represent the same language. More...
 
bool ConvertToISO6391 (const std::string &lang, std::string &code)
 Converts a language given as 2-Char (ISO 639-1), 3-Char (ISO 639-2/T or ISO 639-2/B), or full english name string to a 2-Char (ISO 639-1) code. More...
 
std::string ConvertToISO6392B (const std::string &lang)
 Converts a language given as 2-Char (ISO 639-1), 3-Char (ISO 639-2/T or ISO 639-2/B), or full english name string to a 3-Char ISO 639-2/B code. More...
 
bool ConvertToISO6392B (const std::string &strCharCode, std::string &strISO6392B, bool checkWin32Locales=false)
 Converts a language given as 2-Char (ISO 639-1), 3-Char (ISO 639-2/T or ISO 639-2/B), or full english name string to a 3-Char ISO 639-2/T code. More...
 
bool ConvertToISO6392T (const std::string &strCharCode, std::string &strISO6392T, bool checkWin32Locales=false)
 Converts a language given as 2-Char (ISO 639-1), 3-Char (ISO 639-2/T or ISO 639-2/B), or full english name string to a 3-Char ISO 639-2/T code. More...
 
std::string ConvertToISO6392T (const std::string &lang)
 Converts a language given as 2-Char (ISO 639-1), 3-Char (ISO 639-2/T or ISO 639-2/B), or full english name string to a 3-Char ISO 639-2/T code. More...
 
std::vector< std::string > GetLanguageNames (LANGFORMATS format=ISO_639_1, LANG_LIST list=LANG_LIST::DEFAULT)
 

Static Public Member Functions

static bool ConvertISO6391ToISO6392B (const std::string &strISO6391, std::string &strISO6392B, bool checkWin32Locales=false)
 Converts a language given as 2-Char (ISO 639-1) to a 3-Char (ISO 639-2/T) code. More...
 
static std::string FindLanguageCodeWithSubtag (const std::string &str)
 

Protected Types

typedef std::map< std::string, std::string > STRINGLOOKUPTABLE
 

Protected Member Functions

bool LookupInUserMap (const std::string &code, std::string &desc)
 
bool ReverseLookup (const std::string &desc, std::string &code)
 Looks up the ISO 639-1, ISO 639-2/T, or ISO 639-2/B, whichever it finds first, code of the given english language name. More...
 
bool LookupUserCode (const std::string &desc, std::string &userCode)
 Looks up the user defined code of the given code or language name. More...
 

Static Protected Member Functions

static std::string CodeToString (long code)
 
static bool LookupInISO639Tables (const std::string &code, std::string &desc)
 
static bool LookupInLangAddons (const std::string &code, std::string &desc)
 

Protected Attributes

STRINGLOOKUPTABLE m_mapUser
 

Member Function Documentation

◆ CompareFullLanguageNames()

bool CLangCodeExpander::CompareFullLanguageNames ( const std::string &  lang1,
const std::string &  lang2 
)

Determines if two english language names represent the same language.

Parameters
[in]lang1The first language string to compare given as english language name.
[in]lang2The second language string to compare given as english language name.
Returns
true if the two language strings represent the same language, false otherwise. For example "Abkhaz" and "Abkhazian" represent the same language.

◆ CompareISO639Codes()

bool CLangCodeExpander::CompareISO639Codes ( const std::string &  code1,
const std::string &  code2 
)

Determines if two languages given as ISO 639-1, ISO 639-2/T, or ISO 639-2/B codes represent the same language.

Parameters
[in]code1The first language to compare given as ISO 639-1, ISO 639-2/T, or ISO 639-2/B code.
[in]code2The second language to compare given as ISO 639-1, ISO 639-2/T, or ISO 639-2/B code.
Returns
true if the two language codes represent the same language, false otherwise. For example "ger", "deu" and "de" represent the same language.

◆ ConvertISO6391ToISO6392B()

bool CLangCodeExpander::ConvertISO6391ToISO6392B ( const std::string &  strISO6391,
std::string &  strISO6392B,
bool  checkWin32Locales = false 
)
static

Converts a language given as 2-Char (ISO 639-1) to a 3-Char (ISO 639-2/T) code.

Parameters
[in]strISO6391The language that should be converted.
[out]strISO6392BThe 3-Char (ISO 639-2/B) language code of the given language strISO6391.
[in]checkWin32LocalesWhether to also check WIN32 specific language codes.
Returns
true if the conversion succeeded, false otherwise.

◆ ConvertToISO6391()

bool CLangCodeExpander::ConvertToISO6391 ( const std::string &  lang,
std::string &  code 
)

Converts a language given as 2-Char (ISO 639-1), 3-Char (ISO 639-2/T or ISO 639-2/B), or full english name string to a 2-Char (ISO 639-1) code.

Parameters
[out]codeThe 2-Char language code of the given language lang.
[in]langThe language that should be converted.
Returns
true if the conversion succeeded, false otherwise.

◆ ConvertToISO6392B() [1/2]

std::string CLangCodeExpander::ConvertToISO6392B ( const std::string &  lang)

Converts a language given as 2-Char (ISO 639-1), 3-Char (ISO 639-2/T or ISO 639-2/B), or full english name string to a 3-Char ISO 639-2/B code.

Parameters
[in]langThe language that should be converted.
Returns
The 3-Char ISO 639-2/B code of lang if that code exists, lang otherwise.

◆ ConvertToISO6392B() [2/2]

bool CLangCodeExpander::ConvertToISO6392B ( const std::string &  strCharCode,
std::string &  strISO6392B,
bool  checkWin32Locales = false 
)

Converts a language given as 2-Char (ISO 639-1), 3-Char (ISO 639-2/T or ISO 639-2/B), or full english name string to a 3-Char ISO 639-2/T code.

Parameters
[in]strCharCodeThe language that should be converted.
[out]strISO6392BThe 3-Char (ISO 639-2/B) language code of the given language strISO6391.
[in]checkWin32LocalesWhether to also check WIN32 specific language codes.
Returns
true if the conversion succeeded, false otherwise.

◆ ConvertToISO6392T() [1/2]

bool CLangCodeExpander::ConvertToISO6392T ( const std::string &  strCharCode,
std::string &  strISO6392T,
bool  checkWin32Locales = false 
)

Converts a language given as 2-Char (ISO 639-1), 3-Char (ISO 639-2/T or ISO 639-2/B), or full english name string to a 3-Char ISO 639-2/T code.

Parameters
[in]strCharCodeThe language that should be converted.
[out]strISO6392TThe 3-Char (ISO 639-2/T) language code of the given language strISO6391.
[in]checkWin32LocalesWhether to also check WIN32 specific language codes.
Returns
true if the conversion succeeded, false otherwise.

◆ ConvertToISO6392T() [2/2]

std::string CLangCodeExpander::ConvertToISO6392T ( const std::string &  lang)

Converts a language given as 2-Char (ISO 639-1), 3-Char (ISO 639-2/T or ISO 639-2/B), or full english name string to a 3-Char ISO 639-2/T code.

Parameters
[in]langThe language that should be converted.
Returns
The 3-Char ISO 639-2/T code of lang if that code exists, lang otherwise.

◆ LookupUserCode()

bool CLangCodeExpander::LookupUserCode ( const std::string &  desc,
std::string &  userCode 
)
protected

Looks up the user defined code of the given code or language name.

Parameters
[in]descThe language code or name that should be converted.
[out]userCodeThe user defined language code of the given language desc.
Returns
true if desc was found, false otherwise.

◆ ReverseLookup()

bool CLangCodeExpander::ReverseLookup ( const std::string &  desc,
std::string &  code 
)
protected

Looks up the ISO 639-1, ISO 639-2/T, or ISO 639-2/B, whichever it finds first, code of the given english language name.

Parameters
[in]descThe english language name for which a code is looked for.
[out]codeThe ISO 639-1, ISO 639-2/T, or ISO 639-2/B code of the given language desc.
Returns
true if the a code was found, false otherwise.

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