From 4e357549d57c1d820e320461450d52e36d10f477 Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Sat, 13 Nov 2010 23:27:13 +0000 Subject: COMMON: Fix TranslationManager Revision 54206 broke translations support because it uncovered a bug in the TranslationManager when reading the translations.dat file. In that file all the stored string lengths include the terminating 0 but Common::String expect a length without the terminating 0. Therefore all String objects created from reading the translations.dat file had an incorrect size. This caused the font file names to be wrong after adding the charset. svn-id: r54235 --- common/translation.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'common') diff --git a/common/translation.cpp b/common/translation.cpp index 9e81816234..70dac7a318 100644 --- a/common/translation.cpp +++ b/common/translation.cpp @@ -258,7 +258,7 @@ String TranslationManager::getLangById(int id) const { return "C"; default: if (id >= 0 && id - 1 < (int)_langs.size()) - return _langs[id - 1].c_str(); + return _langs[id - 1]; } // In case an invalid ID was specified, we will output a warning @@ -336,10 +336,10 @@ void TranslationManager::loadTranslationsInfoDat() { for (int i = 0; i < nbTranslations; ++i) { len = in.readUint16BE(); in.read(buf, len); - _langs[i] = String(buf, len); + _langs[i] = String(buf, len-1); len = in.readUint16BE(); in.read(buf, len); - _langNames[i] = String(buf, len); + _langNames[i] = String(buf, len-1); } // Read messages @@ -348,7 +348,7 @@ void TranslationManager::loadTranslationsInfoDat() { for (int i = 0; i < numMessages; ++i) { len = in.readUint16BE(); in.read(buf, len); - _messageIds[i] = String(buf, len); + _messageIds[i] = String(buf, len-1); } } @@ -396,18 +396,18 @@ void TranslationManager::loadLanguageDat(int index) { // Read charset len = in.readUint16BE(); in.read(buf, len); - _currentCharset = String(buf, len); + _currentCharset = String(buf, len-1); // Read messages for (int i = 0; i < nbMessages; ++i) { _currentTranslationMessages[i].msgid = in.readUint16BE(); len = in.readUint16BE(); in.read(buf, len); - _currentTranslationMessages[i].msgstr = String(buf, len); + _currentTranslationMessages[i].msgstr = String(buf, len-1); len = in.readUint16BE(); if (len > 0) { in.read(buf, len); - _currentTranslationMessages[i].msgctxt = String(buf, len); + _currentTranslationMessages[i].msgctxt = String(buf, len-1); } } } -- cgit v1.2.3