Changeset 720 for code/branches/FICN/src/orxonox/core/Language.h
- Timestamp:
- Dec 29, 2007, 2:37:45 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/orxonox/core/Language.h
r715 r720 26 26 */ 27 27 28 /*! 29 @file Language.h 30 @brief Definition of the Language and the LanguageEntry class. 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 name of the entry. 34 If the translation in the configured language isn't available, the default entry, defined in the code, is used. 35 36 Usage: 37 - Set the entry with the default string: 38 Language::getLanguage()->addEntry("name of the entry", "the string to translate"); 39 40 - Get the translation of the entry in the configured language: 41 std::cout << Language::getLanguage()->getTranslation("name of the entry") << std::endl; 42 */ 43 28 44 #ifndef _Language_H__ 29 45 #define _Language_H__ … … 33 49 34 50 #include "CorePrereqs.h" 35 36 51 #include "OrxonoxClass.h" 37 52 … … 40 55 typedef std::string LanguageEntryName; 41 56 57 //! The LanguageEntry class stores the default- and the translated string of a given entry in the language file. 42 58 class _CoreExport LanguageEntry : public OrxonoxClass 43 59 { … … 47 63 void setDefault(const std::string& fallbackEntry); 48 64 65 /** @brief Returns the translated entry in the configured language. @return The translated entry */ 49 66 inline const std::string& getTranslation() 50 67 { return this->translatedEntry_; } 51 68 69 /** @brief Returns the default entry. @return The default entry */ 52 70 inline const std::string& getDefault() 53 71 { return this->fallbackEntry_; } 54 72 55 73 private: 56 std::string fallbackEntry_; 57 std::string translatedEntry_; 74 std::string fallbackEntry_; //!< The default entry: Used, if no translation is available or no language configured 75 std::string translatedEntry_; //!< The translated entry in the configured language 58 76 }; 59 77 78 //! The Language class manges the language files and entries and stores the LanguageEntry objects in a map. 60 79 class _CoreExport Language : public OrxonoxClass 61 80 { … … 77 96 void createEntry(const LanguageEntryName& name, const std::string& entry); 78 97 79 std::string language_; 80 std::string defaultLanguage_; 81 std::string defaultTranslation_; 82 std::map<std::string, LanguageEntry*> languageEntries_; 98 std::string language_; //!< The configured language 99 std::string defaultLanguage_; //!< The default language 100 std::string defaultTranslation_; //!< The returned string, if an entry unavailable entry is requested 101 std::map<std::string, LanguageEntry*> languageEntries_; //!< A map to store all LanguageEntry objects and their name 83 102 }; 84 103 }
Note: See TracChangeset
for help on using the changeset viewer.