Changeset 725 for code/branches/FICN
- Timestamp:
- Dec 29, 2007, 11:17:08 PM (17 years ago)
- Location:
- code/branches/FICN/src/orxonox/core
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/orxonox/core/ConfigValueContainer.cc
r724 r725 948 948 { 949 949 this->description_ = std::string("ConfigValueDescription::" + this->classname_ + "::" + this->varname_); 950 Language::getLanguage().addEntry( description_, description);950 Language::getLanguage().addEntry(this->description_, description); 951 951 this->bAddedDescription_ = true; 952 COUT(4) << "Added description " << this->description_ << std::endl; 953 COUT(4) << "Translation is: " << Language::getLanguage().getTranslation(this->description_) << std::endl; 952 954 } 953 955 } -
code/branches/FICN/src/orxonox/core/Language.cc
r720 r725 51 51 this->fallbackEntry_ = fallbackEntry; 52 52 this->translatedEntry_ = fallbackEntry; // Set the translation to the fallback entry, for the case that no translation gets assigned 53 this->bTranslationSet_ = false; 53 54 } 54 55 … … 61 62 // Check if the translation is more than just an empty string 62 63 if (translation.compare("") != 0) 64 { 63 65 this->translatedEntry_ = translation; 66 this->bTranslationSet_ = true; 67 } 64 68 else 65 69 this->translatedEntry_ = this->fallbackEntry_; … … 73 77 { 74 78 // If the default entry changes and the translation wasn't set yet, use the new default entry as translation 75 if ( this->translatedEntry_.compare(this->fallbackEntry_) == 0)79 if (!this->bTranslationSet_) 76 80 this->translatedEntry_ = fallbackEntry; 77 81 … … 131 135 @param name The name of the entry 132 136 @param entry The default entry 133 */ 134 void Language::createEntry(const LanguageEntryName& name, const std::string& entry) 135 { 137 @return The created LanguageEntry object 138 */ 139 LanguageEntry* Language::createEntry(const LanguageEntryName& name, const std::string& entry) 140 { 141 std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.find(name); 142 136 143 // Make sure we don't create a duplicate entry 137 if (! this->languageEntries_[name])144 if (!it->second) 138 145 { 139 146 LanguageEntry* newEntry = new LanguageEntry(entry); 140 147 newEntry->setName(name); 141 148 this->languageEntries_[name] = newEntry; 142 }143 else144 { 145 146 }149 return newEntry; 150 } 151 152 COUT(2) << "Warning: Language entry " << name << " is duplicate in " << getFileName(this->defaultLanguage_) << "!" << std::endl; 153 return it->second; 147 154 } 148 155 … … 290 297 it->second->setTranslation(lineString.substr(pos + 1)); 291 298 else 292 COUT(2) << "Warning: Unknown language entry \"" << lineString.substr(0, pos) << "\" in " << getFileName(this->language_) << std::endl;299 this->createEntry(lineString.substr(0, pos), this->defaultTranslation_)->setTranslation(lineString.substr(pos + 1)); 293 300 } 294 301 else -
code/branches/FICN/src/orxonox/core/Language.h
r720 r725 74 74 std::string fallbackEntry_; //!< The default entry: Used, if no translation is available or no language configured 75 75 std::string translatedEntry_; //!< The translated entry in the configured language 76 bool bTranslationSet_; //!< True if the translation was set 76 77 }; 77 78 … … 94 95 void writeDefaultLanguageFile() const; 95 96 static const std::string getFileName(const std::string& language); 96 voidcreateEntry(const LanguageEntryName& name, const std::string& entry);97 LanguageEntry* createEntry(const LanguageEntryName& name, const std::string& entry); 97 98 98 99 std::string language_; //!< The configured language
Note: See TracChangeset
for help on using the changeset viewer.