aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2010-11-11 18:22:35 +0000
committerMax Horn2010-11-11 18:22:35 +0000
commitcc61445599e919f70e07de707ad0c9a13942b38c (patch)
treec28482066c4cc079de6d34f976d690c8327e0609
parent8e274749ed4fb92673a9314286b91229e6bcee7b (diff)
downloadscummvm-rg350-cc61445599e919f70e07de707ad0c9a13942b38c.tar.gz
scummvm-rg350-cc61445599e919f70e07de707ad0c9a13942b38c.tar.bz2
scummvm-rg350-cc61445599e919f70e07de707ad0c9a13942b38c.zip
COMMON: Cleanup translation manager code; add FIXME
svn-id: r54206
-rw-r--r--common/translation.cpp45
-rw-r--r--common/translation.h18
2 files changed, 32 insertions, 31 deletions
diff --git a/common/translation.cpp b/common/translation.cpp
index a33e1a5243..3512edb494 100644
--- a/common/translation.cpp
+++ b/common/translation.cpp
@@ -31,7 +31,7 @@
#define TRANSLATIONS_DAT_VER 2
-#include "translation.h"
+#include "common/translation.h"
#include "common/archive.h"
#include "common/config-manager.h"
@@ -57,6 +57,7 @@ TranslationManager::TranslationManager() : _currentLang(-1) {
loadTranslationsInfoDat();
#ifdef USE_DETECTLANG
+// FIXME: language detection should be done via an OSystem API.
#ifdef WIN32
// We can not use "setlocale" (at least not for MSVC builds), since it
// will return locales like: "English_USA.1252", thus we need a special
@@ -124,7 +125,7 @@ TranslationManager::TranslationManager() : _currentLang(-1) {
TranslationManager::~TranslationManager() {
}
-void TranslationManager::setLanguage(const char *lang) {
+void TranslationManager::setLanguage(const String &lang) {
// Get lang index
int langIndex = -1;
String langStr(lang);
@@ -151,11 +152,11 @@ void TranslationManager::setLanguage(const char *lang) {
}
}
-const char *TranslationManager::getTranslation(const char *message) {
+const char *TranslationManager::getTranslation(const char *message) const {
return getTranslation(message, NULL);
}
-const char *TranslationManager::getTranslation(const char *message, const char *context) {
+const char *TranslationManager::getTranslation(const char *message, const char *context) const {
// if no language is set or message is empty, return msgid as is
if (_currentTranslationMessages.empty() || *message == '\0')
return message;
@@ -207,23 +208,23 @@ const char *TranslationManager::getTranslation(const char *message, const char *
return message;
}
-const char *TranslationManager::getCurrentCharset() {
+String TranslationManager::getCurrentCharset() const {
if (_currentCharset.empty())
return "ASCII";
- return _currentCharset.c_str();
+ return _currentCharset;
}
-const char *TranslationManager::getCurrentLanguage() {
+String TranslationManager::getCurrentLanguage() const {
if (_currentLang == -1)
return "C";
- return _langs[_currentLang].c_str();
+ return _langs[_currentLang];
}
-String TranslationManager::getTranslation(const String &message) {
+String TranslationManager::getTranslation(const String &message) const {
return getTranslation(message.c_str());
}
-String TranslationManager::getTranslation(const String &message, const String &context) {
+String TranslationManager::getTranslation(const String &message, const String &context) const {
return getTranslation(message.c_str(), context.c_str());
}
@@ -240,7 +241,7 @@ const TLangArray TranslationManager::getSupportedLanguageNames() const {
return languages;
}
-int TranslationManager::parseLanguage(const String lang) {
+int TranslationManager::parseLanguage(const String &lang) const {
for (unsigned int i = 0; i < _langs.size(); i++) {
if (lang == _langs[i])
return i + 1;
@@ -249,7 +250,7 @@ int TranslationManager::parseLanguage(const String lang) {
return kTranslationBuiltinId;
}
-const char *TranslationManager::getLangById(int id) {
+String TranslationManager::getLangById(int id) const {
switch (id) {
case kTranslationAutodetectId:
return "";
@@ -444,29 +445,29 @@ TranslationManager::TranslationManager() {}
TranslationManager::~TranslationManager() {}
-void TranslationManager::setLanguage(const char *lang) {}
+void TranslationManager::setLanguage(const String &lang) {}
-const char *TranslationManager::getLangById(int id) {
- return "";
+String TranslationManager::getLangById(int id) const {
+ return String();
}
-int TranslationManager::parseLanguage(const String lang) {
+int TranslationManager::parseLanguage(const String lang) const {
return kTranslationBuiltinId;
}
-const char *TranslationManager::getTranslation(const char *message) {
+const char *TranslationManager::getTranslation(const char *message) const {
return message;
}
-String TranslationManager::getTranslation(const String &message) {
+String TranslationManager::getTranslation(const String &message) const {
return message;
}
-const char *TranslationManager::getTranslation(const char *message, const char *) {
+const char *TranslationManager::getTranslation(const char *message, const char *) const {
return message;
}
-String TranslationManager::getTranslation(const String &message, const String &) {
+String TranslationManager::getTranslation(const String &message, const String &) const {
return message;
}
@@ -474,11 +475,11 @@ const TLangArray TranslationManager::getSupportedLanguageNames() const {
return TLangArray();
}
-const char *TranslationManager::getCurrentCharset() {
+String TranslationManager::getCurrentCharset() const {
return "ASCII";
}
-const char *TranslationManager::getCurrentLanguage() {
+String *TranslationManager::getCurrentLanguage() const {
return "C";
}
diff --git a/common/translation.h b/common/translation.h
index ff0a8a2acf..bc35edf971 100644
--- a/common/translation.h
+++ b/common/translation.h
@@ -73,7 +73,7 @@ public:
* @param id Id of the language
* @return the matching string description of the language
*/
- const char *getLangById(int id);
+ String getLangById(int id) const;
/**
* Sets the current translation language to the one specified in the
@@ -82,7 +82,7 @@ public:
*
* @param lang Language to setup.
*/
- void setLanguage(const char *lang);
+ void setLanguage(const String &lang);
/**
* Sets the current translation language to the one specified by the
@@ -101,21 +101,21 @@ public:
* @return id of the language or kTranslationBuiltinId in case the
* language could not be found.
*/
- int parseLanguage(const String lang);
+ int parseLanguage(const String &lang) const;
/**
* 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.
*/
- const char *getTranslation(const char *message);
+ const char *getTranslation(const char *message) const;
/**
* 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.
*/
- String getTranslation(const String &message);
+ String getTranslation(const String &message) const;
/**
* Returns the translation into the current language of the parameter
@@ -126,7 +126,7 @@ public:
* 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);
+ const char *getTranslation(const char *message, const char *context) const;
/**
* Returns the translation into the current language of the parameter
@@ -137,7 +137,7 @@ public:
* 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);
+ String getTranslation(const String &message, const String &context) const;
/**
* Returns a list of supported languages.
@@ -149,12 +149,12 @@ public:
/**
* Returns charset specified by selected translation language
*/
- const char *getCurrentCharset();
+ String getCurrentCharset() const;
/**
* Returns currently selected translation language
*/
- const char *getCurrentLanguage();
+ String getCurrentLanguage() const;
private:
#ifdef USE_TRANSLATION