diff options
author | Nils Dagsson Moskopp <nils@dieweltistgarnichtso.net> | 2011-07-20 17:56:49 +0200 |
---|---|---|
committer | Nils Dagsson Moskopp <nils@dieweltistgarnichtso.net> | 2011-07-20 17:56:49 +0200 |
commit | e5dc58e7103d46298bbca66b0a6a7d9d61146e7e (patch) | |
tree | 37a072a5dc51a2f6e77cc8ff434e73565f45170c /src | |
parent | 3c630c0d90a8d997475c07bc52781126e5f531e6 (diff) | |
parent | cef7bb06195f3923f5c47547b48fe6e6e51c932d (diff) | |
download | minetest-e5dc58e7103d46298bbca66b0a6a7d9d61146e7e.tar.gz minetest-e5dc58e7103d46298bbca66b0a6a7d9d61146e7e.tar.bz2 minetest-e5dc58e7103d46298bbca66b0a6a7d9d61146e7e.zip |
Merge branch 'master' of github.com:erlehmann/minetest-delta
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 41 | ||||
-rw-r--r-- | src/gettext.h | 12 | ||||
-rw-r--r-- | src/guiMainMenu.cpp | 26 | ||||
-rw-r--r-- | src/guiMessageMenu.cpp | 4 | ||||
-rw-r--r-- | src/guiPasswordChange.cpp | 16 | ||||
-rw-r--r-- | src/guiPauseMenu.cpp | 36 | ||||
-rw-r--r-- | src/guiTextInputMenu.cpp | 4 | ||||
-rw-r--r-- | src/main.cpp | 5 |
8 files changed, 102 insertions, 42 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dfe5b5753..fd1591423 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,6 +27,14 @@ if(WIN32) CACHE FILEPATH "Path to zlibwapi.lib") set(ZLIB_DLL "${PROJECT_SOURCE_DIR}/../../zlib125dll/dll32/zlibwapi.dll" CACHE FILEPATH "Path to zlibwapi.dll (for installation)") + set(GETTEXT_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../../gettext/include" + CACHE PATH "gettext include directory") + set(GETTEXT_BIN_DIR "${PROJECT_SOURCE_DIR}/../../gettext/bin" + CACHE PATH "gettext bin directory") + set(GETTEXT_LIBRARIES "${PROJECT_SOURCE_DIR}/../../gettext/lib/intl.lib" + CACHE FILEPATH "gettext intl.lib") + set(IRRLICHT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../../irrlicht-1.7.2" + CACHE PATH "irrlicht dir") else() # Unix probably if(BUILD_CLIENT) @@ -134,6 +142,7 @@ include_directories( ${ZLIB_INCLUDE_DIR} ${CMAKE_BUILD_TYPE} ${PNG_INCLUDE_DIR} + ${GETTEXT_INCLUDE_DIR} "${PROJECT_SOURCE_DIR}/jthread" "${PROJECT_SOURCE_DIR}/sqlite" ) @@ -151,6 +160,7 @@ if(BUILD_CLIENT) ${BZIP2_LIBRARIES} ${PNG_LIBRARIES} ${X11_LIBRARIES} + ${GETTEXT_LIBRARIES} ${PLATFORM_LIBS} ${CLIENT_PLATFORM_LIBS} jthread @@ -208,6 +218,10 @@ else() set(ARCH i386) endif() + if(WIN32) + set(CMAKE_EXE_LINKER_FLAGS "-lintl -L ${GETTEXT_BIN_DIR}") + endif() + set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops") set(CMAKE_CXX_FLAGS_DEBUG "-g -O1 -Wall ${WARNING_FLAGS}") @@ -239,6 +253,8 @@ if(BUILD_CLIENT) install(FILES ${images} DESTINATION ${DATADIR}) + install(FILES ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-c55.mo DESTINATION locale/de/LC_MESSAGES) + if(WIN32) if(DEFINED IRRLICHT_DLL) install(FILES ${IRRLICHT_DLL} DESTINATION ${BINDIR}) @@ -246,6 +262,10 @@ if(BUILD_CLIENT) if(DEFINED ZLIB_DLL) install(FILES ${ZLIB_DLL} DESTINATION ${BINDIR}) endif() + if(DEFINED GETTEXT_BIN_DIR) + install(FILES ${GETTEXT_BIN_DIR}/libintl3.dll DESTINATION ${BINDIR}) + install(FILES ${GETTEXT_BIN_DIR}/libiconv2.dll DESTINATION ${BINDIR}) + endif() endif() endif(BUILD_CLIENT) @@ -253,6 +273,27 @@ if(BUILD_SERVER) install(TARGETS minetestserver DESTINATION ${BINDIR}) endif(BUILD_SERVER) +if(WIN32) + set(GETTEXT_MSGFMT "${GETTEXT_BIN_DIR}/msgfmt" CACHE FILEPATH "path to msgfmt") +elseif(APPLE) + set(GETTEXT_MSGFMT "${GETTEXT_BIN_DIR}/msgfmt" CACHE FILEPATH "path to msgfmt") +else() + set(GETTEXT_MSGFMT "msgfmt") +endif() + +add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES COMMENT "mo-update [de]: Creating locale directory.") + +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-c55.mo + COMMAND ${GETTEXT_MSGFMT} -o ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-c55.mo ${CMAKE_SOURCE_DIR}/po/de/minetest-c55.po + DEPENDS + ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES + ${CMAKE_SOURCE_DIR}/po/de/minetest-c55.po + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/po/de + COMMENT "mo-update [de]: Creating mo file." + ) +add_custom_target(translation_de ALL COMMENT "mo update [de]" DEPENDS ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-c55.mo) + # Subdirectories add_subdirectory(jthread) diff --git a/src/gettext.h b/src/gettext.h new file mode 100644 index 000000000..7f5f56e49 --- /dev/null +++ b/src/gettext.h @@ -0,0 +1,12 @@ +#include <libintl.h> +#define _(String) gettext(String) +#define gettext_noop(String) String +#define N_(String) gettext_noop (String) + +inline wchar_t* chartowchar_t(char *str) +{ + size_t l = strlen(str)+1; + wchar_t* nstr = new wchar_t[l]; + mbstowcs(nstr, str, l); + return nstr; +} diff --git a/src/guiMainMenu.cpp b/src/guiMainMenu.cpp index cea32860b..f557f4dc0 100644 --- a/src/guiMainMenu.cpp +++ b/src/guiMainMenu.cpp @@ -25,6 +25,8 @@ with this program; if not, write to the Free Software Foundation, Inc., +#include "gettext.h" + GUIMainMenu::GUIMainMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, s32 id, IMenuManager *menumgr, @@ -175,8 +177,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) { core::rect<s32> rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, 50+6); - const wchar_t *text = L"Name/Password"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(chartowchar_t(gettext("Name/Password")), rect, false, true, this, -1); } { core::rect<s32> rect(0, 0, 230, 30); @@ -198,8 +199,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) { core::rect<s32> rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, 100+6); - const wchar_t *text = L"Address/Port"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(chartowchar_t(gettext("Address/Port")), rect, false, true, this, -1); } { core::rect<s32> rect(0, 0, 230, 30); @@ -217,28 +217,26 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) } { core::rect<s32> rect(0, 0, 400, 20); - rect += topleft_client + v2s32(160, 100+35); - const wchar_t *text = L"Leave address blank to start a local server."; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(chartowchar_t(gettext("Leave address blank to start a local server.")), rect, false, true, this, -1); } { core::rect<s32> rect(0, 0, 250, 30); rect += topleft_client + v2s32(35, 150); Environment->addCheckBox(fancy_trees, rect, this, GUI_ID_FANCYTREE_CB, - L"Fancy trees"); + chartowchar_t(gettext("Fancy trees"))); } { core::rect<s32> rect(0, 0, 250, 30); rect += topleft_client + v2s32(35, 150+30); Environment->addCheckBox(smooth_lighting, rect, this, GUI_ID_SMOOTH_LIGHTING_CB, - L"Smooth Lighting"); + chartowchar_t(gettext("Smooth Lighting"))); } // Start game button { core::rect<s32> rect(0, 0, 180, 30); //rect += topleft_client + v2s32(size_client.X/2-180/2, 225-30/2); rect += topleft_client + v2s32(size_client.X-180-40, 150+25); - Environment->addButton(rect, this, GUI_ID_JOIN_GAME_BUTTON, L"Start Game / Connect"); + Environment->addButton(rect, this, GUI_ID_JOIN_GAME_BUTTON, chartowchar_t(gettext("Start Game / Connect"))); } // Key change button @@ -246,7 +244,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) core::rect<s32> rect(0, 0, 100, 30); //rect += topleft_client + v2s32(size_client.X/2-180/2, 225-30/2); rect += topleft_client + v2s32(size_client.X-180-40-100-20, 150+25); - Environment->addButton(rect, this, GUI_ID_CHANGE_KEYS_BUTTON, L"Change keys"); + Environment->addButton(rect, this, GUI_ID_CHANGE_KEYS_BUTTON, chartowchar_t(gettext("Change keys"))); } /* Server section @@ -268,19 +266,19 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) { core::rect<s32> rect(0, 0, 250, 30); rect += topleft_server + v2s32(35, 30); - Environment->addCheckBox(creative_mode, rect, this, GUI_ID_CREATIVE_CB, L"Creative Mode"); + Environment->addCheckBox(creative_mode, rect, this, GUI_ID_CREATIVE_CB, chartowchar_t(gettext("Creative Mode"))); } { core::rect<s32> rect(0, 0, 250, 30); rect += topleft_server + v2s32(35, 60); - Environment->addCheckBox(enable_damage, rect, this, GUI_ID_DAMAGE_CB, L"Enable Damage"); + Environment->addCheckBox(enable_damage, rect, this, GUI_ID_DAMAGE_CB, chartowchar_t(gettext("Enable Damage"))); } // Map delete button { core::rect<s32> rect(0, 0, 130, 30); //rect += topleft_server + v2s32(size_server.X-40-130, 100+25); rect += topleft_server + v2s32(40, 100+25); - Environment->addButton(rect, this, GUI_ID_DELETE_MAP_BUTTON, L"Delete map"); + Environment->addButton(rect, this, GUI_ID_DELETE_MAP_BUTTON, chartowchar_t(gettext("Delete map"))); } } diff --git a/src/guiMessageMenu.cpp b/src/guiMessageMenu.cpp index 192911355..e4e582ab1 100644 --- a/src/guiMessageMenu.cpp +++ b/src/guiMessageMenu.cpp @@ -22,6 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "serialization.h" #include <string> +#include "gettext.h" + GUIMessageMenu::GUIMessageMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, s32 id, IMenuManager *menumgr, @@ -87,7 +89,7 @@ void GUIMessageMenu::regenerateGui(v2u32 screensize) core::rect<s32> rect(0, 0, 140, 30); rect = rect + v2s32(size.X/2-140/2, size.Y/2-30/2+25); gui::IGUIElement *e = - Environment->addButton(rect, this, 257, L"Proceed"); + Environment->addButton(rect, this, 257, chartowchar_t(gettext("Proceed"))); Environment->setFocus(e); } } diff --git a/src/guiPasswordChange.cpp b/src/guiPasswordChange.cpp index ec1cd029a..79601a99f 100644 --- a/src/guiPasswordChange.cpp +++ b/src/guiPasswordChange.cpp @@ -21,6 +21,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "serialization.h" #include <string> +#include "gettext.h" + const int ID_oldPassword = 256; const int ID_newPassword1 = 257; const int ID_newPassword2 = 258; @@ -97,8 +99,7 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize) { core::rect<s32> rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, ypos+6); - const wchar_t *text = L"Old Password"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(chartowchar_t(gettext("Old Password")), rect, false, true, this, -1); } { core::rect<s32> rect(0, 0, 230, 30); @@ -112,8 +113,7 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize) { core::rect<s32> rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, ypos+6); - const wchar_t *text = L"New Password"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(chartowchar_t(gettext("New Password")), rect, false, true, this, -1); } { core::rect<s32> rect(0, 0, 230, 30); @@ -126,8 +126,7 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize) { core::rect<s32> rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, ypos+6); - const wchar_t *text = L"Confirm Password"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(chartowchar_t(gettext("Confirm Password")), rect, false, true, this, -1); } { core::rect<s32> rect(0, 0, 230, 30); @@ -141,16 +140,15 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize) { core::rect<s32> rect(0, 0, 140, 30); rect = rect + v2s32(size.X/2-140/2, ypos); - Environment->addButton(rect, this, ID_change, L"Change"); + Environment->addButton(rect, this, ID_change, chartowchar_t(gettext("Change"))); } ypos += 50; { core::rect<s32> rect(0, 0, 300, 20); rect += topleft_client + v2s32(35, ypos); - const wchar_t *text = L"Passwords do not match!"; IGUIElement *e = - Environment->addStaticText(text, rect, false, true, this, ID_message); + Environment->addStaticText(chartowchar_t(gettext("Passwords do not match!")), rect, false, true, this, ID_message); e->setVisible(false); } diff --git a/src/guiPauseMenu.cpp b/src/guiPauseMenu.cpp index 1a885a6ea..5f40a4820 100644 --- a/src/guiPauseMenu.cpp +++ b/src/guiPauseMenu.cpp @@ -24,6 +24,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "config.h"
#include "main.h"
+#include "gettext.h"
+
GUIPauseMenu::GUIPauseMenu(gui::IGUIEnvironment* env,
gui::IGUIElement* parent, s32 id,
IGameCallback *gamecallback,
@@ -104,43 +106,43 @@ void GUIPauseMenu::regenerateGui(v2u32 screensize) {
core::rect<s32> rect(0, 0, 140, btn_height);
rect = rect + v2s32(size.X/2-140/2, btn_y);
- Environment->addButton(rect, this, 256, L"Continue");
+ Environment->addButton(rect, this, 256, chartowchar_t(gettext("Continue")));
}
btn_y += btn_height + btn_gap;
{
core::rect<s32> rect(0, 0, 140, btn_height);
rect = rect + v2s32(size.X/2-140/2, btn_y);
- Environment->addButton(rect, this, 261, L"Change Password");
+ Environment->addButton(rect, this, 261, chartowchar_t(gettext("Change Password")));
}
btn_y += btn_height + btn_gap;
{
core::rect<s32> rect(0, 0, 140, btn_height);
rect = rect + v2s32(size.X/2-140/2, btn_y);
- Environment->addButton(rect, this, 260, L"Disconnect");
+ Environment->addButton(rect, this, 260, chartowchar_t(gettext("Disconnect")));
}
btn_y += btn_height + btn_gap;
{
core::rect<s32> rect(0, 0, 140, btn_height);
rect = rect + v2s32(size.X/2-140/2, btn_y);
- Environment->addButton(rect, this, 257, L"Exit to OS");
+ Environment->addButton(rect, this, 257, chartowchar_t(gettext("Exit to OS")));
}
{
core::rect<s32> rect(0, 0, 180, 240);
rect = rect + v2s32(size.X/2 + 90, size.Y/2-rect.getHeight()/2);
- const wchar_t *text =
- L"Keys:\n"
- L"- WASD: Walk\n"
- L"- Mouse left: dig blocks\n"
- L"- Mouse right: place blocks\n"
- L"- Mouse wheel: select item\n"
- L"- 0...9: select item\n"
- L"- Shift: sneak\n"
- L"- R: Toggle viewing all loaded chunks\n"
- L"- I: Inventory menu\n"
- L"- ESC: This menu\n"
- L"- T: Chat\n";
- Environment->addStaticText(text, rect, false, true, this, 258);
+ Environment->addStaticText(chartowchar_t(gettext(
+ "Keys:\n"
+ "- WASD: Walk\n"
+ "- Mouse left: dig blocks\n"
+ "- Mouse right: place blocks\n"
+ "- Mouse wheel: select item\n"
+ "- 0...9: select item\n"
+ "- Shift: sneak\n"
+ "- R: Toggle viewing all loaded chunks\n"
+ "- I: Inventory menu\n"
+ "- ESC: This menu\n"
+ "- T: Chat\n"
+ )), rect, false, true, this, 258);
}
{
core::rect<s32> rect(0, 0, 180, 220);
diff --git a/src/guiTextInputMenu.cpp b/src/guiTextInputMenu.cpp index 2cb8cae62..b15f8bc07 100644 --- a/src/guiTextInputMenu.cpp +++ b/src/guiTextInputMenu.cpp @@ -22,6 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "serialization.h" #include <string> +#include "gettext.h" + GUITextInputMenu::GUITextInputMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, s32 id, IMenuManager *menumgr, @@ -105,7 +107,7 @@ void GUITextInputMenu::regenerateGui(v2u32 screensize) { core::rect<s32> rect(0, 0, 140, 30); rect = rect + v2s32(size.X/2-140/2, size.Y/2-30/2+25); - Environment->addButton(rect, this, 257, L"Proceed"); + Environment->addButton(rect, this, 257, chartowchar_t(gettext("Proceed"))); } } diff --git a/src/main.cpp b/src/main.cpp index 698c5fc71..1cc479d65 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -401,6 +401,8 @@ Doing currently: #include "keycode.h"
#include "tile.h"
+#include "gettext.h"
+
// This makes textures
ITextureSource *g_texturesource = NULL;
@@ -1058,6 +1060,9 @@ int main(int argc, char *argv[]) std::locale::global(std::locale("C"));
// This enables printing all characters in bitmap font
setlocale(LC_CTYPE, "en_US");
+ setlocale(LC_ALL, "");
+ bindtextdomain("minetest-c55", "./../locale");
+ textdomain("minetest-c55");
/*
Parse command line
|