summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-05 16:21:56 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-05 16:21:56 +0000
commit1828eee6a6d91fd385ad1e69d93044516493aa91 (patch)
tree9e7e86955e2d79f4f21daacf009312efd90dc70e /src
parent52abf02fb5521a00e78903addda6f8a20896f18f (diff)
downloadmana-1828eee6a6d91fd385ad1e69d93044516493aa91.tar.gz
mana-1828eee6a6d91fd385ad1e69d93044516493aa91.tar.bz2
mana-1828eee6a6d91fd385ad1e69d93044516493aa91.tar.xz
mana-1828eee6a6d91fd385ad1e69d93044516493aa91.zip
Added support for internationalization. Tested by translating a few gui strings to french.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/gui/inventorywindow.cpp12
-rw-r--r--src/main.cpp7
-rw-r--r--src/resources/gettext.h44
4 files changed, 60 insertions, 7 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 0ccdd777..42b9d262 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -194,6 +194,7 @@ tmw_SOURCES = gui/widgets/dropdown.cpp \
resources/equipmentdb.cpp \
resources/equipmentdb.h \
resources/equipmentinfo.h \
+ resources/gettext.h \
resources/image.cpp \
resources/image.h \
resources/imagewriter.cpp \
@@ -306,4 +307,5 @@ tmw_SOURCES = gui/widgets/dropdown.cpp \
# set the include path found by configure
INCLUDES = \
$(all_includes) \
- -DTMW_DATADIR=\""$(pkgdatadir)/"\"
+ -DTMW_DATADIR=\""$(pkgdatadir)/"\" \
+ -DLOCALEDIR=\""$(localedir)"\"
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 2ad35095..95a669a9 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -39,22 +39,22 @@
#include "../item.h"
#include "../localplayer.h"
+#include "../resources/gettext.h"
#include "../resources/iteminfo.h"
#include "../utils/tostring.h"
InventoryWindow::InventoryWindow():
- Window("Inventory")
+ Window(_("Inventory"))
{
- setWindowName("Inventory");
setResizable(true);
setMinWidth(240);
setMinHeight(172);
// If you adjust these defaults, don't forget to adjust the trade window's.
setDefaultSize(115, 25, 322, 172);
- mUseButton = new Button("Use", "use", this);
- mDropButton = new Button("Drop", "drop", this);
+ mUseButton = new Button(_("Use"), "use", this);
+ mDropButton = new Button(_("Drop"), "drop", this);
mItems = new ItemContainer(player_node->mInventory.get());
mItems->addSelectionListener(this);
@@ -210,10 +210,10 @@ void InventoryWindow::updateButtons()
if ((item = mItems->getItem()) && item->isEquipment())
{
- mUseButton->setCaption("Equip");
+ mUseButton->setCaption(_("Equip"));
}
else {
- mUseButton ->setCaption("Use");
+ mUseButton ->setCaption(_("Use"));
}
mUseButton->setEnabled(!!item);
diff --git a/src/main.cpp b/src/main.cpp
index 8b631d56..018d93dd 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -85,6 +85,7 @@
#include "net/gameserver/gameserver.h"
#include "resources/equipmentdb.h"
+#include "resources/gettext.h"
#include "resources/image.h"
#include "resources/itemdb.h"
#include "resources/monsterdb.h"
@@ -666,6 +667,12 @@ int main(int argc, char *argv[])
return 0;
}
+#if ENABLE_NLS
+ setlocale(LC_MESSAGES, "");
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+#endif
+
// Initialize PhysicsFS
PHYSFS_init(argv[0]);
diff --git a/src/resources/gettext.h b/src/resources/gettext.h
new file mode 100644
index 00000000..4b893a6f
--- /dev/null
+++ b/src/resources/gettext.h
@@ -0,0 +1,44 @@
+/*
+ * The Mana World
+ * Copyright 2007 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#ifndef _TMW_RESOURCES_GETTEXT_H
+#define _TMW_RESOURCES_GETTEXT_H
+
+#include "../../config.h"
+
+#if ENABLE_NLS
+
+#include <libintl.h>
+
+#define _(s) ((char const *)gettext(s))
+#define N_(s) ((char const *)s)
+
+#else
+
+#define gettext(s) ((char const *)s)
+#define _(s) ((char const *)s)
+#define N_(s) ((char const *)s)
+
+#endif
+
+#endif