1.1 --- a/core/CTranslator.cpp Fri Jan 26 19:35:33 2007 +0000
1.2 +++ b/core/CTranslator.cpp Fri Jan 26 22:37:54 2007 +0000
1.3 @@ -538,33 +538,35 @@
1.4 }
1.5 }
1.6
1.7 -const char *CPhraseFile::GetTranslation(const Translation *pTrans, int **fmt_order, unsigned int *fmt_count)
1.8 +TransError CPhraseFile::GetTranslation(const char *szPhrase, unsigned int lang_id, Translation *pTrans)
1.9 {
1.10 - if (pTrans->lang_id >= m_LangCount)
1.11 + if (lang_id >= m_LangCount)
1.12 {
1.13 - return NULL;
1.14 + return Trans_BadLanguage;
1.15 }
1.16
1.17 void *object;
1.18 - if (!sm_trie_retrieve(m_pPhraseLookup, pTrans->szPhrase, &object))
1.19 + if (!sm_trie_retrieve(m_pPhraseLookup, szPhrase, &object))
1.20 {
1.21 - return NULL;
1.22 + return Trans_BadPhrase;
1.23 }
1.24
1.25 phrase_t *pPhrase = (phrase_t *)m_pMemory->GetAddress(reinterpret_cast<int>(object));
1.26 trans_t *trans = (trans_t *)m_pMemory->GetAddress(pPhrase->trans_tbl);
1.27
1.28 - trans = &trans[pTrans->lang_id];
1.29 + trans = &trans[lang_id];
1.30
1.31 if (trans->stridx == -1)
1.32 {
1.33 - return NULL;
1.34 + return Trans_BadPhraseLanguage;
1.35 }
1.36
1.37 - *fmt_order = (int *)m_pMemory->GetAddress(trans->fmt_order);
1.38 - *fmt_count = pPhrase->fmt_count;
1.39 + pTrans->fmt_order = (int *)m_pMemory->GetAddress(trans->fmt_order);
1.40 + pTrans->fmt_count = pPhrase->fmt_count;
1.41
1.42 - return m_pStringTab->GetString(trans->stridx);
1.43 + pTrans->szPhrase = m_pStringTab->GetString(trans->stridx);
1.44 +
1.45 + return Trans_Okay;
1.46 }
1.47
1.48 const char *CPhraseFile::GetFilename()
1.49 @@ -735,30 +737,15 @@
1.50 return SMCParse_Continue;
1.51 }
1.52
1.53 -size_t CTranslator::Translate(char *buffer, size_t maxlength, const Translation *pTrans)
1.54 +size_t CTranslator::Translate(char *buffer, size_t maxlength, void **params, const Translation *pTrans)
1.55 {
1.56 - if (pTrans->file_id >= m_Files.size())
1.57 + void *new_params[MAX_TRANSLATE_PARAMS];
1.58 +
1.59 + /* Rewrite the parameter order */
1.60 + for (unsigned int i=0; i<pTrans->fmt_count; i++)
1.61 {
1.62 - return 0;
1.63 + new_params[i] = params[pTrans->fmt_order[i]];
1.64 }
1.65
1.66 - CPhraseFile *pFile = m_Files[pTrans->file_id];
1.67 - unsigned int count;
1.68 - int *order_table;
1.69 - const char *str;
1.70 -
1.71 - if ((str=pFile->GetTranslation(pTrans, &order_table, &count)) == NULL)
1.72 - {
1.73 - return 0;
1.74 - }
1.75 -
1.76 - void *params[MAX_TRANSLATE_PARAMS];
1.77 -
1.78 - /* Rewrite the parameter order */
1.79 - for (unsigned int i=0; i<count; i++)
1.80 - {
1.81 - params[i] = pTrans->params[order_table[i]];
1.82 - }
1.83 -
1.84 - return gnprintf(buffer, maxlength, str, params);
1.85 + return gnprintf(buffer, maxlength, pTrans->szPhrase, new_params);
1.86 }