Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 838


Ignore:
Timestamp:
Feb 27, 2008, 12:54:00 AM (17 years ago)
Author:
landauf
Message:

changed naming in Language: translation → localisation, name → label

Location:
code/branches/core/src/orxonox/core
Files:
5 edited

Legend:

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

    r826 r838  
    959959    std::string ConfigValueContainer::getDescription() const
    960960    {
    961         return Language::getLanguage().getTranslation(this->description_);
     961        return Language::getLanguage().getLocalisation(this->description_);
    962962    }
    963963}
  • code/branches/core/src/orxonox/core/ConfigValueContainer.h

    r826 r838  
    150150
    151151            bool bAddedDescription_;                            //!< True if a description was added
    152             LanguageEntryName description_;                     //!< The description
     152            LanguageEntryLabel description_;                    //!< The description
    153153    };
    154154}
  • code/branches/core/src/orxonox/core/CorePrereqs.h

    r826 r838  
    6565namespace orxonox
    6666{
    67   typedef std::string LanguageEntryName;
     67  typedef std::string LanguageEntryLabel;
    6868
    6969  class ArgReader;
  • code/branches/core/src/orxonox/core/Language.cc

    r820 r838  
    5050
    5151        this->fallbackEntry_ = fallbackEntry;
    52         this->translatedEntry_ = fallbackEntry; // Set the translation to the fallback entry, for the case that no translation gets assigned
    53         this->bTranslationSet_ = false;
    54     }
    55 
    56     /**
    57         @brief Sets the translation of the entry.
    58         @param translation The translation
    59     */
    60     void LanguageEntry::setTranslation(const std::string& translation)
     52        this->localisedEntry_ = fallbackEntry; // Set the localisation to the fallback entry, for the case that no translation gets assigned
     53        this->bLocalisationSet_ = false;
     54    }
     55
     56    /**
     57        @brief Sets the localisation of the entry.
     58        @param localisation The localisation
     59    */
     60    void LanguageEntry::setLocalisation(const std::string& localisation)
    6161    {
    6262        // Check if the translation is more than just an empty string
    63         if (translation.compare("") != 0)
    64         {
    65             this->translatedEntry_ = translation;
    66             this->bTranslationSet_ = true;
     63        if (localisation.compare("") != 0)
     64        {
     65            this->localisedEntry_ = localisation;
     66            this->bLocalisationSet_ = true;
    6767        }
    6868        else
    69             this->translatedEntry_ = this->fallbackEntry_;
     69            this->localisedEntry_ = this->fallbackEntry_;
    7070    }
    7171
     
    7777    {
    7878        // If the default entry changes and the translation wasn't set yet, use the new default entry as translation
    79         if (!this->bTranslationSet_)
    80             this->translatedEntry_ = fallbackEntry;
     79        if (!this->bLocalisationSet_)
     80            this->localisedEntry_ = fallbackEntry;
    8181
    8282        this->fallbackEntry_ = fallbackEntry;
     
    9494
    9595        this->defaultLanguage_ = "default";
    96         this->defaultTranslation_ = "ERROR: LANGUAGE ENTRY DOESN'T EXIST!";
     96        this->defaultLocalisation_ = "ERROR: LANGUAGE ENTRY DOESN'T EXIST!";
    9797
    9898        // Read the default language file to create all known LanguageEntry objects
     
    132132
    133133    /**
    134         @brief Creates a new LanguageEntry with a given name and a given default entry.
    135         @param name The name of the entry
     134        @brief Creates a new LanguageEntry with a given label and a given default entry.
     135        @param label The label of the entry
    136136        @param entry The default entry
    137137        @return The created LanguageEntry object
    138138    */
    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);
     139    LanguageEntry* Language::createEntry(const LanguageEntryLabel& label, const std::string& entry)
     140    {
     141        std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.find(label);
    142142
    143143        // Make sure we don't create a duplicate entry
     
    145145        {
    146146            LanguageEntry* newEntry = new LanguageEntry(entry);
    147             newEntry->setName(name);
    148             this->languageEntries_[name] = newEntry;
     147            newEntry->setName(label);
     148            this->languageEntries_[label] = newEntry;
    149149            return newEntry;
    150150        }
    151151
    152         COUT(2) << "Warning: Language entry " << name << " is duplicate in " << getFileName(this->defaultLanguage_) << "!" << std::endl;
     152        COUT(2) << "Warning: Language entry " << label << " is duplicate in " << getFileName(this->defaultLanguage_) << "!" << std::endl;
    153153        return it->second;
    154154    }
     
    156156    /**
    157157        @brief Adds a new LanguageEntry, if it's not already existing.
    158         @param name The name of the entry
     158        @param label The label of the entry
    159159        @param entry The default entry
    160160    */
    161     void Language::addEntry(const LanguageEntryName& name, const std::string& entry)
    162     {
    163         COUT(5) << "Language: Called addEntry with\n  name: " << name << "\n  entry: " <<  entry << std::endl;
    164         std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.find(name);
     161    void Language::addEntry(const LanguageEntryLabel& label, const std::string& entry)
     162    {
     163        COUT(5) << "Language: Called addEntry with\n  label: " << label << "\n  entry: " <<  entry << std::endl;
     164        std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.find(label);
    165165        if (it == this->languageEntries_.end())
    166166        {
    167167            // The entry isn't available yet, meaning it's new, so create it
    168             this->createEntry(name, entry);
     168            this->createEntry(label, entry);
    169169        }
    170170        else if (it->second->getDefault().compare(entry) == 0)
     
    185185
    186186    /**
    187         @brief Returns the translation of a given entry.
    188         @param name The name of the entry
    189         @return The translation
    190     */
    191     const std::string& Language::getTranslation(const LanguageEntryName& name) const
    192     {
    193         std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.find(name);
     187        @brief Returns the localisation of a given entry.
     188        @param label The label of the entry
     189        @return The localisation
     190    */
     191    const std::string& Language::getLocalisation(const LanguageEntryLabel& label) const
     192    {
     193        std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.find(label);
    194194        if (it != this->languageEntries_.end())
    195             return it->second->getTranslation();
     195            return it->second->getLocalisation();
    196196        else
    197197        {
    198198            // Uh, oh, an undefined entry was requested: return the default string
    199             COUT(2) << "Warning: Language entry \"" << name << "\" not found!" << std::endl;
    200             return this->defaultTranslation_;
     199            COUT(2) << "Warning: Language entry \"" << label << "\" not found!" << std::endl;
     200            return this->defaultLocalisation_;
    201201        }
    202202    }
     
    260260
    261261    /**
    262         @brief Reads the language file of the configured language and assigns the translations to the corresponding LanguageEntry object.
     262        @brief Reads the language file of the configured language and assigns the localisation to the corresponding LanguageEntry object.
    263263    */
    264264    void Language::readTranslatedLanguageFile()
     
    299299                    // Check if the entry exists
    300300                    if (it != this->languageEntries_.end())
    301                         it->second->setTranslation(lineString.substr(pos + 1));
     301                        it->second->setLocalisation(lineString.substr(pos + 1));
    302302                    else
    303                         this->createEntry(lineString.substr(0, pos), this->defaultTranslation_)->setTranslation(lineString.substr(pos + 1));
     303                        this->createEntry(lineString.substr(0, pos), this->defaultLocalisation_)->setLocalisation(lineString.substr(pos + 1));
    304304                }
    305305                else
  • code/branches/core/src/orxonox/core/Language.h

    r826 r838  
    3030    @brief Definition of the Language and the LanguageEntry class.
    3131
    32     The Language class is used, to get a translation of a string in the configured language.
    33     The string is identified by another string, the name of the entry.
     32    The Language class is used, to get a localisation of a string in the configured language.
     33    The string is identified by another string, the label of the entry.
    3434    If the translation in the configured language isn't available, the default entry, defined in the code, is used.
    3535
    3636    Usage:
    3737     - Set the entry with the default string:
    38        Language::getLanguage()->addEntry("name of the entry", "the string to translate");
     38       Language::getLanguage()->addEntry("label of the entry", "the string to translate");
    3939
    40      - Get the translation of the entry in the configured language:
    41        std::cout << Language::getLanguage()->getTranslation("name of the entry") << std::endl;
     40     - Get the localisation of the entry in the configured language:
     41       std::cout << Language::getLanguage()->getLocalisation("name of the entry") << std::endl;
    4242*/
    4343
     
    6161        public:
    6262            explicit LanguageEntry(const std::string& fallbackEntry);
    63             void setTranslation(const std::string& translation);
     63            void setLocalisation(const std::string& localisation);
    6464            void setDefault(const std::string& fallbackEntry);
    6565
    6666            /**
    67               @brief Returns the translated entry in the configured language.
     67              @brief Returns the localised entry in the configured language.
    6868              @return The translated entry
    6969            */
    70             inline const std::string& getTranslation()
    71                 { return this->translatedEntry_; }
     70            inline const std::string& getLocalisation()
     71                { return this->localisedEntry_; }
    7272
    7373            /**
     
    8080        private:
    8181            std::string fallbackEntry_;                             //!< The default entry: Used, if no translation is available or no language configured
    82             std::string translatedEntry_;                           //!< The translated entry in the configured language
    83             bool bTranslationSet_;                                  //!< True if the translation was set
     82            std::string localisedEntry_;                            //!< The localised entry in the configured language
     83            bool bLocalisationSet_;                                 //!< True if the translation was set
    8484    };
    8585    template class _CoreExport orxonox::ClassIdentifier<LanguageEntry>;
     
    9999            static Language& getLanguage();
    100100            void setConfigValues();
    101             void addEntry(const LanguageEntryName& name, const std::string& entry);
    102             const std::string& getTranslation(const LanguageEntryName& name) const;
     101            void addEntry(const LanguageEntryLabel& label, const std::string& entry);
     102            const std::string& getLocalisation(const LanguageEntryLabel& label) const;
    103103
    104104        private:
     
    111111            void writeDefaultLanguageFile() const;
    112112            static const std::string getFileName(const std::string& language);
    113             LanguageEntry* createEntry(const LanguageEntryName& name, const std::string& entry);
     113            LanguageEntry* createEntry(const LanguageEntryLabel& label, const std::string& entry);
    114114
    115115            std::string language_;                                  //!< The configured language
    116116            std::string defaultLanguage_;                           //!< The default language
    117             std::string defaultTranslation_;                        //!< The returned string, if an entry unavailable entry is requested
    118             std::map<std::string, LanguageEntry*> languageEntries_; //!< A map to store all LanguageEntry objects and their name
     117            std::string defaultLocalisation_;                       //!< The returned string, if an entry unavailable entry is requested
     118            std::map<std::string, LanguageEntry*> languageEntries_; //!< A map to store all LanguageEntry objects and their labels
    119119    };
    120120    template class _CoreExport orxonox::ClassIdentifier<Language>;
Note: See TracChangeset for help on using the changeset viewer.