Changeset 838 for code/branches/core/src/orxonox/core/Language.h
- Timestamp:
- Feb 27, 2008, 12:54:00 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core/src/orxonox/core/Language.h
r826 r838 30 30 @brief Definition of the Language and the LanguageEntry class. 31 31 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 nameof 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. 34 34 If the translation in the configured language isn't available, the default entry, defined in the code, is used. 35 35 36 36 Usage: 37 37 - Set the entry with the default string: 38 Language::getLanguage()->addEntry(" nameof the entry", "the string to translate");38 Language::getLanguage()->addEntry("label of the entry", "the string to translate"); 39 39 40 - Get the translation of the entry in the configured language:41 std::cout << Language::getLanguage()->get Translation("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; 42 42 */ 43 43 … … 61 61 public: 62 62 explicit LanguageEntry(const std::string& fallbackEntry); 63 void set Translation(const std::string& translation);63 void setLocalisation(const std::string& localisation); 64 64 void setDefault(const std::string& fallbackEntry); 65 65 66 66 /** 67 @brief Returns the translated entry in the configured language.67 @brief Returns the localised entry in the configured language. 68 68 @return The translated entry 69 69 */ 70 inline const std::string& get Translation()71 { return this-> translatedEntry_; }70 inline const std::string& getLocalisation() 71 { return this->localisedEntry_; } 72 72 73 73 /** … … 80 80 private: 81 81 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 language83 bool b TranslationSet_;//!< True if the translation was set82 std::string localisedEntry_; //!< The localised entry in the configured language 83 bool bLocalisationSet_; //!< True if the translation was set 84 84 }; 85 85 template class _CoreExport orxonox::ClassIdentifier<LanguageEntry>; … … 99 99 static Language& getLanguage(); 100 100 void setConfigValues(); 101 void addEntry(const LanguageEntry Name& name, const std::string& entry);102 const std::string& get Translation(const LanguageEntryName& name) const;101 void addEntry(const LanguageEntryLabel& label, const std::string& entry); 102 const std::string& getLocalisation(const LanguageEntryLabel& label) const; 103 103 104 104 private: … … 111 111 void writeDefaultLanguageFile() const; 112 112 static const std::string getFileName(const std::string& language); 113 LanguageEntry* createEntry(const LanguageEntry Name& name, const std::string& entry);113 LanguageEntry* createEntry(const LanguageEntryLabel& label, const std::string& entry); 114 114 115 115 std::string language_; //!< The configured language 116 116 std::string defaultLanguage_; //!< The default language 117 std::string default Translation_;//!< The returned string, if an entry unavailable entry is requested118 std::map<std::string, LanguageEntry*> languageEntries_; //!< A map to store all LanguageEntry objects and their name117 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 119 119 }; 120 120 template class _CoreExport orxonox::ClassIdentifier<Language>;
Note: See TracChangeset
for help on using the changeset viewer.