diff options
author | Johannes Schickel | 2010-10-13 03:57:44 +0000 |
---|---|---|
committer | Johannes Schickel | 2010-10-13 03:57:44 +0000 |
commit | 75e8452b6e6a2bf4fb2f588aa00b428a60d873b5 (patch) | |
tree | f29541d55309487a94bd1d38e8b53bb3dde9aec6 /common/translation.h | |
parent | 48ee83b88957dab86bc763e9ef21a70179fa8679 (diff) | |
parent | e9f50882ea5b6beeefa994040be9d3bab6a1f107 (diff) | |
download | scummvm-rg350-75e8452b6e6a2bf4fb2f588aa00b428a60d873b5.tar.gz scummvm-rg350-75e8452b6e6a2bf4fb2f588aa00b428a60d873b5.tar.bz2 scummvm-rg350-75e8452b6e6a2bf4fb2f588aa00b428a60d873b5.zip |
OPENGL: Merged from trunk, from rev 52105 to 53396.
This includes an rather hacky attempt to merge all the recent gp2x backend
changes into the branch. I suppose the gp2x backend and probably all new
backends, i.e. gph, dingux etc., might not compile anymore.
Since I have no way of testing those it would be nice if porters could look
into getting those up to speed in this branch.
svn-id: r53399
Diffstat (limited to 'common/translation.h')
-rw-r--r-- | common/translation.h | 93 |
1 files changed, 83 insertions, 10 deletions
diff --git a/common/translation.h b/common/translation.h index ccdd0f3500..ff0a8a2acf 100644 --- a/common/translation.h +++ b/common/translation.h @@ -27,6 +27,8 @@ #include "common/singleton.h" #include "common/str-array.h" +#include "common/file.h" +#include "common/fs.h" namespace Common { @@ -39,19 +41,20 @@ struct TLanguage { const char *name; int id; - TLanguage() { - name = 0; - id = 0; - } - - TLanguage(const char *n, int i) { - name = n; - id = i; - } + TLanguage() : name(0), id(0) {} + TLanguage(const char *n, int i) : name(n), id(i) {} }; +bool operator<(const TLanguage &l, const TLanguage &r); + typedef Array<TLanguage> TLangArray; +struct PoMessageEntry { + int msgid; + String msgctxt; + String msgstr; +}; + /** * Message translation manager. */ @@ -115,6 +118,28 @@ public: String getTranslation(const String &message); /** + * Returns the translation into the current language of the parameter + * message. In case the message isn't found in the translation catalog, + * it returns the original untranslated message. + * + * If a translation is found for the given context it will return that + * translation, otherwise it will look for a translation for the same + * massage without a context or with a different context. + */ + const char *getTranslation(const char *message, const char *context); + + /** + * Returns the translation into the current language of the parameter + * message. In case the message isn't found in the translation catalog, + * it returns the original untranslated message. + * + * If a translation is found for the given context it will return that + * translation, otherwise it will look for a translation for the same + * massage without a context or with a different context. + */ + String getTranslation(const String &message, const String &context); + + /** * Returns a list of supported languages. * * @return The list of supported languages in a user readable form. @@ -126,8 +151,52 @@ public: */ const char *getCurrentCharset(); + /** + * Returns currently selected translation language + */ + const char *getCurrentLanguage(); + private: - Common::String _syslang; +#ifdef USE_TRANSLATION + /** + * Find the translations.dat file. It looks first using the SearchMan and + * then if needed using the Themepath. If found it opens the given File + * to read the translations.dat file. + */ + bool openTranslationsFile(File&); + + /** + * Find the translations.dat file in the given directory node. + * If found it opens the given File to read the translations.dat file. + */ + bool openTranslationsFile(const FSNode &node, File&, int depth = -1); + + /** + * Load the list of languages from the translations.dat file + */ + void loadTranslationsInfoDat(); + + /** + * Load the translation for the given language from the translations.dat file + * + * @param index of the language in the list of languages + */ + void loadLanguageDat(int index); + + /** + * Check the header of the given file to make sure it is a valid translations data file. + */ + bool checkHeader(File &in); + + String _syslang; + StringArray _langs; + StringArray _langNames; + + StringArray _messageIds; + Array<PoMessageEntry> _currentTranslationMessages; + String _currentCharset; + int _currentLang; +#endif }; } // End of namespace Common @@ -136,10 +205,14 @@ private: #ifdef USE_TRANSLATION #define _(str) TransMan.getTranslation(str) +#define _c(str, context) TransMan.getTranslation(str, context) #else #define _(str) str +#define _c(str, context) str #endif #define _s(str) str +#define _sc(str, ctxt) str +#define DECLARE_TRANSLATION_ADDITIONAL_CONTEXT(str, ctxt) #endif |