diff --git a/CMakeLists.txt b/CMakeLists.txt index d9e009a27..60ec14bbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,6 @@ if(NOT CMAKE_BUILD_TYPE) endif() option(SERVER_ONLY "Create a server only (i.e. no graphics or sound)" OFF) -option(USE_FRIBIDI "Support for right-to-left languages" ON) option(CHECK_ASSETS "Check if assets are installed in ../stk-assets" ON) option(USE_SYSTEM_ANGELSCRIPT "Use system angelscript instead of built-in angelscript. If you enable this option, make sure to use a compatible version." OFF) option(USE_SYSTEM_ENET "Use system ENET instead of the built-in version, when available." ON) @@ -27,6 +26,8 @@ option(USE_SYSTEM_GLEW "Use system GLEW instead of the built-in version, when av CMAKE_DEPENDENT_OPTION(BUILD_RECORDER "Build opengl recorder" ON "NOT SERVER_ONLY;NOT APPLE" OFF) +CMAKE_DEPENDENT_OPTION(USE_FRIBIDI "Support for right-to-left languages" ON + "NOT SERVER_ONLY" OFF) if(APPLE) list(APPEND CMAKE_PREFIX_PATH /usr/local/opt) diff --git a/src/font/font_manager.cpp b/src/font/font_manager.cpp index 52a893de3..7a20f6063 100644 --- a/src/font/font_manager.cpp +++ b/src/font/font_manager.cpp @@ -87,6 +87,7 @@ void FontManager::loadFonts() */ void FontManager::unitTesting() { +#ifndef SERVER_ONLY std::vector list = *(translations->getLanguageList()); const int cur_log_level = Log::getLogLevel(); for (const std::string& lang : list) @@ -134,5 +135,5 @@ void FontManager::unitTesting() } } } - +#endif } // unitTesting diff --git a/src/states_screens/credits.cpp b/src/states_screens/credits.cpp index 7c6bce747..016af23fe 100644 --- a/src/states_screens/credits.cpp +++ b/src/states_screens/credits.cpp @@ -192,7 +192,9 @@ void CreditsScreen::loadedFromFile() m_sections.push_back( new CreditsSection("Translations")); for (unsigned int i = 1; i < translator.size(); i = i + MAX_PER_SCREEN) { +#ifndef SERVER_ONLY line = stringw(translations->getCurrentLanguageName().c_str()); +#endif CreditsEntry entry(line); getCurrentSection()->addEntry( entry ); diff --git a/src/states_screens/options_screen_language.cpp b/src/states_screens/options_screen_language.cpp index 60fb11b77..b7abe776f 100644 --- a/src/states_screens/options_screen_language.cpp +++ b/src/states_screens/options_screen_language.cpp @@ -85,7 +85,7 @@ void OptionsScreenLanguage::init() // I18N: in the language choice, to select the same language as the OS list_widget->addItem("system", _("System Language")); - +#ifndef SERVER_ONLY const std::vector* lang_list = translations->getLanguageList(); const int amount = (int)lang_list->size(); @@ -109,7 +109,7 @@ void OptionsScreenLanguage::init() list_widget->addItem(nice_name_2_id[nice_lang_list[i]], nice_lang_list[i]); } - +#endif list_widget->setSelectionID( list_widget->getItemID(UserConfigParams::m_language) ); // Forbid changing language while in-game, since this crashes (changing the language involves diff --git a/src/tinygettext/dictionary.cpp b/src/tinygettext/dictionary.cpp index ffd6f3868..fbbd67504 100644 --- a/src/tinygettext/dictionary.cpp +++ b/src/tinygettext/dictionary.cpp @@ -15,6 +15,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#ifndef SERVER_ONLY + #include #include "dictionary.hpp" @@ -246,3 +248,4 @@ std::set Dictionary::get_all_used_chars() } // namespace tinygettext /* EOF */ +#endif diff --git a/src/tinygettext/dictionary.hpp b/src/tinygettext/dictionary.hpp index 0076647ac..0357036fe 100644 --- a/src/tinygettext/dictionary.hpp +++ b/src/tinygettext/dictionary.hpp @@ -18,6 +18,8 @@ #ifndef HEADER_TINYGETTEXT_DICTIONARY_HPP #define HEADER_TINYGETTEXT_DICTIONARY_HPP +#ifndef SERVER_ONLY + #include #include #include @@ -135,3 +137,4 @@ public: #endif /* EOF */ +#endif diff --git a/src/tinygettext/dictionary_manager.cpp b/src/tinygettext/dictionary_manager.cpp index 69945d80c..4817a0c2a 100644 --- a/src/tinygettext/dictionary_manager.cpp +++ b/src/tinygettext/dictionary_manager.cpp @@ -15,6 +15,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#ifndef SERVER_ONLY + #include "dictionary_manager.hpp" #include "utils/log.hpp" @@ -297,3 +299,4 @@ std::string DictionaryManager::convertFilename2Language(const std::string &s_in) /* EOF */ +#endif diff --git a/src/tinygettext/dictionary_manager.hpp b/src/tinygettext/dictionary_manager.hpp index 2005e105b..c90511324 100644 --- a/src/tinygettext/dictionary_manager.hpp +++ b/src/tinygettext/dictionary_manager.hpp @@ -18,6 +18,8 @@ #ifndef HEADER_TINYGETTEXT_DICTIONARY_MANAGER_HPP #define HEADER_TINYGETTEXT_DICTIONARY_MANAGER_HPP +#ifndef SERVER_ONLY + #include #include #include @@ -103,3 +105,4 @@ private: #endif /* EOF */ +#endif diff --git a/src/tinygettext/file_system.hpp b/src/tinygettext/file_system.hpp index f68b35d46..f72f44c85 100644 --- a/src/tinygettext/file_system.hpp +++ b/src/tinygettext/file_system.hpp @@ -18,6 +18,8 @@ #ifndef HEADER_TINYGETTEXT_FILE_SYSTEM_HPP #define HEADER_TINYGETTEXT_FILE_SYSTEM_HPP +#ifndef SERVER_ONLY + #include #include #include @@ -39,4 +41,4 @@ public: #endif /* EOF */ - +#endif diff --git a/src/tinygettext/language.cpp b/src/tinygettext/language.cpp index f64e31038..ada62540b 100644 --- a/src/tinygettext/language.cpp +++ b/src/tinygettext/language.cpp @@ -15,6 +15,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#ifndef SERVER_ONLY + #include "language.hpp" #include "utils/string_utils.hpp" @@ -579,3 +581,5 @@ Language::operator!=(const Language& rhs) } // namespace tinygettext /* EOF */ + +#endif diff --git a/src/tinygettext/language.hpp b/src/tinygettext/language.hpp index 46f47d299..431005411 100644 --- a/src/tinygettext/language.hpp +++ b/src/tinygettext/language.hpp @@ -18,6 +18,8 @@ #ifndef HEADER_TINYGETTEXT_LANGUAGE_HPP #define HEADER_TINYGETTEXT_LANGUAGE_HPP +#ifndef SERVER_ONLY + #include namespace tinygettext { @@ -89,3 +91,5 @@ inline bool operator<(const Language& lhs, const Language& rhs) { #endif /* EOF */ + +#endif diff --git a/src/tinygettext/plural_forms.cpp b/src/tinygettext/plural_forms.cpp index 23215ed55..173d53193 100644 --- a/src/tinygettext/plural_forms.cpp +++ b/src/tinygettext/plural_forms.cpp @@ -15,6 +15,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#ifndef SERVER_ONLY + #include "plural_forms.hpp" #include @@ -114,3 +116,4 @@ PluralForms::from_string(const std::string& str) } // namespace tinygettext /* EOF */ +#endif diff --git a/src/tinygettext/plural_forms.hpp b/src/tinygettext/plural_forms.hpp index ce8fc3eb1..6fc2a7a02 100644 --- a/src/tinygettext/plural_forms.hpp +++ b/src/tinygettext/plural_forms.hpp @@ -18,6 +18,8 @@ #ifndef HEADER_TINYGETTEXT_PLURAL_FORMS_HPP #define HEADER_TINYGETTEXT_PLURAL_FORMS_HPP +#ifndef SERVER_ONLY + #include namespace tinygettext { @@ -59,3 +61,4 @@ public: #endif /* EOF */ +#endif diff --git a/src/tinygettext/po_parser.cpp b/src/tinygettext/po_parser.cpp index 0831c2417..51f9b94c0 100644 --- a/src/tinygettext/po_parser.cpp +++ b/src/tinygettext/po_parser.cpp @@ -15,6 +15,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#ifndef SERVER_ONLY + #include "po_parser.hpp" #include @@ -496,3 +498,4 @@ POParser::parse() } // namespace tinygettext /* EOF */ +#endif diff --git a/src/tinygettext/po_parser.hpp b/src/tinygettext/po_parser.hpp index 42fe8e825..5c5c94571 100644 --- a/src/tinygettext/po_parser.hpp +++ b/src/tinygettext/po_parser.hpp @@ -18,6 +18,8 @@ #ifndef HEADER_TINYGETTEXT_PO_PARSER_HPP #define HEADER_TINYGETTEXT_PO_PARSER_HPP +#ifndef SERVER_ONLY + #include #include @@ -76,3 +78,4 @@ private: #endif /* EOF */ +#endif diff --git a/src/tinygettext/stk_file_system.cpp b/src/tinygettext/stk_file_system.cpp index cd38a7585..d85a7b022 100644 --- a/src/tinygettext/stk_file_system.cpp +++ b/src/tinygettext/stk_file_system.cpp @@ -15,6 +15,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#ifndef SERVER_ONLY + #include "stk_file_system.hpp" #include @@ -53,3 +55,5 @@ StkFileSystem::open_file(const std::string& filename) } // namespace tinygettext /* EOF */ + +#endif diff --git a/src/tinygettext/stk_file_system.hpp b/src/tinygettext/stk_file_system.hpp index 6072f5e8c..28526d7b8 100644 --- a/src/tinygettext/stk_file_system.hpp +++ b/src/tinygettext/stk_file_system.hpp @@ -18,6 +18,8 @@ #ifndef HEADER_TINYGETTEXT_STK_FILE_SYSTEM_HPP #define HEADER_TINYGETTEXT_STK_FILE_SYSTEM_HPP +#ifndef SERVER_ONLY + #include "file_system.hpp" namespace tinygettext { @@ -36,3 +38,5 @@ public: #endif /* EOF */ + +#endif diff --git a/src/utils/translation.cpp b/src/utils/translation.cpp index 4d7b97d7f..c52de41e0 100644 --- a/src/utils/translation.cpp +++ b/src/utils/translation.cpp @@ -55,15 +55,15 @@ // Define TEST_BIDI to force right-to-left style for all languages //#define TEST_BIDI -using namespace tinygettext; - Translations* translations = NULL; -const bool REMOVE_BOM = false; #ifdef LINUX // m_debug #define PACKAGE "supertuxkart" #endif +#ifndef SERVER_ONLY +const bool REMOVE_BOM = false; +using namespace tinygettext; /** The list of available languages; this is global so that it is cached (and remains even if the translations object is deleted and re-created) */ typedef std::vector LanguageList; @@ -75,6 +75,7 @@ const LanguageList* Translations::getLanguageList() const { return &g_language_list; } +#endif // ---------------------------------------------------------------------------- /** Frees the memory allocated for the result of toFribidiChar(). */ @@ -178,6 +179,7 @@ wchar_t* fromFribidiChar(const FriBidiChar* str) // ---------------------------------------------------------------------------- Translations::Translations() //: m_dictionary_manager("UTF-16") { +#ifndef SERVER_ONLY m_dictionary_manager.add_directory( file_manager->getAsset(FileManager::TRANSLATION,"")); @@ -416,6 +418,8 @@ Translations::Translations() //: m_dictionary_manager("UTF-16") #ifdef TEST_BIDI m_rtl = true; #endif + +#endif } // Translations // ---------------------------------------------------------------------------- @@ -428,6 +432,9 @@ Translations::~Translations() const wchar_t* Translations::fribidize(const wchar_t* in_ptr) { +#ifdef SERVER_ONLY + return in_ptr; +#else if (isRTLText(in_ptr)) { // Test if this string was already fribidized @@ -467,6 +474,7 @@ const wchar_t* Translations::fribidize(const wchar_t* in_ptr) } else return in_ptr; +#endif } bool Translations::isRTLText(const wchar_t *in_ptr) @@ -513,6 +521,13 @@ const wchar_t* Translations::w_gettext(const wchar_t* original, const char* cont */ const wchar_t* Translations::w_gettext(const char* original, const char* context) { + +#ifdef SERVER_ONLY + static irr::core::stringw dummy_for_server; + dummy_for_server = StringUtils::utf8ToWide(original); + return dummy_for_server.c_str(); +#else + if (original[0] == '\0') return L""; #if TRANSLATE_VERBOSE @@ -548,6 +563,7 @@ const wchar_t* Translations::w_gettext(const char* original, const char* context #endif return out_ptr; +#endif } /** @@ -573,11 +589,18 @@ const wchar_t* Translations::w_ngettext(const wchar_t* singular, const wchar_t* */ const wchar_t* Translations::w_ngettext(const char* singular, const char* plural, int num, const char* context) { + static core::stringw str_buffer; + +#ifdef SERVER_ONLY + str_buffer = StringUtils::utf8ToWide(singular); + return str_buffer.c_str(); + +#else + const std::string& res = (context == NULL ? m_dictionary.translate_plural(singular, plural, num) : m_dictionary.translate_ctxt_plural(context, singular, plural, num)); - static core::stringw str_buffer; str_buffer = StringUtils::utf8ToWide(res); const wchar_t* out_ptr = str_buffer.c_str(); if (REMOVE_BOM) out_ptr++; @@ -587,28 +610,8 @@ const wchar_t* Translations::w_ngettext(const char* singular, const char* plural #endif return out_ptr; -} +#endif - -bool Translations::isRTLLanguage() const -{ - return m_rtl; -} - -std::set Translations::getCurrentAllChar() -{ - return m_dictionary.get_all_used_chars(); -} - -std::string Translations::getCurrentLanguageName() -{ - return m_current_language_name; - //return m_dictionary_manager.get_language().get_name(); -} - -std::string Translations::getCurrentLanguageNameCode() -{ - return m_current_language_name_code; } core::stringw Translations::fribidizeLine(const core::stringw &str) @@ -662,9 +665,28 @@ core::stringw Translations::fribidizeLine(const core::stringw &str) } +#ifndef SERVER_ONLY +std::set Translations::getCurrentAllChar() +{ + return m_dictionary.get_all_used_chars(); +} + +std::string Translations::getCurrentLanguageName() +{ + return m_current_language_name; + //return m_dictionary_manager.get_language().get_name(); +} + +std::string Translations::getCurrentLanguageNameCode() +{ + return m_current_language_name_code; +} + const std::string& Translations::getLocalizedName(const std::string& str) const { std::map::const_iterator n = m_localized_name.find(str); assert (n != m_localized_name.end()); return n->second; } + +#endif diff --git a/src/utils/translation.hpp b/src/utils/translation.hpp index 7205433a9..ebd9f34f8 100644 --- a/src/utils/translation.hpp +++ b/src/utils/translation.hpp @@ -21,13 +21,15 @@ #include #include +#include #include #include #include #include "utils/string_utils.hpp" - +#ifndef SERVER_ONLY #include "tinygettext/tinygettext.hpp" +#endif # define _(String, ...) (translations->fribidize(StringUtils::insertValues(translations->w_gettext(String), ##__VA_ARGS__))) #undef _C @@ -46,6 +48,7 @@ class Translations { private: +#ifndef SERVER_ONLY tinygettext::DictionaryManager m_dictionary_manager; tinygettext::Dictionary m_dictionary; @@ -57,6 +60,7 @@ private: std::string m_current_language_name; std::string m_current_language_name_code; +#endif public: Translations(); @@ -67,14 +71,22 @@ public: const wchar_t *w_ngettext(const wchar_t* singular, const wchar_t* plural, int num, const char* context=NULL); const wchar_t *w_ngettext(const char* singular, const char* plural, int num, const char* context=NULL); + bool isRTLLanguage() const + { +#ifdef SERVER_ONLY + return false; +#else + return m_rtl; +#endif + } - bool isRTLLanguage() const; const wchar_t* fribidize(const wchar_t* in_ptr); const wchar_t* fribidize(const irr::core::stringw &str) { return fribidize(str.c_str()); } bool isRTLText(const wchar_t* in_ptr); bool isRTLText(const irr::core::stringw &str) { return isRTLText(str.c_str()); } +#ifndef SERVER_ONLY const std::vector* getLanguageList() const; std::set getCurrentAllChar(); @@ -84,6 +96,7 @@ public: std::string getCurrentLanguageNameCode(); const std::string& getLocalizedName(const std::string& str) const; +#endif private: irr::core::stringw fribidizeLine(const irr::core::stringw &str);