Merge pull request #22 from SpeedProg/master

added gettext support
This commit is contained in:
Nils Dagsson Moskopp 2011-07-20 08:56:35 -07:00
commit cef7bb0619
11 changed files with 241 additions and 42 deletions

View File

@ -90,6 +90,8 @@ Compiling on Windows:
http://www.winimage.com/zLibDll/index.html
* Zlib library (zlibwapi.lib and zlibwapi.dll from zlib125dll.zip):
http://www.winimage.com/zLibDll/index.html
* gettext bibrary and tools:
http://gnuwin32.sourceforge.net/downlinks/gettext.php
* And, of course, Minetest-c55:
http://celeron.55.lt/~celeron55/minetest/download
- Steps:
@ -117,6 +119,10 @@ Compiling on Windows:
+ lib
+ include
...
+ gettext
+bin
+include
+lib
+ minetest
+ src
+ doc
@ -145,6 +151,10 @@ Compiling on Windows:
ZLIB_DLL DIR/zlib125dll/dll32/zlibwapi.dll
ZLIB_INCLUDE_DIR DIR/zlib-1.2.5
ZLIB_LIBRARIES DIR/zlib125dll/dll32/zlibwapi.lib
GETTEXT_BIN_DIR DIR/gettext/bin
GETTEXT_INCLUDE_DIR DIR/gettext/include
GETTEXT_LIBRARIES DIR/gettext/lib/intl.lib
GETTEXT_MSGFMT DIR/gettext/bin/msgfmt
-----------------
- Hit "Configure"
- Hit "Generate"

125
po/de/minetest-c55.po Normal file
View File

@ -0,0 +1,125 @@
# German translations for minetest-c55 package.
# Copyright (C) 2011 celeron
# This file is distributed under the same license as the minetest-c55 package.
# Constantin Wenger <constantin.wenger@googlemail.com>, 2011.
#
msgid ""
msgstr ""
"Project-Id-Version: 0.0.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-07-20 16:57+0200\n"
"PO-Revision-Date: 2011-07-20 16:58+0100\n"
"Last-Translator: Constantin Wenger <constantin.wenger@googlemail.com>\n"
"Language-Team: Deutsch <>\n"
"Language: de\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"
#: src/guiMainMenu.cpp:180
msgid "Name/Password"
msgstr "Name/Passwort"
#: src/guiMainMenu.cpp:202
msgid "Address/Port"
msgstr "Adresse / Port"
#: src/guiMainMenu.cpp:220
msgid "Leave address blank to start a local server."
msgstr "Lasse die Adresse frei um einen eigenen Server zu starten"
#: src/guiMainMenu.cpp:226
msgid "Fancy trees"
msgstr "Schöne Bäume"
#: src/guiMainMenu.cpp:232
msgid "Smooth Lighting"
msgstr "Besseres Licht"
#: src/guiMainMenu.cpp:239
msgid "Start Game / Connect"
msgstr "Spiel starten / Verbinden"
#: src/guiMainMenu.cpp:247
msgid "Change keys"
msgstr "Tastenbelegung ändern"
#: src/guiMainMenu.cpp:269
msgid "Creative Mode"
msgstr "Kreativitätsmodus"
#: src/guiMainMenu.cpp:274
msgid "Enable Damage"
msgstr "Schaden einschalten"
#: src/guiMainMenu.cpp:281
msgid "Delete map"
msgstr "Karte löschen"
#: src/guiMessageMenu.cpp:92
#: src/guiTextInputMenu.cpp:110
msgid "Proceed"
msgstr "Fortsetzen"
#: src/guiPasswordChange.cpp:102
msgid "Old Password"
msgstr "Altes Passwort"
#: src/guiPasswordChange.cpp:116
msgid "New Password"
msgstr "Neues Passwort"
#: src/guiPasswordChange.cpp:129
msgid "Confirm Password"
msgstr "Passwort wiederholen"
#: src/guiPasswordChange.cpp:143
msgid "Change"
msgstr "Ändern"
#: src/guiPasswordChange.cpp:151
msgid "Passwords do not match!"
msgstr "Passwörter passen nicht zusammen"
#: src/guiPauseMenu.cpp:109
msgid "Continue"
msgstr "Weiter"
#: src/guiPauseMenu.cpp:115
msgid "Change Password"
msgstr "Passwort ändern"
#: src/guiPauseMenu.cpp:121
msgid "Disconnect"
msgstr "Verbindung trennen"
#: src/guiPauseMenu.cpp:127
msgid "Exit to OS"
msgstr "Programm beenden"
#: src/guiPauseMenu.cpp:134
msgid ""
"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"
msgstr ""
"Tastenkürzel:\n"
"- WASD: Gehen\n"
"- linke Maustaste: dig blocks\n"
"- rechte Maustaste: place blocks\n"
"- Mausrad: Item auswählen\n"
"- 0...9: Item auswählen\n"
"- Shift: ducken\n"
"- R: Alle geladenen Kartenteile anzeigen, umschalten\n"
"- I: Inventarmenü\n"
"- T: Chat\n"

View File

@ -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)

12
src/gettext.h Normal file
View File

@ -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;
}

View File

@ -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")));
}
}

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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")));
}
}

View File

@ -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

4
updatelocales.sh Executable file
View File

@ -0,0 +1,4 @@
#! /bin/bash
xgettext -n -o minetest-c55.pot ./src/*.cpp ./src/*.h
msgmerge -U ./po/de/minetest-c55.po minetest-c55.pot
rm minetest-c55.pot