Changeset 7372 for code/branches/doc/src/libraries/core/Language.h
- Timestamp:
- Sep 7, 2010, 12:58:52 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/doc/src/libraries/core/Language.h
r7363 r7372 35 35 @file 36 36 @ingroup Language 37 @brief Definition of the Language and the LanguageEntry class. 37 @brief Declaration of the Language and the LanguageEntry class, as well as some helper functions. 38 39 @anchor LanguageExample 38 40 39 41 The Language class is used, to get a localisation of a string in the configured language. … … 43 45 Usage: 44 46 - Set the entry with the default string: 47 @code 45 48 Language::getInstance()->addEntry("label of the entry", "the string to translate"); 49 @endcode 46 50 47 51 - Get the localisation of the entry in the configured language: 52 @code 48 53 std::cout << Language::getInstance()->getLocalisation("name of the entry") << std::endl; 54 @endcode 55 56 Example: 57 @code 58 int age = 20; 59 AddLanguageEntry("user_age", "Age"); 60 std::cout << GetLocalisation("user_age") << ": " << age << std::endl; 61 @endcode 62 63 Resulting output: 64 @code 65 Age: 20 66 @endcode 67 68 The language entry is now defined in @a translation_default.lang: 69 @code 70 user_age=Age 71 @endcode 72 73 We can add a translation for another language, for example @a translation_german.lang: 74 @code 75 user_age=Alter 76 @endcode 77 78 Now change the language in @a orxonox.ini to "german": 79 @code 80 language_ = "german" 81 @endcode 82 83 Now you will see the translated language entry in the resulting output of the above code: 84 @code 85 Alter: 20 86 @endcode 49 87 */ 50 88 … … 64 102 // ### LanguageEntry ### 65 103 // ############################### 66 //! The LanguageEntry class stores the default- and the translated string of a given entry in the language file. 104 /** 105 @brief The LanguageEntry class stores the default- and the translated string of a given entry in the language file. 106 107 This class belongs to the Language class. 108 */ 67 109 class _CoreExport LanguageEntry 68 110 { … … 111 153 // ### Language ### 112 154 // ############################### 113 //! The Language class manges the language files and entries and stores the LanguageEntry objects in a map. 155 /** 156 @brief The Language class manges the language files and entries and stores the LanguageEntry objects in a map. 157 158 @see See @ref LanguageExample "Language.h" for some examples. 159 */ 114 160 class _CoreExport Language : public Singleton<Language> 115 161 { … … 140 186 }; 141 187 142 // !Shortcut function for Language::addEntry188 /// Shortcut function for Language::addEntry 143 189 inline void AddLanguageEntry(const LanguageEntryLabel& label, const std::string& fallbackString) 144 190 { … … 146 192 } 147 193 148 // !Shortcut function for Language::getLocalisation194 /// Shortcut function for Language::getLocalisation 149 195 inline const std::string& GetLocalisation(const LanguageEntryLabel& label) 150 196 { … … 152 198 } 153 199 154 // !Shortcut function for Language::getLocalisation without printing an error in case the label doesn't exist200 /// Shortcut function for Language::getLocalisation without printing an error in case the label doesn't exist 155 201 inline const std::string& GetLocalisation_noerror(const LanguageEntryLabel& label) 156 202 {
Note: See TracChangeset
for help on using the changeset viewer.