Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 725


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

Location:
code/branches/FICN/src/orxonox/core
Files:
3 edited

Legend:

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

    r724 r725  
    948948        {
    949949            this->description_ = std::string("ConfigValueDescription::" + this->classname_ + "::" + this->varname_);
    950             Language::getLanguage().addEntry(description_, description);
     950            Language::getLanguage().addEntry(this->description_, description);
    951951            this->bAddedDescription_ = true;
     952            COUT(4) << "Added description " << this->description_ << std::endl;
     953            COUT(4) << "Translation is: " << Language::getLanguage().getTranslation(this->description_) << std::endl;
    952954        }
    953955    }
  • 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
  • code/branches/FICN/src/orxonox/core/Language.h

    r720 r725  
    7474            std::string fallbackEntry_;                             //!< The default entry: Used, if no translation is available or no language configured
    7575            std::string translatedEntry_;                           //!< The translated entry in the configured language
     76            bool bTranslationSet_;                                  //!< True if the translation was set
    7677    };
    7778
     
    9495            void writeDefaultLanguageFile() const;
    9596            static const std::string getFileName(const std::string& language);
    96             void createEntry(const LanguageEntryName& name, const std::string& entry);
     97            LanguageEntry* createEntry(const LanguageEntryName& name, const std::string& entry);
    9798
    9899            std::string language_;                                  //!< The configured language
Note: See TracChangeset for help on using the changeset viewer.