Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 29, 2007, 11:17:08 PM (16 years ago)
Author:
landauf
Message:

it's now possible to use a translation without already existing translation_default.lang file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/orxonox/core/Language.cc

    r720 r725  
    5151        this->fallbackEntry_ = fallbackEntry;
    5252        this->translatedEntry_ = fallbackEntry; // Set the translation to the fallback entry, for the case that no translation gets assigned
     53        this->bTranslationSet_ = false;
    5354    }
    5455
     
    6162        // Check if the translation is more than just an empty string
    6263        if (translation.compare("") != 0)
     64        {
    6365            this->translatedEntry_ = translation;
     66            this->bTranslationSet_ = true;
     67        }
    6468        else
    6569            this->translatedEntry_ = this->fallbackEntry_;
     
    7377    {
    7478        // 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_)
    7680            this->translatedEntry_ = fallbackEntry;
    7781
     
    131135        @param name The name of the entry
    132136        @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
    136143        // Make sure we don't create a duplicate entry
    137         if (!this->languageEntries_[name])
     144        if (!it->second)
    138145        {
    139146            LanguageEntry* newEntry = new LanguageEntry(entry);
    140147            newEntry->setName(name);
    141148            this->languageEntries_[name] = newEntry;
    142         }
    143         else
    144         {
    145             COUT(2) << "Warning: Language entry " << name << " is duplicate in " << getFileName(this->defaultLanguage_) << "!" << std::endl;
    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;
    147154    }
    148155
     
    290297                        it->second->setTranslation(lineString.substr(pos + 1));
    291298                    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));
    293300                }
    294301                else
Note: See TracChangeset for help on using the changeset viewer.