Support for 3-letter language codes (bug 3526, r=ds).

This commit is contained in:
David Anderson 2008-12-28 02:38:53 -05:00
parent ebed45a0f6
commit 08e2fc8deb
2 changed files with 5 additions and 7 deletions

View File

@ -487,7 +487,7 @@ SMCResult CPhraseFile::ReadSMC_KeyValue(const SMCStates *states, const char *key
else
{
size_t len = strlen(key);
if (len != 2)
if (len < 2 || len > 3)
{
ParseWarning("Ignoring translation to invalid language \"%s\" on line %d.", key, states->line);
return SMCResult_Continue;
@ -936,7 +936,7 @@ SMCResult Translator::ReadSMC_KeyValue(const SMCStates *states, const char *key,
{
size_t len = strlen(key);
if (len != 2)
if (len < 2 || len > 3)
{
g_Logger.LogError("[SM] Warning encountered parsing languages.cfg file.");
g_Logger.LogError("[SM] Invalid language code \"%s\" is being ignored.", key);
@ -957,9 +957,7 @@ bool Translator::AddLanguage(const char *langcode, const char *description)
Language *pLanguage = new Language;
unsigned int idx = m_Languages.size();
pLanguage->m_code2[0] = langcode[0];
pLanguage->m_code2[1] = langcode[1];
pLanguage->m_code2[2] = langcode[2];
UTIL_Format(pLanguage->m_code2, sizeof(pLanguage->m_code2), "%s", langcode);
pLanguage->m_FullName = m_pStringTab->AddString(description);
sm_trie_insert(m_pLCodeLookup, langcode, reinterpret_cast<void *>(idx));

View File

@ -57,7 +57,7 @@ enum PhraseParseState
struct Language
{
char m_code2[3];
char m_code2[4];
int m_FullName;
};
@ -159,7 +159,7 @@ private:
bool m_InLanguageSection;
String m_CustomError;
unsigned int m_ServerLang;
char m_InitialLang[3];
char m_InitialLang[4];
};
/* Nice little wrapper to handle error logging and whatnot */