MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / AddLanguage

Method AddLanguage

core/logic/Translator.cpp:920–954  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

918}
919
920bool Translator::AddLanguage(const char *langcode, const char *description)
921{
922 char lower[256];
923 size_t len = strlen(description);
924 if (len > 255) len = 255;
925 for (size_t i = 0; i < len; i++)
926 {
927 if (description[i] >= 'A' && description[i] <= 'Z')
928 lower[i] = tolower(description[i]);
929 else
930 lower[i] = description[i];
931 }
932 lower[len] = '\0';
933
934 if (m_LAliases.contains(lower))
935 return false;
936
937 unsigned int idx;
938 if (!m_LCodeLookup.retrieve(langcode, &idx))
939 {
940 Language *pLanguage = new Language;
941 idx = m_Languages.size();
942
943 ke::SafeStrcpy(pLanguage->m_code2, sizeof(pLanguage->m_code2), langcode);
944 pLanguage->m_CanonicalName = m_pStringTab->AddString(lower);
945
946 m_LCodeLookup.insert(langcode, idx);
947
948 m_Languages.push_back(pLanguage);
949 }
950
951 m_LAliases.insert(lower, idx);
952
953 return true;
954}
955
956CPhraseFile *Translator::GetFileByIndex(unsigned int index)
957{

Callers

nothing calls this directly

Calls 6

push_backMethod · 0.80
containsMethod · 0.45
retrieveMethod · 0.45
sizeMethod · 0.45
AddStringMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected