Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
CLangCodeExpander Class Reference

#include <LangCodeExpander.h>

Public Types

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

Public Member Functions

 CLangCodeExpander ()
 
 ~CLangCodeExpander ()
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
bool LookupUserCode (const std::string &desc, std::string &userCode)
 Looks up the user defined code of the given code or language name.
 

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 Typedef Documentation

◆ STRINGLOOKUPTABLE

std::map<std::string, std::string> CLangCodeExpander::STRINGLOOKUPTABLE
protected

Member Enumeration Documentation

◆ LANG_LIST

enum class CLangCodeExpander::LANG_LIST
strong
Enumerator
DEFAULT 
INCLUDE_ADDONS 
INCLUDE_USERDEFINED 
INCLUDE_ADDONS_USERDEFINED 

◆ LANGFORMATS

Enumerator
ISO_639_1 
ISO_639_2 
ENGLISH_NAME 

Constructor & Destructor Documentation

◆ CLangCodeExpander()

CLangCodeExpander::CLangCodeExpander ( )
default

◆ ~CLangCodeExpander()

CLangCodeExpander::~CLangCodeExpander ( )
default

Member Function Documentation

◆ Clear()

void CLangCodeExpander::Clear ( )

◆ CodeToString()

std::string CLangCodeExpander::CodeToString ( long code)
staticprotected

◆ 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]

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.

◆ ConvertToISO6392T() [2/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.

◆ FindLanguageCodeWithSubtag()

std::string CLangCodeExpander::FindLanguageCodeWithSubtag ( const std::string & str)
static

◆ GetLanguageNames()

std::vector< std::string > CLangCodeExpander::GetLanguageNames ( LANGFORMATS format = ISO_639_1,
LANG_LIST list = LANG_LIST::DEFAULT )

◆ LoadUserCodes()

void CLangCodeExpander::LoadUserCodes ( const TiXmlElement * pRootElement)

◆ Lookup() [1/2]

bool CLangCodeExpander::Lookup ( const int code,
std::string & desc )

◆ Lookup() [2/2]

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

◆ LookupInISO639Tables()

bool CLangCodeExpander::LookupInISO639Tables ( const std::string & code,
std::string & desc )
staticprotected

◆ LookupInLangAddons()

bool CLangCodeExpander::LookupInLangAddons ( const std::string & code,
std::string & desc )
staticprotected

◆ LookupInUserMap()

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

◆ 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.

Member Data Documentation

◆ m_mapUser

STRINGLOOKUPTABLE CLangCodeExpander::m_mapUser
protected

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