Language files are now additive, and are sniffed from translations/[iso code].
This is so translations can be maintained easier without any merging pains on behalf of users or developers.
This commit is contained in:
parent
99e304d6b5
commit
4147bf7444
@ -152,6 +152,45 @@ void CPhraseFile::ReparseFile()
|
|||||||
g_Logger.LogError("[SM] Fatal error encountered parsing translation file \"%s\"", m_File.c_str());
|
g_Logger.LogError("[SM] Fatal error encountered parsing translation file \"%s\"", m_File.c_str());
|
||||||
g_Logger.LogError("[SM] Error (line %d, column %d): %s", states.line, states.col, msg);
|
g_Logger.LogError("[SM] Error (line %d, column %d): %s", states.line, states.col, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *code;
|
||||||
|
for (unsigned int i = 1; i < m_LangCount; i++)
|
||||||
|
{
|
||||||
|
if (!m_pTranslator->GetLanguageInfo(i, &code, NULL))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_SourceMod.BuildPath(Path_SM,
|
||||||
|
path,
|
||||||
|
PLATFORM_MAX_PATH,
|
||||||
|
"translations/%s/%s",
|
||||||
|
code,
|
||||||
|
m_File.c_str());
|
||||||
|
|
||||||
|
/* Speculatively load these. */
|
||||||
|
if (!g_LibSys.PathExists(path))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((err=textparsers->ParseFile_SMC(path, this, &states)) != SMCError_Okay)
|
||||||
|
{
|
||||||
|
const char *msg = textparsers->GetSMCErrorString(err);
|
||||||
|
if (!msg)
|
||||||
|
{
|
||||||
|
msg = m_ParseError.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
g_Logger.LogError("[SM] Fatal error encountered parsing translation file \"%s/%s\"",
|
||||||
|
code,
|
||||||
|
m_File.c_str());
|
||||||
|
g_Logger.LogError("[SM] Error (line %d, column %d): %s",
|
||||||
|
states.line,
|
||||||
|
states.col,
|
||||||
|
msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPhraseFile::ReadSMC_ParseStart()
|
void CPhraseFile::ReadSMC_ParseStart()
|
||||||
@ -178,21 +217,21 @@ SMCResult CPhraseFile::ReadSMC_NewSection(const SMCStates *states, const char *n
|
|||||||
m_ParseState = PPS_InPhrase;
|
m_ParseState = PPS_InPhrase;
|
||||||
recognized = true;
|
recognized = true;
|
||||||
|
|
||||||
phrase_t *pPhrase;
|
void *value;
|
||||||
m_CurPhrase = m_pMemory->CreateMem(sizeof(phrase_t), (void **)&pPhrase);
|
if (sm_trie_retrieve(m_pPhraseLookup, name, &value))
|
||||||
|
{
|
||||||
|
m_CurPhrase = reinterpret_cast<int>(value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
phrase_t *pPhrase;
|
||||||
|
|
||||||
|
m_CurPhrase = m_pMemory->CreateMem(sizeof(phrase_t), (void **)&pPhrase);
|
||||||
|
sm_trie_insert(m_pPhraseLookup, name, reinterpret_cast<void *>(m_CurPhrase));
|
||||||
|
|
||||||
/* Create the reverse lookup */
|
|
||||||
if (!sm_trie_insert(m_pPhraseLookup, name, reinterpret_cast<void *>(m_CurPhrase)))
|
|
||||||
{
|
|
||||||
ParseWarning("Skipping duplicate phrase \"%s\" on line %d.", name, states->line);
|
|
||||||
/* :IDEA: prevent memory waste by seeking backwards in memtable? */
|
|
||||||
m_CurPhrase = -1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Initialize new phrase */
|
/* Initialize new phrase */
|
||||||
trans_t *pTrans;
|
trans_t *pTrans;
|
||||||
|
|
||||||
pPhrase->fmt_count = 0;
|
pPhrase->fmt_count = 0;
|
||||||
pPhrase->fmt_list = -1;
|
pPhrase->fmt_list = -1;
|
||||||
|
|
||||||
@ -202,13 +241,14 @@ SMCResult CPhraseFile::ReadSMC_NewSection(const SMCStates *states, const char *n
|
|||||||
|
|
||||||
pPhrase->translations = 0;
|
pPhrase->translations = 0;
|
||||||
pPhrase->fmt_bytes = 0;
|
pPhrase->fmt_bytes = 0;
|
||||||
|
|
||||||
for (unsigned int i=0; i<m_LangCount; i++)
|
for (unsigned int i=0; i<m_LangCount; i++)
|
||||||
{
|
{
|
||||||
pTrans[i].stridx = -1;
|
pTrans[i].stridx = -1;
|
||||||
}
|
}
|
||||||
m_LastPhraseString.assign(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_LastPhraseString.assign(name);
|
||||||
}
|
}
|
||||||
else if (m_ParseState == PPS_InPhrase)
|
else if (m_ParseState == PPS_InPhrase)
|
||||||
{
|
{
|
||||||
@ -233,15 +273,12 @@ SMCResult CPhraseFile::ReadSMC_KeyValue(const SMCStates *states, const char *key
|
|||||||
}
|
}
|
||||||
|
|
||||||
phrase_t *pPhrase = (phrase_t *)m_pMemory->GetAddress(m_CurPhrase);
|
phrase_t *pPhrase = (phrase_t *)m_pMemory->GetAddress(m_CurPhrase);
|
||||||
|
|
||||||
if (key[0] == '#' && strcmp(key, "#format") == 0)
|
|
||||||
{
|
|
||||||
if (pPhrase->fmt_list != -1)
|
|
||||||
{
|
|
||||||
ParseWarning("Ignoring duplicated #format property on line %d", states->line);
|
|
||||||
return SMCResult_Continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/* Duplicate format keys get silently ignored. */
|
||||||
|
if (key[0] == '#'
|
||||||
|
&& strcmp(key, "#format") == 0
|
||||||
|
&& pPhrase->fmt_list == -1)
|
||||||
|
{
|
||||||
if (pPhrase->translations > 0)
|
if (pPhrase->translations > 0)
|
||||||
{
|
{
|
||||||
ParseWarning("#format property should come before translations on line %d, ignoring", states->line);
|
ParseWarning("#format property should come before translations on line %d, ignoring", states->line);
|
||||||
|
Loading…
Reference in New Issue
Block a user