Changeset 7401 for code/trunk/src/libraries/core/Language.h
- Timestamp:
- Sep 11, 2010, 12:34:00 AM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/doc (added) merged: 7290-7292,7296-7300,7302-7304,7306-7312,7315-7318,7323,7325,7327,7331-7332,7334-7335,7345-7347,7352-7353,7356-7357,7361,7363-7367,7371-7375,7388
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/Language.h
r7284 r7401 28 28 29 29 /** 30 @defgroup Language Language 31 @ingroup Core 32 */ 33 34 /** 30 35 @file 31 @brief Definition of the Language and the LanguageEntry class. 36 @ingroup Language 37 @brief Declaration of the Language and the LanguageEntry class, as well as some helper functions. 38 39 @anchor LanguageExample 32 40 33 41 The Language class is used, to get a localisation of a string in the configured language. … … 37 45 Usage: 38 46 - Set the entry with the default string: 47 @code 39 48 Language::getInstance()->addEntry("label of the entry", "the string to translate"); 49 @endcode 40 50 41 51 - Get the localisation of the entry in the configured language: 52 @code 42 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 43 87 */ 44 88 … … 58 102 // ### LanguageEntry ### 59 103 // ############################### 60 //! 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 */ 61 109 class _CoreExport LanguageEntry 62 110 { … … 105 153 // ### Language ### 106 154 // ############################### 107 //! 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 */ 108 160 class _CoreExport Language : public Singleton<Language> 109 161 { … … 134 186 }; 135 187 136 // !Shortcut function for Language::addEntry188 /// Shortcut function for Language::addEntry 137 189 inline void AddLanguageEntry(const LanguageEntryLabel& label, const std::string& fallbackString) 138 190 { … … 140 192 } 141 193 142 // !Shortcut function for Language::getLocalisation194 /// Shortcut function for Language::getLocalisation 143 195 inline const std::string& GetLocalisation(const LanguageEntryLabel& label) 144 196 { … … 146 198 } 147 199 148 // !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 149 201 inline const std::string& GetLocalisation_noerror(const LanguageEntryLabel& label) 150 202 {
Note: See TracChangeset
for help on using the changeset viewer.