From e62996858b2ce2be322eae55f86b4b0ad7172a08 Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Thu, 27 Dec 2012 17:10:45 +0100 Subject: Create a central version Make it 0.1.0~pre-alpha for now. - Add it to runtime program - Add it to -help option - Add it to manpage - Update translations --- src/app/app.cpp | 2 +- src/common/config.h.cmake | 4 ++++ src/common/restext.cpp | 4 +++- src/desktop/CMakeLists.txt | 1 + src/po/colobot.pot | 5 +---- src/po/de.po | 5 +---- src/po/fr.po | 11 ++++------- src/po/pl.po | 5 +---- 8 files changed, 16 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/app/app.cpp b/src/app/app.cpp index 27adcb1..000cfdf 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -246,7 +246,7 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[]) else if (arg == "-help") { GetLogger()->Message("\n"); - GetLogger()->Message("COLOBOT GOLD pre-alpha\n"); + GetLogger()->Message("Colobot %s (%s)\n",COLOBOT_CODENAME,COLOBOT_VERSION); GetLogger()->Message("\n"); GetLogger()->Message("List of available options:\n"); GetLogger()->Message(" -help this help\n"); diff --git a/src/common/config.h.cmake b/src/common/config.h.cmake index dd280a3..022bb69 100644 --- a/src/common/config.h.cmake +++ b/src/common/config.h.cmake @@ -8,6 +8,10 @@ #cmakedefine USE_GLEW @USE_GLEW@ #cmakedefine GLEW_STATIC +#define COLOBOT_VERSION "@COLOBOT_VERSION_FULL@" +#define COLOBOT_CODENAME "@COLOBOT_VERSION_CODENAME@" +#define COLOBOT_FULLNAME "Colobot @COLOBOT_VERSION_CODENAME@" + #define COLOBOT_DEFAULT_DATADIR "@COLOBOT_INSTALL_DATA_DIR@" #define COLOBOT_I18N_DIR "@COLOBOT_INSTALL_I18N_DIR@" diff --git a/src/common/restext.cpp b/src/common/restext.cpp index da06131..4c56ae5 100644 --- a/src/common/restext.cpp +++ b/src/common/restext.cpp @@ -17,6 +17,8 @@ #include "common/restext.h" +#include "common/config.h" + #include "common/global.h" #include "common/event.h" #include "common/logger.h" @@ -39,7 +41,7 @@ const char* stringsCbot[TX_MAX] = { nullptr }; void InitializeRestext() { - stringsText[RT_VERSION_ID] = "Colobot Gold"; + stringsText[RT_VERSION_ID] = COLOBOT_FULLNAME; stringsText[RT_DISINFO_TITLE] = "SatCom"; stringsText[RT_WINDOW_MAXIMIZED] = "Maximize"; diff --git a/src/desktop/CMakeLists.txt b/src/desktop/CMakeLists.txt index 1a1cfd5..ce4f48d 100644 --- a/src/desktop/CMakeLists.txt +++ b/src/desktop/CMakeLists.txt @@ -53,6 +53,7 @@ if(POD2MAN) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${PM_PODFILE} COMMAND ${POD2MAN} ARGS --section=${COLOBOT_MANPAGE_SECTION} --center="Colobot" --stderr --utf8 + --release="${COLOBOT_VERSION_FULL}" ${CMAKE_CURRENT_SOURCE_DIR}/${PM_PODFILE} ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION} COMMENT "Create ${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION} manpage" diff --git a/src/po/colobot.pot b/src/po/colobot.pot index a45303e..e1f9dc7 100644 --- a/src/po/colobot.pot +++ b/src/po/colobot.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-12-27 13:53+0100\n" +"POT-Creation-Date: 2012-12-27 17:09+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -20,9 +20,6 @@ msgstr "" msgid "Colobot rules!" msgstr "" -msgid "Colobot Gold" -msgstr "" - msgid "SatCom" msgstr "" diff --git a/src/po/de.po b/src/po/de.po index 6edcedd..2992cb1 100644 --- a/src/po/de.po +++ b/src/po/de.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-12-27 13:53+0100\n" +"POT-Creation-Date: 2012-12-27 17:09+0100\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -378,9 +378,6 @@ msgstr "Schließen" msgid "Closing bracket missing " msgstr "Es fehlt eine geschlossene Klammer \")\"" -msgid "Colobot Gold" -msgstr "Colobot Gold" - msgid "Colobot rules!" msgstr "Colobot ist wunderbar!" diff --git a/src/po/fr.po b/src/po/fr.po index 973dc19..662fb93 100644 --- a/src/po/fr.po +++ b/src/po/fr.po @@ -2,16 +2,16 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-12-27 13:53+0100\n" +"POT-Creation-Date: 2012-12-27 17:09+0100\n" +"PO-Revision-Date: 2012-12-27 14:07+0100\n" +"Last-Translator: Didier Raboud \n" +"Language: fr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" "X-Language: fr_FR\n" "X-Source-Language: en_US\n" -"Last-Translator: Didier Raboud \n" -"PO-Revision-Date: 2012-12-27 14:07+0100\n" -"Language: fr\n" "X-Generator: Lokalize 1.4\n" msgid " " @@ -378,9 +378,6 @@ msgstr "Fermer" msgid "Closing bracket missing " msgstr "Il manque une parenthèse fermante" -msgid "Colobot Gold" -msgstr "Colobot Gold" - msgid "Colobot rules!" msgstr "Colobot est super!" diff --git a/src/po/pl.po b/src/po/pl.po index 27b05c4..9bab529 100644 --- a/src/po/pl.po +++ b/src/po/pl.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-12-27 13:53+0100\n" +"POT-Creation-Date: 2012-12-27 17:09+0100\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -380,9 +380,6 @@ msgstr "Zamknij" msgid "Closing bracket missing " msgstr "Brak nawiasu zamykającego" -msgid "Colobot Gold" -msgstr "Colobot Gold" - msgid "Colobot rules!" msgstr "Colobot rządzi!" -- cgit v1.2.3-1-g7c22 From f4c6f49b2fd01de2d6daff5ec1b9c181c39d09b7 Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Fri, 28 Dec 2012 22:31:47 +0100 Subject: Move language initialisation in SetLanguage --- src/app/app.cpp | 90 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 48 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/app/app.cpp b/src/app/app.cpp index 4d32de3..32f68e1 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -285,48 +285,7 @@ bool CApplication::Create() return false; } - /* Gettext initialization */ - - std::string locale = ""; - switch (m_language) - { - default: - case LANGUAGE_ENV: - locale = ""; - break; - - case LANGUAGE_ENGLISH: - locale = "en_US.utf8"; - break; - - case LANGUAGE_GERMAN: - locale = "de_DE.utf8"; - break; - - case LANGUAGE_FRENCH: - locale = "fr_FR.utf8"; - break; - - case LANGUAGE_POLISH: - locale = "pl_PL.utf8"; - break; - } - - if (!locale.empty()) - { - std::string langStr = "LANG="; - langStr += locale; - strcpy(S_LANGUAGE, langStr.c_str()); - putenv(S_LANGUAGE); - } - setlocale(LC_ALL, ""); - GetLogger()->Debug("Set locale to '%s'\n", locale.c_str()); - - bindtextdomain("colobot", COLOBOT_I18N_DIR); - bind_textdomain_codeset("colobot", "UTF-8"); - textdomain("colobot"); - - GetLogger()->Debug("Testing gettext translation: '%s'\n", gettext("Colobot rules!")); + SetLanguage(m_language); //Create the sound instance. if (!GetProfile().InitCurrentDirectory()) @@ -1456,6 +1415,53 @@ Language CApplication::GetLanguage() void CApplication::SetLanguage(Language language) { m_language = language; + + /* Gettext initialization */ + + std::string locale = ""; + switch (m_language) + { + default: + case LANGUAGE_ENV: + locale = ""; + break; + + case LANGUAGE_ENGLISH: + locale = "en_US.utf8"; + break; + + case LANGUAGE_GERMAN: + locale = "de_DE.utf8"; + break; + + case LANGUAGE_FRENCH: + locale = "fr_FR.utf8"; + break; + + case LANGUAGE_POLISH: + locale = "pl_PL.utf8"; + break; + } + + if (locale.empty()) + { + GetLogger()->Trace("SetLanguage: Inherit LANGUAGE=%s from environment\n", getenv("LANGUAGE")); + } + else + { + std::string langStr = "LANGUAGE="; + langStr += locale; + strcpy(S_LANGUAGE, langStr.c_str()); + putenv(S_LANGUAGE); + GetLogger()->Trace("SetLanguage: Set LANGUAGE=%s in environment\n", locale.c_str()); + } + setlocale(LC_ALL, ""); + + bindtextdomain("colobot", COLOBOT_I18N_DIR); + bind_textdomain_codeset("colobot", "UTF-8"); + textdomain("colobot"); + + GetLogger()->Debug("SetLanguage: Test gettext translation: '%s'\n", gettext("Colobot rules!")); } void CApplication::SetLowCPU(bool low) -- cgit v1.2.3-1-g7c22 From 1b4208cdc5143cfc8f46da063a1a991795d7f307 Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Fri, 28 Dec 2012 23:06:12 +0100 Subject: Implement language Char for level files This currently lacks fallback to an existing entry for non-translated entries --- src/app/app.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++++- src/app/app.h | 1 + src/object/robotmain.cpp | 8 ++++---- src/ui/maindialog.cpp | 20 ++++++++++---------- 4 files changed, 59 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/app/app.cpp b/src/app/app.cpp index 32f68e1..1e577ca 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -1412,6 +1412,32 @@ Language CApplication::GetLanguage() return m_language; } +char CApplication::GetLanguageChar() +{ + char langChar = 'E'; + switch (m_language) + { + default: + case LANGUAGE_ENV: + case LANGUAGE_ENGLISH: + langChar = 'E'; + break; + + case LANGUAGE_GERMAN: + langChar = 'D'; + break; + + case LANGUAGE_FRENCH: + langChar = 'F'; + break; + + case LANGUAGE_POLISH: + langChar = 'P'; + break; + } + return langChar; +} + void CApplication::SetLanguage(Language language) { m_language = language; @@ -1445,7 +1471,24 @@ void CApplication::SetLanguage(Language language) if (locale.empty()) { - GetLogger()->Trace("SetLanguage: Inherit LANGUAGE=%s from environment\n", getenv("LANGUAGE")); + char *envLang = getenv("LANGUAGE"); + if (strncmp(envLang,"en",2) == 0) + { + m_language = LANGUAGE_ENGLISH; + } + else if (strncmp(envLang,"de",2) == 0) + { + m_language = LANGUAGE_GERMAN; + } + else if (strncmp(envLang,"fr",2) == 0) + { + m_language = LANGUAGE_FRENCH; + } + else if (strncmp(envLang,"po",2) == 0) + { + m_language = LANGUAGE_POLISH; + } + GetLogger()->Trace("SetLanguage: Inherit LANGUAGE=%s from environment\n", envLang); } else { diff --git a/src/app/app.h b/src/app/app.h index 20d07df..2da20d3 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -294,6 +294,7 @@ public: //! Management of language //@{ Language GetLanguage(); + char GetLanguageChar(); void SetLanguage(Language language); //@} diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index d5805d0..aa2fe22 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -3808,16 +3808,16 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) } } - // TODO: language letters - sprintf(op, "Title.%c", 'E' /*GetLanguageLetter()*/); + // TODO: Fallback to an non-localized entry + sprintf(op, "Title.%c", m_app->GetLanguageChar()); if (Cmd(line, op) && !resetObject) OpString(line, "text", m_title); - sprintf(op, "Resume.%c", 'E' /*GetLanguageLetter()*/); + sprintf(op, "Resume.%c", m_app->GetLanguageChar()); if (Cmd(line, op) && !resetObject) OpString(line, "text", m_resume); - sprintf(op, "ScriptName.%c", 'E' /*GetLanguageLetter()*/); + sprintf(op, "ScriptName.%c", m_app->GetLanguageChar()); if (Cmd(line, op) && !resetObject) OpString(line, "text", m_scriptName); diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index ebf7d10..68e7854 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -4305,8 +4305,8 @@ void CMainDialog::IOReadName() } } - // TODO: language letters - sprintf(op, "Title.%c", 'E' /*MAX_FNAME()*/ ); + // TODO: Fallback to an non-localized entry + sprintf(op, "Title.%c", m_app->GetLanguageChar() ); if ( Cmd(line, op) ) { OpString(line, "resume", resume); @@ -4701,8 +4701,8 @@ void CMainDialog::UpdateSceneChap(int &chap) } } - /* TODO: language letters */ - sprintf(op, "Title.%c", 'E' /*GetLanguageLetter()*/); + // TODO: Fallback to an non-localized entry + sprintf(op, "Title.%c", m_app->GetLanguageChar()); if ( Cmd(line, op) ) { OpString(line, "text", name); @@ -4748,8 +4748,8 @@ void CMainDialog::UpdateSceneChap(int &chap) } } - // TODO: language letters - sprintf(op, "Title.%c", 'E'/*GetLanguageLetter()*/); + // TODO: Fallback to an non-localized entry + sprintf(op, "Title.%c", m_app->GetLanguageChar()); if ( Cmd(line, op) ) { OpString(line, "text", name); @@ -4851,8 +4851,8 @@ void CMainDialog::UpdateSceneList(int chap, int &sel) } } - // TODO: language letters - sprintf(op, "Title.%c", 'E' /*MAX_FNAME()*/); + // TODO: Fallback to an non-localized entry + sprintf(op, "Title.%c", m_app->GetLanguageChar()); if ( Cmd(line, op) ) { OpString(line, "text", name); @@ -4996,8 +4996,8 @@ void CMainDialog::UpdateSceneResume(int rank) } } - // TODO: language letters - sprintf(op, "Resume.%c", 'E' /*MAX_FNAME()*/); + // TODO: Fallback to an non-localized entry + sprintf(op, "Resume.%c", m_app->GetLanguageChar()); if ( Cmd(line, op) ) { OpString(line, "text", name); -- cgit v1.2.3-1-g7c22