summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-01-06 13:52:30 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-01-06 15:50:02 +0100
commitbfd1d1bcc2a6ecd7efe301bfbf22a1e9b9188706 (patch)
treeb30134f93042e4afb5554b5f14a83528ed2ef069
parentce0d7b62824d620ec8c3daceac5710fbbd6b12f1 (diff)
downloadmana-bfd1d1bcc2a6ecd7efe301bfbf22a1e9b9188706.tar.gz
mana-bfd1d1bcc2a6ecd7efe301bfbf22a1e9b9188706.tar.bz2
mana-bfd1d1bcc2a6ecd7efe301bfbf22a1e9b9188706.tar.xz
mana-bfd1d1bcc2a6ecd7efe301bfbf22a1e9b9188706.zip
Added support for internationalization
Merged from the mainline client. Originally implemented by Guillaume Melquiond, starting with commit 1828eee6a6d91fd385ad1e69d93044516493aa91.
-rw-r--r--INSTALL5
-rw-r--r--Makefile.am5
-rwxr-xr-xconfigure.ac9
-rw-r--r--po/LINGUAS1
-rw-r--r--po/Makevars41
-rw-r--r--po/POTFILES.in25
-rw-r--r--po/tmw.pot486
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am4
-rw-r--r--src/graphics.cpp2
-rw-r--r--src/gui/buy.cpp34
-rw-r--r--src/gui/char_select.cpp63
-rw-r--r--src/gui/char_server.cpp8
-rw-r--r--src/gui/confirm_dialog.cpp5
-rw-r--r--src/gui/connection.cpp6
-rw-r--r--src/gui/equipmentwindow.cpp4
-rw-r--r--src/gui/inventorywindow.cpp51
-rw-r--r--src/gui/item_amount.cpp34
-rw-r--r--src/gui/login.cpp20
-rw-r--r--src/gui/menuwindow.cpp18
-rw-r--r--src/gui/minimap.cpp4
-rw-r--r--src/gui/npc_text.cpp6
-rw-r--r--src/gui/npclistdialog.cpp8
-rw-r--r--src/gui/ok_dialog.cpp4
-rw-r--r--src/gui/popupmenu.cpp29
-rw-r--r--src/gui/register.cpp51
-rw-r--r--src/gui/sell.cpp41
-rw-r--r--src/gui/setup.cpp18
-rw-r--r--src/gui/setup_audio.cpp8
-rw-r--r--src/gui/setup_joystick.cpp18
-rw-r--r--src/gui/setup_video.cpp55
-rw-r--r--src/gui/trade.cpp43
-rw-r--r--src/main.cpp14
-rw-r--r--src/resources/itemdb.cpp5
-rw-r--r--src/utils/gettext.h44
35 files changed, 913 insertions, 257 deletions
diff --git a/INSTALL b/INSTALL
index cd530cae..d604895c 100644
--- a/INSTALL
+++ b/INSTALL
@@ -12,7 +12,7 @@ IRC: irc.freenode.net / #themanaworld
1. Requirements
===============
-You are expected to have either checked out TMW from CVS or you have downloaded
+You are expected to have either checked out TMW from Git or you have downloaded
a source release. To get The Mana World to compile, you need a compiler (GCC)
and some libraries. The required libraries are:
@@ -20,6 +20,7 @@ and some libraries. The required libraries are:
* SDL_mixer http://www.libsdl.org/projects/SDL_mixer/
* SDL_image http://www.libsdl.org/projects/SDL_image/
* SDL_net http://www.libsdl.org/projects/SDL_net/
+* SDL_ttf http://www.libsdl.org/projects/SDL_ttf/
* Guichan 0.8.x http://guichan.sourceforge.net/
* libxml2 http://www.xmlsoft.org/
* physfs 1.0.x http://icculus.org/physfs/
@@ -30,6 +31,8 @@ If you've cloned the Git repository, you will also need these tools to compile:
* GNU automake 1.9 http://www.gnu.org/software/automake/
* GNU autoconf http://www.gnu.org/software/autoconf/
+* GNU gettext http://www.gnu.org/software/gettext/
+* CVS http://www.nongnu.org/cvs/ (needed to run autopoint)
Installing these dependencies is distributions-specific, and we'll leave it to
you to figure this out.
diff --git a/Makefile.am b/Makefile.am
index 7306c71f..2d7250cc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,5 @@
# Subdirectories to build
-SUBDIRS = data docs src
+SUBDIRS = data docs po src
desktopdir = $(datadir)/applications
@@ -7,3 +7,6 @@ desktop_DATA = tmw.desktop
# Extra files to include
EXTRA_DIST = $(desktop_DATA)
+
+# Autopoint m4 stuff
+ACLOCAL_AMFLAGS = -I m4
diff --git a/configure.ac b/configure.ac
index c95d3006..8c1ce8a4 100755
--- a/configure.ac
+++ b/configure.ac
@@ -7,13 +7,9 @@ AC_LANG_CPLUSPLUS
# Checks for programs.
AC_PROG_CXX
AC_PROG_INSTALL
-AC_PROG_MAKE_SET
# Checks for typedefs, structures, and compiler characteristics.
-AC_HEADER_STDBOOL
-AC_C_CONST
AC_HEADER_TIME
-AC_C_VOLATILE
# Checks for library functions.
AC_FUNC_ERROR_AT_LINE
@@ -23,6 +19,10 @@ AC_FUNC_SELECT_ARGTYPES
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([atexit floor getcwd gethostbyname memset mkdir select socket])
+# Checks for internationalization support
+AM_GNU_GETTEXT([external])
+AM_GNU_GETTEXT_VERSION([0.16.1])
+
# Search for *-config
AC_PATH_PROG(SDL_CONFIG, sdl-config)
AC_PATH_PROG(PKG_CONFIG, pkg-config)
@@ -117,6 +117,7 @@ data/graphics/images/Makefile
data/help/Makefile
data/icons/Makefile
docs/Makefile
+po/Makefile.in
])
AC_OUTPUT
diff --git a/po/LINGUAS b/po/LINGUAS
new file mode 100644
index 00000000..8bba9bc2
--- /dev/null
+++ b/po/LINGUAS
@@ -0,0 +1 @@
+# Set of available languages.
diff --git a/po/Makevars b/po/Makevars
new file mode 100644
index 00000000..76e72f50
--- /dev/null
+++ b/po/Makevars
@@ -0,0 +1,41 @@
+# Makefile variables for PO directory in any package using GNU gettext.
+
+# Usually the message domain is the same as the package name.
+DOMAIN = tmw
+
+# These two variables depend on the location of this directory.
+subdir = po
+top_builddir = ..
+
+# These options get passed to xgettext.
+XGETTEXT_OPTIONS = --keyword=_ --keyword=N_
+
+# This is the copyright holder that gets inserted into the header of the
+# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
+# package. (Note that the msgstr strings, extracted from the package's
+# sources, belong to the copyright holder of the package.) Translators are
+# expected to transfer the copyright for their translations to this person
+# or entity, or to disclaim their copyright. The empty string stands for
+# the public domain; in this case the translators are expected to disclaim
+# their copyright.
+COPYRIGHT_HOLDER = The Mana World Development Team
+
+# This is the email address or URL to which the translators shall report
+# bugs in the untranslated strings:
+# - Strings which are not entire sentences, see the maintainer guidelines
+# in the GNU gettext documentation, section 'Preparing Strings'.
+# - Strings which use unclear terms or require additional context to be
+# understood.
+# - Strings which make invalid assumptions about notation of date, time or
+# money.
+# - Pluralisation problems.
+# - Incorrect English spelling.
+# - Incorrect formatting.
+# It can be your email address, or a mailing list address where translators
+# can write to without being subscribed, or the URL of a web page through
+# which the translators can contact you.
+MSGID_BUGS_ADDRESS =
+
+# This is the list of locale categories, beyond LC_MESSAGES, for which the
+# message catalogs shall be used. It is usually empty.
+EXTRA_LOCALE_CATEGORIES =
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644
index 00000000..f750976e
--- /dev/null
+++ b/po/POTFILES.in
@@ -0,0 +1,25 @@
+# List of source files which contain translatable strings.
+
+src/gui/buy.cpp
+src/gui/char_select.cpp
+src/gui/char_server.cpp
+src/gui/confirm_dialog.cpp
+src/gui/connection.cpp
+src/gui/equipmentwindow.cpp
+src/gui/inventorywindow.cpp
+src/gui/item_amount.cpp
+src/gui/login.cpp
+src/gui/menuwindow.cpp
+src/gui/minimap.cpp
+src/gui/npclistdialog.cpp
+src/gui/npc_text.cpp
+src/gui/ok_dialog.cpp
+src/gui/popupmenu.cpp
+src/gui/register.cpp
+src/gui/sell.cpp
+src/gui/setup_audio.cpp
+src/gui/setup.cpp
+src/gui/setup_joystick.cpp
+src/gui/setup_video.cpp
+src/gui/trade.cpp
+src/resources/itemdb.cpp
diff --git a/po/tmw.pot b/po/tmw.pot
new file mode 100644
index 00000000..ae49bb32
--- /dev/null
+++ b/po/tmw.pot
@@ -0,0 +1,486 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR The Mana World Development Team
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: themanaworld-devel@lists.sourceforge.net\n"
+"POT-Creation-Date: 2009-01-06 14:37+0100\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/gui/buy.cpp:41 src/gui/buy.cpp:59
+msgid "Buy"
+msgstr ""
+
+#: src/gui/buy.cpp:56 src/gui/buy.cpp:284 src/gui/sell.cpp:63
+#: src/gui/sell.cpp:304
+#, c-format
+msgid "Price: %d GP / Total: %d GP"
+msgstr ""
+
+#: src/gui/buy.cpp:60 src/gui/sell.cpp:67
+msgid "Quit"
+msgstr ""
+
+#: src/gui/buy.cpp:61 src/gui/buy.cpp:251 src/gui/buy.cpp:269
+#: src/gui/inventorywindow.cpp:150 src/gui/inventorywindow.cpp:160
+#: src/gui/sell.cpp:68 src/gui/sell.cpp:275 src/gui/sell.cpp:289
+#: src/gui/trade.cpp:94 src/gui/trade.cpp:266
+#, c-format
+msgid "Description: %s"
+msgstr ""
+
+#: src/gui/buy.cpp:62 src/gui/buy.cpp:253 src/gui/buy.cpp:270
+#: src/gui/inventorywindow.cpp:149 src/gui/inventorywindow.cpp:158
+#: src/gui/sell.cpp:69 src/gui/sell.cpp:277 src/gui/sell.cpp:290
+#, c-format
+msgid "Effect: %s"
+msgstr ""
+
+#: src/gui/char_select.cpp:61
+msgid "Confirm Character Delete"
+msgstr ""
+
+#: src/gui/char_select.cpp:62
+msgid "Are you sure you want to delete this character?"
+msgstr ""
+
+#: src/gui/char_select.cpp:79
+msgid "Select Character"
+msgstr ""
+
+#: src/gui/char_select.cpp:82 src/gui/item_amount.cpp:50 src/gui/login.cpp:49
+#: src/gui/ok_dialog.cpp:37 src/gui/trade.cpp:62
+msgid "Ok"
+msgstr ""
+
+#: src/gui/char_select.cpp:83 src/gui/char_select.cpp:271
+#: src/gui/char_server.cpp:60 src/gui/connection.cpp:47
+#: src/gui/item_amount.cpp:51 src/gui/login.cpp:50
+#: src/gui/npclistdialog.cpp:45 src/gui/register.cpp:76 src/gui/setup.cpp:58
+#: src/gui/trade.cpp:63
+msgid "Cancel"
+msgstr ""
+
+#: src/gui/char_select.cpp:84
+msgid "New"
+msgstr ""
+
+#: src/gui/char_select.cpp:85
+msgid "Delete"
+msgstr ""
+
+#: src/gui/char_select.cpp:86
+msgid "Previous"
+msgstr ""
+
+#: src/gui/char_select.cpp:87
+msgid "Next"
+msgstr ""
+
+#: src/gui/char_select.cpp:89 src/gui/char_select.cpp:184
+#: src/gui/char_select.cpp:196 src/gui/inventorywindow.cpp:148
+#: src/gui/inventorywindow.cpp:156 src/gui/trade.cpp:92 src/gui/trade.cpp:264
+#, c-format
+msgid "Name: %s"
+msgstr ""
+
+#: src/gui/char_select.cpp:90 src/gui/char_select.cpp:185
+#: src/gui/char_select.cpp:197
+#, c-format
+msgid "Level: %d"
+msgstr ""
+
+#: src/gui/char_select.cpp:91 src/gui/char_select.cpp:186
+#: src/gui/char_select.cpp:198
+#, c-format
+msgid "Job Level: %d"
+msgstr ""
+
+#: src/gui/char_select.cpp:92 src/gui/char_select.cpp:199
+#, c-format
+msgid "Money: %d"
+msgstr ""
+
+#: src/gui/char_select.cpp:187
+#, c-format
+msgid "Gold: %d"
+msgstr ""
+
+#: src/gui/char_select.cpp:256
+msgid "Create Character"
+msgstr ""
+
+#: src/gui/char_select.cpp:263 src/gui/login.cpp:42 src/gui/register.cpp:65
+msgid "Name:"
+msgstr ""
+
+#: src/gui/char_select.cpp:266
+msgid "Hair Color:"
+msgstr ""
+
+#: src/gui/char_select.cpp:269
+msgid "Hair Style:"
+msgstr ""
+
+#: src/gui/char_select.cpp:270
+msgid "Create"
+msgstr ""
+
+#: src/gui/char_server.cpp:52
+msgid "Select Server"
+msgstr ""
+
+#: src/gui/char_server.cpp:59 src/gui/npclistdialog.cpp:44
+#: src/gui/npc_text.cpp:46
+msgid "OK"
+msgstr ""
+
+#: src/gui/confirm_dialog.cpp:35
+msgid "Yes"
+msgstr ""
+
+#: src/gui/confirm_dialog.cpp:36
+msgid "No"
+msgstr ""
+
+#: src/gui/connection.cpp:49
+msgid "Connecting..."
+msgstr ""
+
+#: src/gui/equipmentwindow.cpp:38 src/gui/menuwindow.cpp:62
+msgid "Equipment"
+msgstr ""
+
+#: src/gui/inventorywindow.cpp:46 src/gui/menuwindow.cpp:63
+msgid "Inventory"
+msgstr ""
+
+#: src/gui/inventorywindow.cpp:56 src/gui/inventorywindow.cpp:232
+msgid "Use"
+msgstr ""
+
+#: src/gui/inventorywindow.cpp:57
+msgid "Drop"
+msgstr ""
+
+#: src/gui/inventorywindow.cpp:99
+#, c-format
+msgid "Weight: %d / %d"
+msgstr ""
+
+#: src/gui/inventorywindow.cpp:104
+#, c-format
+msgid "Slots used: %d / %d"
+msgstr ""
+
+#: src/gui/inventorywindow.cpp:225
+msgid "Unequip"
+msgstr ""
+
+#: src/gui/inventorywindow.cpp:228
+msgid "Equip"
+msgstr ""
+
+#: src/gui/item_amount.cpp:75
+msgid "Select amount of items to trade."
+msgstr ""
+
+#: src/gui/item_amount.cpp:79
+msgid "Select amount of items to drop."
+msgstr ""
+
+#: src/gui/login.cpp:40
+msgid "Login"
+msgstr ""
+
+#: src/gui/login.cpp:43 src/gui/register.cpp:66
+msgid "Password:"
+msgstr ""
+
+#: src/gui/login.cpp:44 src/gui/register.cpp:68
+msgid "Server:"
+msgstr ""
+
+#: src/gui/login.cpp:48
+msgid "Remember Username"
+msgstr ""
+
+#: src/gui/login.cpp:51 src/gui/register.cpp:75
+msgid "Register"
+msgstr ""
+
+#: src/gui/menuwindow.cpp:61
+msgid "Status"
+msgstr ""
+
+#: src/gui/menuwindow.cpp:64
+msgid "Skills"
+msgstr ""
+
+#: src/gui/menuwindow.cpp:65
+msgid "Shortcut"
+msgstr ""
+
+#: src/gui/menuwindow.cpp:66
+msgid "Setup"
+msgstr ""
+
+#: src/gui/minimap.cpp:34
+msgid "MiniMap"
+msgstr ""
+
+#: src/gui/npclistdialog.cpp:35 src/gui/npc_text.cpp:35
+msgid "NPC"
+msgstr ""
+
+#: src/gui/popupmenu.cpp:81
+#, c-format
+msgid "@@trade|Trade With %s@@"
+msgstr ""
+
+#: src/gui/popupmenu.cpp:83
+#, c-format
+msgid "@@attack|Attack %s@@"
+msgstr ""
+
+#: src/gui/popupmenu.cpp:114
+msgid "@@talk|Talk To NPC@@"
+msgstr ""
+
+#: src/gui/popupmenu.cpp:124 src/gui/popupmenu.cpp:140
+#: src/gui/popupmenu.cpp:293
+msgid "@@cancel|Cancel@@"
+msgstr ""
+
+#: src/gui/popupmenu.cpp:136
+#, c-format
+msgid "@@pickup|Pick Up %s@@"
+msgstr ""
+
+#: src/gui/popupmenu.cpp:283
+msgid "@@use|Unequip@@"
+msgstr ""
+
+#: src/gui/popupmenu.cpp:285
+msgid "@@use|Equip@@"
+msgstr ""
+
+#: src/gui/popupmenu.cpp:288
+msgid "@@use|Use@@"
+msgstr ""
+
+#: src/gui/popupmenu.cpp:290
+msgid "@@drop|Drop@@"
+msgstr ""
+
+#: src/gui/popupmenu.cpp:291
+msgid "@@description|Description@@"
+msgstr ""
+
+#: src/gui/register.cpp:67
+msgid "Confirm:"
+msgstr ""
+
+#: src/gui/register.cpp:73
+msgid "Male"
+msgstr ""
+
+#: src/gui/register.cpp:74
+msgid "Female"
+msgstr ""
+
+#: src/gui/register.cpp:176
+#, c-format
+msgid "The username needs to be at least %d characters long."
+msgstr ""
+
+#: src/gui/register.cpp:184
+#, c-format
+msgid "The username needs to be less than %d characters long."
+msgstr ""
+
+#: src/gui/register.cpp:192
+#, c-format
+msgid "The password needs to be at least %d characters long."
+msgstr ""
+
+#: src/gui/register.cpp:200
+#, c-format
+msgid "The password needs to be less than %d characters long."
+msgstr ""
+
+#: src/gui/register.cpp:207
+msgid "Passwords do not match."
+msgstr ""
+
+#: src/gui/register.cpp:227
+msgid "Error"
+msgstr ""
+
+#: src/gui/sell.cpp:46 src/gui/sell.cpp:66
+msgid "Sell"
+msgstr ""
+
+#: src/gui/setup_audio.cpp:40
+msgid "Sound"
+msgstr ""
+
+#: src/gui/setup_audio.cpp:46
+msgid "Sfx volume"
+msgstr ""
+
+#: src/gui/setup_audio.cpp:47
+msgid "Music volume"
+msgstr ""
+
+#: src/gui/setup.cpp:58
+msgid "Apply"
+msgstr ""
+
+#: src/gui/setup.cpp:58
+msgid "Reset Windows"
+msgstr ""
+
+#: src/gui/setup.cpp:79
+msgid "Video"
+msgstr ""
+
+#: src/gui/setup.cpp:83
+msgid "Audio"
+msgstr ""
+
+#: src/gui/setup.cpp:87
+msgid "Joystick"
+msgstr ""
+
+#: src/gui/setup.cpp:91
+msgid "Keyboard"
+msgstr ""
+
+#: src/gui/setup.cpp:95
+msgid "Players"
+msgstr ""
+
+#: src/gui/setup_joystick.cpp:36 src/gui/setup_joystick.cpp:70
+msgid "Press the button to start calibration"
+msgstr ""
+
+#: src/gui/setup_joystick.cpp:37 src/gui/setup_joystick.cpp:68
+msgid "Calibrate"
+msgstr ""
+
+#: src/gui/setup_joystick.cpp:38
+msgid "Enable joystick"
+msgstr ""
+
+#: src/gui/setup_joystick.cpp:73
+msgid "Stop"
+msgstr ""
+
+#: src/gui/setup_joystick.cpp:74
+msgid "Rotate the stick"
+msgstr ""
+
+#: src/gui/setup_video.cpp:112
+msgid "Full screen"
+msgstr ""
+
+#: src/gui/setup_video.cpp:113
+msgid "OpenGL"
+msgstr ""
+
+#: src/gui/setup_video.cpp:114
+msgid "Custom cursor"
+msgstr ""
+
+#: src/gui/setup_video.cpp:116
+msgid "FPS Limit:"
+msgstr ""
+
+#: src/gui/setup_video.cpp:135
+msgid "Gui opacity"
+msgstr ""
+
+#: src/gui/setup_video.cpp:192
+msgid "Scroll radius"
+msgstr ""
+
+#: src/gui/setup_video.cpp:200
+msgid "Scroll laziness"
+msgstr ""
+
+#: src/gui/setup_video.cpp:208
+msgid "Ambient FX"
+msgstr ""
+
+#: src/gui/setup_video.cpp:215 src/gui/setup_video.cpp:412
+msgid "off"
+msgstr ""
+
+#: src/gui/setup_video.cpp:218 src/gui/setup_video.cpp:234
+#: src/gui/setup_video.cpp:415 src/gui/setup_video.cpp:429
+msgid "low"
+msgstr ""
+
+#: src/gui/setup_video.cpp:221 src/gui/setup_video.cpp:240
+#: src/gui/setup_video.cpp:418 src/gui/setup_video.cpp:435
+msgid "high"
+msgstr ""
+
+#: src/gui/setup_video.cpp:227
+msgid "Particle Detail"
+msgstr ""
+
+#: src/gui/setup_video.cpp:237 src/gui/setup_video.cpp:432
+msgid "medium"
+msgstr ""
+
+#: src/gui/setup_video.cpp:243 src/gui/setup_video.cpp:438
+msgid "max"
+msgstr ""
+
+#: src/gui/setup_video.cpp:309
+msgid "Switching to full screen"
+msgstr ""
+
+#: src/gui/setup_video.cpp:310
+msgid "Restart needed for changes to take effect."
+msgstr ""
+
+#: src/gui/setup_video.cpp:322
+msgid "Changing OpenGL"
+msgstr ""
+
+#: src/gui/setup_video.cpp:323
+msgid "Applying change to OpenGL requires restart."
+msgstr ""
+
+#: src/gui/trade.cpp:61
+msgid "Add"
+msgstr ""
+
+#: src/gui/trade.cpp:64
+msgid "Trade"
+msgstr ""
+
+#: src/gui/trade.cpp:80 src/gui/trade.cpp:156 src/gui/trade.cpp:204
+#, c-format
+msgid "You get %d GP."
+msgstr ""
+
+#: src/gui/trade.cpp:81
+msgid "You give:"
+msgstr ""
+
+#: src/resources/itemdb.cpp:99
+msgid "Unnamed"
+msgstr ""
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 61fc77e8..666a675d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -261,6 +261,7 @@ SET(SRCS
utils/base64.h
utils/dtor.h
utils/fastsqrt.h
+ utils/gettext.h
utils/strprintf.cpp
utils/strprintf.h
utils/tostring.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 7c547a11..c924760f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -215,6 +215,7 @@ tmw_SOURCES = gui/widgets/resizegrip.cpp \
utils/base64.h \
utils/dtor.h \
utils/fastsqrt.h \
+ utils/gettext.h \
utils/strprintf.cpp \
utils/strprintf.h \
utils/tostring.h \
@@ -311,4 +312,5 @@ tmw_SOURCES = gui/widgets/resizegrip.cpp \
# set the include path found by configure
INCLUDES = \
$(all_includes) \
- -DTMW_DATADIR=\""$(pkgdatadir)/"\"
+ -DTMW_DATADIR=\""$(pkgdatadir)/"\" \
+ -DLOCALEDIR=\""$(localedir)"\"
diff --git a/src/graphics.cpp b/src/graphics.cpp
index c8cb0091..6920bcb0 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -123,7 +123,7 @@ bool Graphics::drawImage(Image *image, int x, int y)
{
return drawImage(image, 0, 0, x, y, image->mBounds.w, image->mBounds.h);
}
-#include <cstdio>
+
bool Graphics::drawImage(Image *image, int srcX, int srcY, int dstX, int dstY,
int width, int height, bool)
{
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index 714f52db..c1e5a272 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -34,10 +34,11 @@
#include "../net/messageout.h"
#include "../net/protocol.h"
-#include "../utils/tostring.h"
+#include "../utils/gettext.h"
+#include "../utils/strprintf.h"
BuyDialog::BuyDialog(Network *network):
- Window("Buy"), mNetwork(network),
+ Window(_("Buy")), mNetwork(network),
mMoney(0), mAmountItems(0), mMaxItems(0)
{
setWindowName("Buy");
@@ -52,13 +53,13 @@ BuyDialog::BuyDialog(Network *network):
mScrollArea = new ScrollArea(mShopItemList);
mSlider = new Slider(1.0);
mQuantityLabel = new gcn::Label("0");
- mMoneyLabel = new gcn::Label("Price : 0 GP / 0 GP");
+ mMoneyLabel = new gcn::Label(strprintf(_("Price: %d GP / Total: %d GP"), 0, 0));
mIncreaseButton = new Button("+", "+", this);
mDecreaseButton = new Button("-", "-", this);
- mBuyButton = new Button("Buy", "buy", this);
- mQuitButton = new Button("Quit", "quit", this);
- mItemDescLabel = new gcn::Label("Description:");
- mItemEffectLabel = new gcn::Label("Effect:");
+ mBuyButton = new Button(_("Buy"), "buy", this);
+ mQuitButton = new Button(_("Quit"), "quit", this);
+ mItemDescLabel = new gcn::Label(strprintf(_("Description: %s"), ""));
+ mItemEffectLabel = new gcn::Label(strprintf(_("Effect: %s"), ""));
mIncreaseButton->setSize(20, 20);
mDecreaseButton->setSize(20, 20);
@@ -159,7 +160,7 @@ void BuyDialog::action(const gcn::ActionEvent &event)
}
// TODO: Actually we'd have a bug elsewhere if this check for the number
// of items to be bought ever fails, Bertram removed the assertions, is
- // there a better way to ensure this fails in an _obivous_ way in C++?
+ // there a better way to ensure this fails in an _obvious_ way in C++?
else if (event.getId() == "buy" && mAmountItems > 0 &&
mAmountItems <= mMaxItems)
{
@@ -246,8 +247,10 @@ BuyDialog::updateButtonsAndLabels()
{
const ItemInfo &info = mShopItems->at(selectedItem)->getInfo();
- mItemDescLabel->setCaption("Description: " + info.getDescription());
- mItemEffectLabel->setCaption("Effect: " + info.getEffect());
+ mItemDescLabel->setCaption
+ (strprintf(_("Description: %s"), info.getDescription().c_str()));
+ mItemEffectLabel->setCaption
+ (strprintf(_("Effect: %s"), info.getEffect().c_str()));
int itemPrice = mShopItems->at(selectedItem)->getPrice();
@@ -263,8 +266,8 @@ BuyDialog::updateButtonsAndLabels()
}
else
{
- mItemDescLabel->setCaption("Description:");
- mItemEffectLabel->setCaption("Effect:");
+ mItemDescLabel->setCaption(strprintf(_("Description: %s"), ""));
+ mItemEffectLabel->setCaption(strprintf(_("Effect: %s"), ""));
mMaxItems = 0;
mAmountItems = 0;
}
@@ -276,8 +279,7 @@ BuyDialog::updateButtonsAndLabels()
mSlider->setEnabled(mMaxItems > 1);
// Update quantity and money labels
- mQuantityLabel->setCaption(
- toString(mAmountItems) + " / " + toString(mMaxItems));
- mMoneyLabel->setCaption("Price: " + toString(price) + " GP / "
- + toString(mMoney - price) + " GP" );
+ mQuantityLabel->setCaption(strprintf("%d / %d", mAmountItems, mMaxItems));
+ mMoneyLabel->setCaption
+ (strprintf(_("Price: %d GP / Total: %d GP"), price, mMoney - price));
}
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index 7c067eef..65dafeea 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -38,7 +38,8 @@
#include "../net/charserverhandler.h"
#include "../net/messageout.h"
-#include "../utils/tostring.h"
+#include "../utils/gettext.h"
+#include "../utils/strprintf.h"
#include "../utils/trim.h"
// Defined in main.cpp, used here for setting the char create dialog
@@ -57,8 +58,8 @@ class CharDeleteConfirm : public ConfirmDialog
};
CharDeleteConfirm::CharDeleteConfirm(CharSelectDialog *m):
- ConfirmDialog("Confirm", "Are you sure you want to delete this character?",
- m),
+ ConfirmDialog(_("Confirm Character Delete"),
+ _("Are you sure you want to delete this character?"), m),
master(m)
{
}
@@ -75,21 +76,23 @@ void CharDeleteConfirm::action(const gcn::ActionEvent &event)
CharSelectDialog::CharSelectDialog(Network *network,
LockedArray<LocalPlayer*> *charInfo,
Gender gender):
- Window("Select Character"), mNetwork(network),
+ Window(_("Select Character")), mNetwork(network),
mCharInfo(charInfo), mGender(gender), mCharSelected(false)
{
- mSelectButton = new Button("Ok", "ok", this);
- mCancelButton = new Button("Cancel", "cancel", this);
- mNewCharButton = new Button("New", "new", this);
- mDelCharButton = new Button("Delete", "delete", this);
- mPreviousButton = new Button("Previous", "previous", this);
- mNextButton = new Button("Next", "next", this);
-
- mNameLabel = new gcn::Label("Name");
- mLevelLabel = new gcn::Label("Level");
- mJobLevelLabel = new gcn::Label("Job Level");
- mMoneyLabel = new gcn::Label("Money");
- mPlayerBox = new PlayerBox();
+ mSelectButton = new Button(_("Ok"), "ok", this);
+ mCancelButton = new Button(_("Cancel"), "cancel", this);
+ mNewCharButton = new Button(_("New"), "new", this);
+ mDelCharButton = new Button(_("Delete"), "delete", this);
+ mPreviousButton = new Button(_("Previous"), "previous", this);
+ mNextButton = new Button(_("Next"), "next", this);
+
+ mNameLabel = new gcn::Label(strprintf(_("Name: %s"), ""));
+ mLevelLabel = new gcn::Label(strprintf(_("Level: %d"), 0));
+ mJobLevelLabel = new gcn::Label(strprintf(_("Job Level: %d"), 0));
+ mMoneyLabel = new gcn::Label(strprintf(_("Money: %d"), 0));
+
+ // Control that shows the Player
+ mPlayerBox = new PlayerBox;
int w = 195;
int h = 220;
@@ -178,10 +181,10 @@ void CharSelectDialog::updatePlayerInfo()
if (pi)
{
- mNameLabel->setCaption(pi->getName());
- mLevelLabel->setCaption("Lvl: " + toString(pi->mLevel));
- mJobLevelLabel->setCaption("Job Lvl: " + toString(pi->mJobLevel));
- mMoneyLabel->setCaption("Gold: " + toString(pi->mGp));
+ mNameLabel->setCaption(strprintf(_("Name: %s"), pi->getName().c_str()));
+ mLevelLabel->setCaption(strprintf(_("Level: %d"), pi->mLevel));
+ mJobLevelLabel->setCaption(strprintf(_("Job Level: %d"), pi->mJobLevel));
+ mMoneyLabel->setCaption(strprintf(_("Gold: %d"), pi->mGp));
if (!mCharSelected)
{
mNewCharButton->setEnabled(false);
@@ -190,10 +193,10 @@ void CharSelectDialog::updatePlayerInfo()
}
}
else {
- mNameLabel->setCaption("Name");
- mLevelLabel->setCaption("Level");
- mJobLevelLabel->setCaption("Job Level");
- mMoneyLabel->setCaption("Money");
+ mNameLabel->setCaption(strprintf(_("Name: %s"), ""));
+ mLevelLabel->setCaption(strprintf(_("Level: %d"), 0));
+ mJobLevelLabel->setCaption(strprintf(_("Job Level: %d"), 0));
+ mMoneyLabel->setCaption(strprintf(_("Money: %d"), 0));
mNewCharButton->setEnabled(true);
mDelCharButton->setEnabled(false);
mSelectButton->setEnabled(false);
@@ -250,22 +253,22 @@ bool CharSelectDialog::selectByName(const std::string &name)
CharCreateDialog::CharCreateDialog(Window *parent, int slot, Network *network,
Gender gender):
- Window("Create Character", true, parent), mNetwork(network), mSlot(slot)
+ Window(_("Create Character"), true, parent), mNetwork(network), mSlot(slot)
{
mPlayer = new Player(0, 0, NULL);
mPlayer->setGender(gender);
mPlayer->setHairStyle(rand() % Being::getHairStylesNr(), rand() % Being::getHairColorsNr());
mNameField = new TextField("");
- mNameLabel = new gcn::Label("Name:");
+ mNameLabel = new gcn::Label(_("Name:"));
mNextHairColorButton = new Button(">", "nextcolor", this);
mPrevHairColorButton = new Button("<", "prevcolor", this);
- mHairColorLabel = new gcn::Label("Hair Color:");
+ mHairColorLabel = new gcn::Label(_("Hair Color:"));
mNextHairStyleButton = new Button(">", "nextstyle", this);
mPrevHairStyleButton = new Button("<", "prevstyle", this);
- mHairStyleLabel = new gcn::Label("Hair Style:");
- mCreateButton = new Button("Create", "create", this);
- mCancelButton = new Button("Cancel", "cancel", this);
+ mHairStyleLabel = new gcn::Label(_("Hair Style:"));
+ mCreateButton = new Button(_("Create"), "create", this);
+ mCancelButton = new Button(_("Cancel"), "cancel", this);
mPlayerBox = new PlayerBox(mPlayer);
mNameField->setActionEventId("create");
diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp
index ce068ad1..3d3309fb 100644
--- a/src/gui/char_server.cpp
+++ b/src/gui/char_server.cpp
@@ -31,6 +31,8 @@
#include "../net/network.h" // TODO this is just for iptostring, move that?
+#include "../utils/gettext.h"
+#include "../utils/strprintf.h"
#include "../utils/tostring.h"
extern SERVER_INFO **server_info;
@@ -47,15 +49,15 @@ class ServerListModel : public gcn::ListModel {
};
ServerSelectDialog::ServerSelectDialog(LoginData *loginData, int nextState):
- Window("Select Server"),
+ Window(_("Select Server")),
mLoginData(loginData),
mNextState(nextState)
{
mServerListModel = new ServerListModel();
mServerList = new ListBox(mServerListModel);
ScrollArea *mScrollArea = new ScrollArea(mServerList);
- mOkButton = new Button("OK", "ok", this);
- Button *mCancelButton = new Button("Cancel", "cancel", this);
+ mOkButton = new Button(_("OK"), "ok", this);
+ Button *mCancelButton = new Button(_("Cancel"), "cancel", this);
setContentSize(200, 100);
diff --git a/src/gui/confirm_dialog.cpp b/src/gui/confirm_dialog.cpp
index 9ef94f62..5f2b9cb2 100644
--- a/src/gui/confirm_dialog.cpp
+++ b/src/gui/confirm_dialog.cpp
@@ -25,14 +25,15 @@
#include "button.h"
+#include "../utils/gettext.h"
ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
Window *parent):
Window(title, true, parent)
{
gcn::Label *textLabel = new gcn::Label(msg);
- gcn::Button *yesButton = new Button("Yes", "yes", this);
- gcn::Button *noButton = new Button("No", "no", this);
+ gcn::Button *yesButton = new Button(_("Yes"), "yes", this);
+ gcn::Button *noButton = new Button(_("No"), "no", this);
int w = textLabel->getWidth() + 20;
int inWidth = yesButton->getWidth() + noButton->getWidth() + 5;
diff --git a/src/gui/connection.cpp b/src/gui/connection.cpp
index 8ad3b436..0f43ff14 100644
--- a/src/gui/connection.cpp
+++ b/src/gui/connection.cpp
@@ -30,6 +30,8 @@
#include "../main.h"
+#include "../utils/gettext.h"
+
namespace {
struct ConnectionActionListener : public gcn::ActionListener
{
@@ -42,9 +44,9 @@ ConnectionDialog::ConnectionDialog():
{
setContentSize(200, 100);
- Button *cancelButton = new Button("Cancel", "cancelButton", &listener);
+ Button *cancelButton = new Button(_("Cancel"), "cancelButton", &listener);
mProgressBar = new ProgressBar(0.0, 200 - 10, 20, 128, 128, 128);
- gcn::Label *label = new gcn::Label("Connecting...");
+ gcn::Label *label = new gcn::Label(_("Connecting..."));
cancelButton->setPosition(5, 100 - 5 - cancelButton->getHeight());
mProgressBar->setPosition(5, cancelButton->getY() - 25);
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 762ca8e8..f3a143be 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -31,10 +31,12 @@
#include "../resources/iteminfo.h"
#include "../resources/resourcemanager.h"
+#include "../utils/gettext.h"
#include "../utils/tostring.h"
EquipmentWindow::EquipmentWindow(Equipment *equipment):
- Window("Equipment"), mEquipment(equipment)
+ Window(_("Equipment")),
+ mEquipment(equipment)
{
setWindowName("Equipment");
setCloseButton(true);
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 0e1c5291..ac368aa7 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -39,10 +39,11 @@
#include "../resources/iteminfo.h"
-#include "../utils/tostring.h"
+#include "../utils/gettext.h"
+#include "../utils/strprintf.h"
InventoryWindow::InventoryWindow():
- Window("Inventory")
+ Window(_("Inventory"))
{
setWindowName("Inventory");
setResizable(true);
@@ -52,8 +53,8 @@ InventoryWindow::InventoryWindow():
// If you adjust these defaults, don't forget to adjust the trade window's.
setDefaultSize(115, 25, 322, 200);
- 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->getInventory());
mItems->addSelectionListener(this);
@@ -95,15 +96,14 @@ void InventoryWindow::logic()
updateButtons();
// Update weight information
- mWeightLabel->setCaption(
- "Weight: " + toString(player_node->mTotalWeight) +
- "/" + toString(player_node->mMaxWeight));
+ mWeightLabel->setCaption(strprintf(_("Weight: %d / %d"),
+ player_node->mTotalWeight,
+ player_node->mMaxWeight));
// Update number of items in inventory
- mInvenSlotLabel->setCaption(
- "Slots used: "
- + toString(player_node->getInventory()->getNumberOfSlotsUsed())
- + "/" + toString(player_node->getInventory()->getInventorySize()));
+ mInvenSlotLabel->setCaption(strprintf(_("Slots used: %d / %d"),
+ player_node->getInventory()->getNumberOfSlotsUsed(),
+ player_node->getInventory()->getInventorySize()));
}
void InventoryWindow::action(const gcn::ActionEvent &event)
@@ -145,20 +145,20 @@ void InventoryWindow::valueChanged(const gcn::SelectionEvent &event)
// Update name, effect and description
if (!item)
{
- mItemNameLabel->setCaption("Name:");
- mItemEffectLabel->setCaption("Effect:");
- mItemDescriptionLabel->setCaption("Description:");
+ mItemNameLabel->setCaption(strprintf(_("Name: %s"), ""));
+ mItemEffectLabel->setCaption(strprintf(_("Effect: %s"), ""));
+ mItemDescriptionLabel->setCaption(strprintf(_("Description: %s"), ""));
}
else
{
const ItemInfo& itemInfo = item->getInfo();
- std::string SomeText;
- SomeText = "Name: " + itemInfo.getName();
- mItemNameLabel->setCaption(SomeText);
- SomeText = "Effect: " + itemInfo.getEffect();
- mItemEffectLabel->setCaption(SomeText);
- SomeText = "Description: " + itemInfo.getDescription();
- mItemDescriptionLabel->setCaption(SomeText);
+ mItemNameLabel->setCaption(
+ strprintf(_("Name: %s"), itemInfo.getName().c_str()));
+ mItemEffectLabel->setCaption(
+ strprintf(_("Effect: %s"), itemInfo.getEffect().c_str()));
+ mItemDescriptionLabel->setCaption(
+ strprintf(_("Description: %s"),
+ itemInfo.getDescription().c_str()));
}
}
@@ -170,7 +170,8 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
{
Item *item = mItems->getSelectedItem();
- if (!item) return;
+ if (!item)
+ return;
/* Convert relative to the window coordinates to absolute screen
* coordinates.
@@ -221,14 +222,14 @@ void InventoryWindow::updateButtons()
if (selectedItem && selectedItem->isEquipment())
{
if (selectedItem->isEquipped()) {
- mUseButton->setCaption("Unequip");
+ mUseButton->setCaption(_("Unequip"));
}
else {
- mUseButton->setCaption("Equip");
+ mUseButton->setCaption(_("Equip"));
}
}
else {
- mUseButton->setCaption("Use");
+ mUseButton->setCaption(_("Use"));
}
mUseButton->setEnabled(selectedItem != 0);
diff --git a/src/gui/item_amount.cpp b/src/gui/item_amount.cpp
index 2e8941e8..064c8f93 100644
--- a/src/gui/item_amount.cpp
+++ b/src/gui/item_amount.cpp
@@ -29,31 +29,33 @@
#include "../item.h"
#include "../localplayer.h"
+#include "../utils/gettext.h"
+
ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item):
- Window("Select amount of items to drop.", true, parent),
+ Window("", true, parent),
mItem(item)
{
- // New labels
+ // Integer field
mItemAmountTextBox = new IntTextBox(1);
-
- // New buttons
- Button *minusButton = new Button("-", "Minus", this);
- Button *plusButton = new Button("+", "Plus", this);
- Button *okButton = new Button("Okay", "Drop", this);
- Button *cancelButton = new Button("Cancel", "Cancel", this);
- mItemAmountSlide = new Slider(1.0, mItem->getQuantity());
-
mItemAmountTextBox->setRange(1, mItem->getQuantity());
- mItemAmountSlide->setDimension(gcn::Rectangle(5, 120, 180, 10));
- // Set button events Id
+ // Slider
+ mItemAmountSlide = new Slider(1.0, mItem->getQuantity());
mItemAmountSlide->setActionEventId("Slide");
+ mItemAmountSlide->addActionListener(this);
+
+ // Buttons
+ Button *minusButton = new Button("-", "Minus", this);
+ Button *plusButton = new Button("+", "Plus", this);
+ Button *okButton = new Button(_("Ok"), "Drop", this);
+ Button *cancelButton = new Button(_("Cancel"), "Cancel", this);
- // Set position
+ // Set positions
mItemAmountTextBox->setPosition(35, 10);
mItemAmountTextBox->setSize(24, 16);
plusButton->setPosition(60, 5);
minusButton->setPosition(10, 5);
+ mItemAmountSlide->setDimension(gcn::Rectangle(5, 120, 180, 10));
mItemAmountSlide->setPosition(10, 35);
okButton->setPosition(10, 50);
cancelButton->setPosition(60, 50);
@@ -66,17 +68,15 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item):
add(okButton);
add(cancelButton);
- mItemAmountSlide->addActionListener(this);
-
resetAmount();
switch (usage) {
case AMOUNT_TRADE_ADD:
- setCaption("Select amount of items to trade.");
+ setCaption(_("Select amount of items to trade."));
okButton->setActionEventId("AddTrade");
break;
case AMOUNT_ITEM_DROP:
- setCaption("Select amount of items to drop.");
+ setCaption(_("Select amount of items to drop."));
okButton->setActionEventId("Drop");
break;
default:
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index 06a5f9f0..5a748b52 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -34,21 +34,23 @@
#include "passwordfield.h"
#include "textfield.h"
+#include "../utils/gettext.h"
+
LoginDialog::LoginDialog(LoginData *loginData):
- Window("Login"), mLoginData(loginData)
+ Window(_("Login")), mLoginData(loginData)
{
- gcn::Label *userLabel = new gcn::Label("Name:");
- gcn::Label *passLabel = new gcn::Label("Password:");
- gcn::Label *serverLabel = new gcn::Label("Server:");
+ gcn::Label *userLabel = new gcn::Label(_("Name:"));
+ gcn::Label *passLabel = new gcn::Label(_("Password:"));
+ gcn::Label *serverLabel = new gcn::Label(_("Server:"));
mUserField = new TextField(mLoginData->username);
mPassField = new PasswordField(mLoginData->password);
mServerField = new TextField(mLoginData->hostname);
- mKeepCheck = new CheckBox("Keep", mLoginData->remember);
- mOkButton = new Button("OK", "ok", this);
- mCancelButton = new Button("Cancel", "cancel", this);
- mRegisterButton = new Button("Register", "register", this);
+ mKeepCheck = new CheckBox(_("Remember Username"), mLoginData->remember);
+ mOkButton = new Button(_("Ok"), "ok", this);
+ mCancelButton = new Button(_("Cancel"), "cancel", this);
+ mRegisterButton = new Button(_("Register"), "register", this);
- const int width = 220;
+ const int width = 250;
const int height = 100;
setContentSize(width, height);
diff --git a/src/gui/menuwindow.cpp b/src/gui/menuwindow.cpp
index 3c3e4ab8..0893cb1c 100644
--- a/src/gui/menuwindow.cpp
+++ b/src/gui/menuwindow.cpp
@@ -28,6 +28,8 @@
#include "button.h"
#include "windowcontainer.h"
+#include "../utils/gettext.h"
+
extern Window *setupWindow;
extern Window *inventoryWindow;
extern Window *equipmentWindow;
@@ -54,21 +56,21 @@ MenuWindow::MenuWindow():
setTitleBarHeight(0);
// Buttons
- const char *buttonNames[] =
+ static const char *buttonNames[] =
{
- "Status",
- "Equipment",
- "Inventory",
- "Skills",
- "Shortcut",
- "Setup",
+ N_("Status"),
+ N_("Equipment"),
+ N_("Inventory"),
+ N_("Skills"),
+ N_("Shortcut"),
+ N_("Setup"),
0
};
int x = 0, h = 0;
for (const char **curBtn = buttonNames; *curBtn; curBtn++)
{
- gcn::Button *btn = new Button(*curBtn, *curBtn, &listener);
+ gcn::Button *btn = new Button(gettext(*curBtn), *curBtn, &listener);
btn->setPosition(x, 0);
add(btn);
x += btn->getWidth() + 3;
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index 231c749f..55132d6d 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -28,8 +28,10 @@
#include "../resources/image.h"
+#include "../utils/gettext.h"
+
Minimap::Minimap():
- Window("Map"),
+ Window(_("MiniMap")),
mMapImage(NULL)
{
setWindowName("MiniMap");
diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp
index 34c9cce1..c9ace303 100644
--- a/src/gui/npc_text.cpp
+++ b/src/gui/npc_text.cpp
@@ -29,8 +29,10 @@
#include "../npc.h"
+#include "../utils/gettext.h"
+
NpcTextDialog::NpcTextDialog():
- Window("NPC")
+ Window(_("NPC"))
{
setResizable(true);
@@ -41,7 +43,7 @@ NpcTextDialog::NpcTextDialog():
mTextBox->setEditable(false);
scrollArea = new ScrollArea(mTextBox);
- okButton = new Button("OK", "ok", this);
+ okButton = new Button(_("OK"), "ok", this);
setContentSize(260, 175);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp
index cdd38312..bff6994d 100644
--- a/src/gui/npclistdialog.cpp
+++ b/src/gui/npclistdialog.cpp
@@ -29,8 +29,10 @@
#include "../npc.h"
+#include "../utils/gettext.h"
+
NpcListDialog::NpcListDialog():
- Window("NPC")
+ Window(_("NPC"))
{
setResizable(true);
@@ -39,8 +41,8 @@ NpcListDialog::NpcListDialog():
mItemList = new ListBox(this);
scrollArea = new ScrollArea(mItemList);
- okButton = new Button("OK", "ok", this);
- cancelButton = new Button("Cancel", "cancel", this);
+ okButton = new Button(_("OK"), "ok", this);
+ cancelButton = new Button(_("Cancel"), "cancel", this);
setContentSize(260, 175);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
diff --git a/src/gui/ok_dialog.cpp b/src/gui/ok_dialog.cpp
index d43c8e69..9db3cd7b 100644
--- a/src/gui/ok_dialog.cpp
+++ b/src/gui/ok_dialog.cpp
@@ -24,6 +24,8 @@
#include "button.h"
#include "scrollarea.h"
+#include "../utils/gettext.h"
+
OkDialog::OkDialog(const std::string &title, const std::string &msg,
Window *parent):
Window(title, true, parent)
@@ -32,7 +34,7 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg,
textBox->setEditable(false);
gcn::ScrollArea *scrollArea = new ScrollArea(textBox);
- gcn::Button *okButton = new Button("Ok", "ok", this);
+ gcn::Button *okButton = new Button(_("Ok"), "ok", this);
setContentSize(260, 175);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 07719d2c..bfa75ef9 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -42,6 +42,9 @@
#include "../resources/iteminfo.h"
#include "../resources/itemdb.h"
+#include "../utils/gettext.h"
+#include "../utils/strprintf.h"
+
extern std::string tradePartnerName;
PopupMenu::PopupMenu():
@@ -74,8 +77,10 @@ void PopupMenu::showPopup(int x, int y, Being *being)
// Players can be traded with. Later also attack, follow and
// add as buddy will be options in this menu.
const std::string &name = being->getName();
- mBrowserBox->addRow("@@trade|Trade With " + name + "@@");
- mBrowserBox->addRow("@@attack|Attack " + name + "@@");
+ mBrowserBox->addRow(
+ strprintf(_("@@trade|Trade With %s@@"), name.c_str()));
+ mBrowserBox->addRow(
+ strprintf(_("@@attack|Attack %s@@"), name.c_str()));
mBrowserBox->addRow("##3---");
@@ -106,7 +111,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
case Being::NPC:
// NPCs can be talked to (single option, candidate for removal
// unless more options would be added)
- mBrowserBox->addRow("@@talk|Talk To NPC@@");
+ mBrowserBox->addRow(_("@@talk|Talk To NPC@@"));
break;
default:
@@ -116,7 +121,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
//browserBox->addRow("@@look|Look To@@");
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow("@@cancel|Cancel@@");
+ mBrowserBox->addRow(_("@@cancel|Cancel@@"));
showPopup(x, y);
}
@@ -128,11 +133,11 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
// Floor item can be picked up (single option, candidate for removal)
std::string name = ItemDB::get(mFloorItem->getItemId()).getName();
- mBrowserBox->addRow("@@pickup|Pick Up " + name + "@@");
+ mBrowserBox->addRow(strprintf(_("@@pickup|Pick Up %s@@"), name.c_str()));
//browserBox->addRow("@@look|Look To@@");
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow("@@cancel|Cancel@@");
+ mBrowserBox->addRow(_("@@cancel|Cancel@@"));
showPopup(x, y);
}
@@ -275,17 +280,17 @@ void PopupMenu::showPopup(int x, int y, Item *item)
if (item->isEquipment())
{
if (item->isEquipped())
- mBrowserBox->addRow("@@use|Unequip@@");
+ mBrowserBox->addRow(_("@@use|Unequip@@"));
else
- mBrowserBox->addRow("@@use|Equip@@");
+ mBrowserBox->addRow(_("@@use|Equip@@"));
}
else
- mBrowserBox->addRow("@@use|Use@@");
+ mBrowserBox->addRow(_("@@use|Use@@"));
- mBrowserBox->addRow("@@drop|Drop@@");
- mBrowserBox->addRow("@@description|Description@@");
+ mBrowserBox->addRow(_("@@drop|Drop@@"));
+ mBrowserBox->addRow(_("@@description|Description@@"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow("@@cancel|Cancel@@");
+ mBrowserBox->addRow(_("@@cancel|Cancel@@"));
showPopup(x, y);
}
diff --git a/src/gui/register.cpp b/src/gui/register.cpp
index 2a97a3e5..ce36efa2 100644
--- a/src/gui/register.cpp
+++ b/src/gui/register.cpp
@@ -39,6 +39,9 @@
#include "textfield.h"
#include "ok_dialog.h"
+#include "../utils/gettext.h"
+#include "../utils/strprintf.h"
+
void
WrongDataNoticeListener::setTarget(gcn::TextField *textField)
{
@@ -59,18 +62,18 @@ RegisterDialog::RegisterDialog(LoginData *loginData):
mWrongDataNoticeListener(new WrongDataNoticeListener()),
mLoginData(loginData)
{
- gcn::Label *userLabel = new gcn::Label("Name:");
- gcn::Label *passwordLabel = new gcn::Label("Password:");
- gcn::Label *confirmLabel = new gcn::Label("Confirm:");
- gcn::Label *serverLabel = new gcn::Label("Server:");
+ gcn::Label *userLabel = new gcn::Label(_("Name:"));
+ gcn::Label *passwordLabel = new gcn::Label(_("Password:"));
+ gcn::Label *confirmLabel = new gcn::Label(_("Confirm:"));
+ gcn::Label *serverLabel = new gcn::Label(_("Server:"));
mUserField = new TextField(loginData->username);
mPasswordField = new PasswordField(loginData->password);
mConfirmField = new PasswordField();
mServerField = new TextField(loginData->hostname);
- mMaleButton = new RadioButton("Male", "sex", true);
- mFemaleButton = new RadioButton("Female", "sex", false);
- mRegisterButton = new Button("Register", "register", this);
- mCancelButton = new Button("Cancel", "cancel", this);
+ mMaleButton = new RadioButton(_("Male"), "sex", true);
+ mFemaleButton = new RadioButton(_("Female"), "sex", false);
+ mRegisterButton = new Button(_("Register"), "register", this);
+ mCancelButton = new Button(_("Cancel"), "cancel", this);
const int width = 220;
const int height = 150;
@@ -163,45 +166,45 @@ RegisterDialog::action(const gcn::ActionEvent &event)
const std::string user = mUserField->getText();
logger->log("RegisterDialog::register Username is %s", user.c_str());
- std::stringstream errorMsg;
+ std::string errorMsg;
int error = 0;
if (user.length() < LEN_MIN_USERNAME)
{
// Name too short
- errorMsg << "The username needs to be at least "
- << LEN_MIN_USERNAME
- << " characters long.";
+ errorMsg = strprintf
+ (_("The username needs to be at least %d characters long."),
+ LEN_MIN_USERNAME);
error = 1;
}
else if (user.length() > LEN_MAX_USERNAME - 1 )
{
// Name too long
- errorMsg << "The username needs to be less than "
- << LEN_MAX_USERNAME
- << " characters long.";
+ errorMsg = strprintf
+ (_("The username needs to be less than %d characters long."),
+ LEN_MAX_USERNAME);
error = 1;
}
else if (mPasswordField->getText().length() < LEN_MIN_PASSWORD)
{
// Pass too short
- errorMsg << "The password needs to be at least "
- << LEN_MIN_PASSWORD
- << " characters long.";
+ errorMsg = strprintf
+ (_("The password needs to be at least %d characters long."),
+ LEN_MIN_PASSWORD);
error = 2;
}
else if (mPasswordField->getText().length() > LEN_MAX_PASSWORD - 1 )
{
// Pass too long
- errorMsg << "The password needs to be less than "
- << LEN_MAX_PASSWORD
- << " characters long.";
+ errorMsg = strprintf
+ (_("The password needs to be less than %d characters long."),
+ LEN_MAX_PASSWORD);
error = 2;
}
else if (mPasswordField->getText() != mConfirmField->getText())
{
// Password does not match with the confirmation one
- errorMsg << "Passwords do not match.";
+ errorMsg = _("Passwords do not match.");
error = 2;
}
@@ -220,8 +223,8 @@ RegisterDialog::action(const gcn::ActionEvent &event)
mWrongDataNoticeListener->setTarget(this->mPasswordField);
}
- OkDialog *mWrongRegisterNotice = new OkDialog("Error",
- errorMsg.str());
+ OkDialog *mWrongRegisterNotice =
+ new OkDialog(_("Error"), errorMsg);
mWrongRegisterNotice->addActionListener(mWrongDataNoticeListener);
}
else
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index 6df1cbf6..7a2e94c6 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -39,10 +39,11 @@
#include "../net/messageout.h"
#include "../net/protocol.h"
-#include "../utils/tostring.h"
+#include "../utils/gettext.h"
+#include "../utils/strprintf.h"
SellDialog::SellDialog(Network *network):
- Window("Sell"),
+ Window(_("Sell")),
mNetwork(network),
mMaxItems(0), mAmountItems(0)
{
@@ -58,13 +59,14 @@ SellDialog::SellDialog(Network *network):
mScrollArea = new ScrollArea(mShopItemList);
mSlider = new Slider(1.0);
mQuantityLabel = new gcn::Label("0");
- mMoneyLabel = new gcn::Label("Money: 0 GP / Total: 0 GP");
+ mMoneyLabel = new gcn::Label(
+ strprintf(_("Price: %d GP / Total: %d GP"), 0, 0));
mIncreaseButton = new Button("+", "+", this);
mDecreaseButton = new Button("-", "-", this);
- mSellButton = new Button("Sell", "sell", this);
- mQuitButton = new Button("Quit", "quit", this);
- mItemDescLabel = new gcn::Label("Description:");
- mItemEffectLabel = new gcn::Label("Effect:");
+ mSellButton = new Button(_("Sell"), "sell", this);
+ mQuitButton = new Button(_("Quit"), "quit", this);
+ mItemDescLabel = new gcn::Label(strprintf(_("Description: %s"), ""));
+ mItemEffectLabel = new gcn::Label(strprintf(_("Effect: %s"), ""));
mIncreaseButton->setSize(20, 20);
mDecreaseButton->setSize(20, 20);
@@ -261,14 +263,19 @@ void SellDialog::setMoney(int amount)
mShopItemList->setPlayersMoney(amount);
}
-void
-SellDialog::updateButtonsAndLabels()
+void SellDialog::updateButtonsAndLabels()
{
int selectedItem = mShopItemList->getSelected();
int income = 0;
if (selectedItem > -1)
{
+ const ItemInfo &info = mShopItems->at(selectedItem)->getInfo();
+ mItemDescLabel->setCaption
+ (strprintf(_("Description: %s"), info.getDescription().c_str()));
+ mItemEffectLabel->setCaption
+ (strprintf(_("Effect: %s"), info.getEffect().c_str()));
+
mMaxItems = mShopItems->at(selectedItem)->getQuantity();
if (mAmountItems > mMaxItems)
{
@@ -276,17 +283,13 @@ SellDialog::updateButtonsAndLabels()
}
income = mAmountItems * mShopItems->at(selectedItem)->getPrice();
-
- const ItemInfo &info = mShopItems->at(selectedItem)->getInfo();
- mItemDescLabel->setCaption("Description: " + info.getDescription());
- mItemEffectLabel->setCaption("Effect: " + info.getEffect());
}
else
{
+ mItemDescLabel->setCaption(strprintf(_("Description: %s"), ""));
+ mItemEffectLabel->setCaption(strprintf(_("Effect: %s"), ""));
mMaxItems = 0;
mAmountItems = 0;
- mItemDescLabel->setCaption("Description:");
- mItemEffectLabel->setCaption("Effect:");
}
// Update Buttons and slider
@@ -296,8 +299,8 @@ SellDialog::updateButtonsAndLabels()
mSlider->setEnabled(mMaxItems > 1);
// Update the quantity and money labels
- mQuantityLabel->setCaption(
- toString(mAmountItems) + " / " + toString(mMaxItems));
- mMoneyLabel->setCaption("Money: " + toString(income) + " GP / Total: "
- + toString(mPlayerMoney + income) + " GP");
+ mQuantityLabel->setCaption(strprintf("%d / %d", mAmountItems, mMaxItems));
+ mMoneyLabel->setCaption
+ (strprintf(_("Price: %d GP / Total: %d GP"),
+ income, mPlayerMoney + income));
}
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index 2da9d1b5..067d8d64 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -32,6 +32,8 @@
#include "tabbedcontainer.h"
#include "../utils/dtor.h"
+#include "../utils/gettext.h"
+
#include <iostream>
extern Window *statusWindow;
@@ -52,12 +54,12 @@ Setup::Setup():
int height = 265;
setContentSize(width, height);
- const char *buttonNames[] = {
- "Apply", "Cancel", "Reset Windows", 0
+ static const char *buttonNames[] = {
+ N_("Apply"), N_("Cancel"), N_("Reset Windows"), 0
};
int x = width;
for (const char **curBtn = buttonNames; *curBtn; ++curBtn) {
- Button *btn = new Button(*curBtn, *curBtn, this);
+ Button *btn = new Button(gettext(*curBtn), *curBtn, this);
x -= btn->getWidth() + 5;
btn->setPosition(x, height - btn->getHeight() - 5);
add(btn);
@@ -74,23 +76,23 @@ Setup::Setup():
SetupTab *tab;
tab = new Setup_Video();
- panel->addTab(tab, "Video");
+ panel->addTab(tab, _("Video"));
mTabs.push_back(tab);
tab = new Setup_Audio();
- panel->addTab(tab, "Audio");
+ panel->addTab(tab, _("Audio"));
mTabs.push_back(tab);
tab = new Setup_Joystick();
- panel->addTab(tab, "Joystick");
+ panel->addTab(tab, _("Joystick"));
mTabs.push_back(tab);
tab = new Setup_Keyboard();
- panel->addTab(tab, "Keyboard");
+ panel->addTab(tab, _("Keyboard"));
mTabs.push_back(tab);
tab = new Setup_Players();
- panel->addTab(tab, "Players");
+ panel->addTab(tab, _("Players"));
mTabs.push_back(tab);
add(panel);
diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp
index a027e133..c595edc9 100644
--- a/src/gui/setup_audio.cpp
+++ b/src/gui/setup_audio.cpp
@@ -31,18 +31,20 @@
#include "../log.h"
#include "../sound.h"
+#include "../utils/gettext.h"
+
Setup_Audio::Setup_Audio():
mMusicVolume((int)config.getValue("musicVolume", 60)),
mSfxVolume((int)config.getValue("sfxVolume", 100)),
mSoundEnabled(config.getValue("sound", 0)),
- mSoundCheckBox(new CheckBox("Sound", mSoundEnabled)),
+ mSoundCheckBox(new CheckBox(_("Sound"), mSoundEnabled)),
mSfxSlider(new Slider(0, 128)),
mMusicSlider(new Slider(0, 128))
{
setOpaque(false);
- gcn::Label *sfxLabel = new gcn::Label("Sfx volume");
- gcn::Label *musicLabel = new gcn::Label("Music volume");
+ gcn::Label *sfxLabel = new gcn::Label(_("Sfx volume"));
+ gcn::Label *musicLabel = new gcn::Label(_("Music volume"));
mSfxSlider->setActionEventId("sfx");
mMusicSlider->setActionEventId("music");
diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp
index c59068f7..a718f87e 100644
--- a/src/gui/setup_joystick.cpp
+++ b/src/gui/setup_joystick.cpp
@@ -28,12 +28,14 @@
#include "../configuration.h"
#include "../joystick.h"
+#include "../utils/gettext.h"
+
extern Joystick *joystick;
Setup_Joystick::Setup_Joystick():
- mCalibrateLabel(new gcn::Label("Press the button to start calibration")),
- mCalibrateButton(new Button("Calibrate", "calibrate", this)),
- mJoystickEnabled(new CheckBox("Enable joystick"))
+ mCalibrateLabel(new gcn::Label(_("Press the button to start calibration"))),
+ mCalibrateButton(new Button(_("Calibrate"), "calibrate", this)),
+ mJoystickEnabled(new CheckBox(_("Enable joystick")))
{
setOpaque(false);
mJoystickEnabled->setPosition(10, 10);
@@ -63,13 +65,13 @@ void Setup_Joystick::action(const gcn::ActionEvent &event)
else
{
if (joystick->isCalibrating()) {
- mCalibrateButton->setCaption("Calibrate");
- mCalibrateLabel->setCaption(
- "Press the button to start calibration");
+ mCalibrateButton->setCaption(_("Calibrate"));
+ mCalibrateLabel->setCaption
+ (_("Press the button to start calibration"));
joystick->finishCalibration();
} else {
- mCalibrateButton->setCaption("Stop");
- mCalibrateLabel->setCaption("Rotate the stick");
+ mCalibrateButton->setCaption(_("Stop"));
+ mCalibrateLabel->setCaption(_("Rotate the stick"));
joystick->startCalibration();
}
}
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 54169b63..0debe163 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -43,6 +43,7 @@
#include "../main.h"
#include "../particle.h"
+#include "../utils/gettext.h"
#include "../utils/tostring.h"
extern Graphics *graphics;
@@ -108,11 +109,11 @@ Setup_Video::Setup_Video():
mFps((int) config.getValue("fpslimit", 0)),
mModeListModel(new ModeListModel),
mModeList(new ListBox(mModeListModel)),
- mFsCheckBox(new CheckBox("Full screen", mFullScreenEnabled)),
- mOpenGLCheckBox(new CheckBox("OpenGL", mOpenGLEnabled)),
- mCustomCursorCheckBox(new CheckBox("Custom cursor", mCustomCursorEnabled)),
+ mFsCheckBox(new CheckBox(_("Full screen"), mFullScreenEnabled)),
+ mOpenGLCheckBox(new CheckBox(_("OpenGL"), mOpenGLEnabled)),
+ mCustomCursorCheckBox(new CheckBox(_("Custom cursor"), mCustomCursorEnabled)),
mAlphaSlider(new Slider(0.2, 1.0)),
- mFpsCheckBox(new CheckBox("FPS Limit: ")),
+ mFpsCheckBox(new CheckBox(_("FPS Limit:"))),
mFpsSlider(new Slider(10, 200)),
mFpsField(new TextField),
mOriginalScrollLaziness((int) config.getValue("ScrollLaziness", 16)),
@@ -131,7 +132,7 @@ Setup_Video::Setup_Video():
setOpaque(false);
ScrollArea *scrollArea = new ScrollArea(mModeList);
- gcn::Label *alphaLabel = new gcn::Label("Gui opacity");
+ gcn::Label *alphaLabel = new gcn::Label(_("Gui opacity"));
mModeList->setEnabled(false);
#ifndef USE_OPENGL
@@ -188,7 +189,7 @@ Setup_Video::Setup_Video():
mParticleDetailField->addKeyListener(this);
mScrollRadiusSlider->setDimension(gcn::Rectangle(10, 120, 75, 10));
- gcn::Label *scrollRadiusLabel = new gcn::Label("Scroll radius");
+ gcn::Label *scrollRadiusLabel = new gcn::Label(_("Scroll radius"));
scrollRadiusLabel->setPosition(90, 120);
mScrollRadiusField->setPosition(mFpsField->getX(), 120);
mScrollRadiusField->setWidth(30);
@@ -196,7 +197,7 @@ Setup_Video::Setup_Video():
mScrollRadiusSlider->setValue(mOriginalScrollRadius);
mScrollLazinessSlider->setDimension(gcn::Rectangle(10, 140, 75, 10));
- gcn::Label *scrollLazinessLabel = new gcn::Label("Scroll laziness");
+ gcn::Label *scrollLazinessLabel = new gcn::Label(_("Scroll laziness"));
scrollLazinessLabel->setPosition(90, 140);
mScrollLazinessField->setPosition(mFpsField->getX(), 140);
mScrollLazinessField->setWidth(30);
@@ -204,42 +205,42 @@ Setup_Video::Setup_Video():
mScrollLazinessSlider->setValue(mOriginalScrollLaziness);
mOverlayDetailSlider->setDimension(gcn::Rectangle(10, 160, 75, 10));
- gcn::Label *overlayDetailLabel = new gcn::Label("Ambient FX");
+ gcn::Label *overlayDetailLabel = new gcn::Label(_("Ambient FX"));
overlayDetailLabel->setPosition(90, 160);
mOverlayDetailField->setPosition(180, 160);
mOverlayDetailField->setWidth(30);
switch (mOverlayDetail)
{
case 0:
- mOverlayDetailField->setCaption("off");
+ mOverlayDetailField->setCaption(_("off"));
break;
case 1:
- mOverlayDetailField->setCaption("low");
+ mOverlayDetailField->setCaption(_("low"));
break;
case 2:
- mOverlayDetailField->setCaption("high");
+ mOverlayDetailField->setCaption(_("high"));
break;
}
mOverlayDetailSlider->setValue(mOverlayDetail);
mParticleDetailSlider->setDimension(gcn::Rectangle(10, 180, 75, 10));
- gcn::Label *particleDetailLabel = new gcn::Label("Particle Detail");
+ gcn::Label *particleDetailLabel = new gcn::Label(_("Particle Detail"));
particleDetailLabel->setPosition(90, 180);
mParticleDetailField->setPosition(180, 180);
mParticleDetailField->setWidth(60);
switch (mParticleDetail)
{
case 0:
- mParticleDetailField->setCaption("low");
+ mParticleDetailField->setCaption(_("low"));
break;
case 1:
- mParticleDetailField->setCaption("medium");
+ mParticleDetailField->setCaption(_("medium"));
break;
case 2:
- mParticleDetailField->setCaption("high");
+ mParticleDetailField->setCaption(_("high"));
break;
case 3:
- mParticleDetailField->setCaption("max");
+ mParticleDetailField->setCaption(_("max"));
break;
}
mParticleDetailSlider->setValue(mParticleDetail);
@@ -305,8 +306,8 @@ void Setup_Video::apply()
}
#ifdef WIN32
} else {
- new OkDialog("Switching to full screen",
- "Restart needed for changes to take effect.");
+ new OkDialog(_("Switching to full screen"),
+ _("Restart needed for changes to take effect."));
}
#endif
config.setValue("screen", fullscreen ? 1 : 0);
@@ -318,8 +319,8 @@ void Setup_Video::apply()
config.setValue("opengl", mOpenGLCheckBox->isSelected() ? 1 : 0);
// OpenGL can currently only be changed by restarting, notify user.
- new OkDialog("Changing OpenGL",
- "Applying change to OpenGL requires restart.");
+ new OkDialog(_("Changing OpenGL"),
+ _("Applying change to OpenGL requires restart."));
}
// FPS change
@@ -408,13 +409,13 @@ void Setup_Video::action(const gcn::ActionEvent &event)
switch (val)
{
case 0:
- mOverlayDetailField->setCaption("off");
+ mOverlayDetailField->setCaption(_("off"));
break;
case 1:
- mOverlayDetailField->setCaption("low");
+ mOverlayDetailField->setCaption(_("low"));
break;
case 2:
- mOverlayDetailField->setCaption("high");
+ mOverlayDetailField->setCaption(_("high"));
break;
}
config.setValue("OverlayDetail", val);
@@ -425,16 +426,16 @@ void Setup_Video::action(const gcn::ActionEvent &event)
switch (val)
{
case 0:
- mParticleDetailField->setCaption("low");
+ mParticleDetailField->setCaption(_("low"));
break;
case 1:
- mParticleDetailField->setCaption("medium");
+ mParticleDetailField->setCaption(_("medium"));
break;
case 2:
- mParticleDetailField->setCaption("high");
+ mParticleDetailField->setCaption(_("high"));
break;
case 3:
- mParticleDetailField->setCaption("max");
+ mParticleDetailField->setCaption(_("max"));
break;
}
config.setValue("particleEmitterSkip", 3 - val);
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index 9347cc02..9b88b6fb 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -41,6 +41,8 @@
#include "../resources/iteminfo.h"
+#include "../utils/gettext.h"
+#include "../utils/strprintf.h"
#include "../utils/tostring.h"
TradeWindow::TradeWindow(Network *network):
@@ -56,10 +58,10 @@ TradeWindow::TradeWindow(Network *network):
setMinWidth(342);
setMinHeight(209);
- mAddButton = new Button("Add", "add", this);
- mOkButton = new Button("Ok", "ok", this);
- mCancelButton = new Button("Cancel", "cancel", this);
- mTradeButton = new Button("Trade", "trade", this);
+ mAddButton = new Button(_("Add"), "add", this);
+ mOkButton = new Button(_("Ok"), "ok", this);
+ mCancelButton = new Button(_("Cancel"), "cancel", this);
+ mTradeButton = new Button(_("Trade"), "trade", this);
mMyItemContainer = new ItemContainer(mMyInventory.get());
mMyItemContainer->addSelectionListener(this);
@@ -75,8 +77,8 @@ TradeWindow::TradeWindow(Network *network):
mPartnerScroll = new ScrollArea(mPartnerItemContainer);
mPartnerScroll->setPosition(8, 64);
- mMoneyLabel = new gcn::Label("You get: 0 GP");
- mMoneyLabel2 = new gcn::Label("You give:");
+ mMoneyLabel = new gcn::Label(strprintf(_("You get %d GP."), 0));
+ mMoneyLabel2 = new gcn::Label(_("You give:"));
mMoneyField = new TextField;
mMoneyField->setWidth(50);
@@ -87,8 +89,9 @@ TradeWindow::TradeWindow(Network *network):
mTradeButton->setEnabled(false);
- mItemNameLabel = new gcn::Label("Name:");
- mItemDescriptionLabel = new gcn::Label("Description:");
+ mItemNameLabel = new gcn::Label(strprintf(_("Name: %s"), ""));
+ mItemDescriptionLabel = new gcn::Label(
+ strprintf(_("Description: %s"), ""));
add(mMyScroll);
add(mPartnerScroll);
@@ -150,7 +153,7 @@ void TradeWindow::widgetResized(const gcn::Event &event)
void TradeWindow::addMoney(int amount)
{
- mMoneyLabel->setCaption("You get: " + toString(amount) + " GP");
+ mMoneyLabel->setCaption(strprintf(_("You get %d GP."), amount));
mMoneyLabel->adjustSize();
}
@@ -198,7 +201,7 @@ void TradeWindow::reset()
mOkButton->setEnabled(true);
mOkOther = false;
mOkMe = false;
- mMoneyLabel->setCaption("You get: 0 GP");
+ mMoneyLabel->setCaption(strprintf(_("You get %d GP."), 0));
mMoneyField->setEnabled(true);
mMoneyField->setText("");
}
@@ -257,21 +260,11 @@ void TradeWindow::valueChanged(const gcn::SelectionEvent &event)
}
// Update name and description
- if (!item)
- {
- mItemNameLabel->setCaption("Name:");
- mItemDescriptionLabel->setCaption("Description:");
- }
- else
- {
- std::string SomeText;
- SomeText = "Name: " + item->getInfo().getName();
- mItemNameLabel->setCaption(SomeText);
- mItemNameLabel->adjustSize();
- SomeText = "Description: " + item->getInfo().getDescription();
- mItemDescriptionLabel->setCaption(SomeText);
- mItemDescriptionLabel->adjustSize();
- }
+ ItemInfo const *info = item ? &item->getInfo() : NULL;
+ mItemNameLabel->setCaption(strprintf(_("Name: %s"),
+ info ? info->getName().c_str() : ""));
+ mItemDescriptionLabel->setCaption(strprintf(_("Description: %s"),
+ info ? info->getDescription().c_str() : ""));
}
void TradeWindow::action(const gcn::ActionEvent &event)
diff --git a/src/main.cpp b/src/main.cpp
index 83686749..09a1a41d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -84,6 +84,7 @@
#include "resources/resourcemanager.h"
#include "utils/dtor.h"
+#include "utils/gettext.h"
#include "utils/tostring.h"
namespace {
@@ -267,7 +268,7 @@ void init_engine(const Options &options)
// Add the user's homedir to PhysicsFS search path
resman->addToSearchPath(homeDir, false);
- // Add the main data directory to our PhysicsFS search path
+ // Add the main data directories to our PhysicsFS search path
if (!options.dataPath.empty()) {
resman->addToSearchPath(options.dataPath, true);
}
@@ -646,6 +647,7 @@ void mapLogin(Network *network, LoginData *loginData)
} // namespace
+extern "C" char const *_nl_locale_name_default(void);
/** Main */
int main(int argc, char *argv[])
@@ -666,6 +668,16 @@ int main(int argc, char *argv[])
printVersion();
return 0;
}
+
+#if ENABLE_NLS
+#ifdef WIN32
+ putenv(("LANG=" + std::string(_nl_locale_name_default())).c_str());
+#endif
+ setlocale(LC_MESSAGES, "");
+ bindtextdomain("tmw", LOCALEDIR);
+ textdomain("tmw");
+#endif
+
// Initialize libxml2 and check for potential ABI mismatches between
// compiled version and the shared library actually used.
xmlInitParser();
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 8fd60110..4b3024a7 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -30,6 +30,7 @@
#include "../log.h"
#include "../utils/dtor.h"
+#include "../utils/gettext.h"
#include "../utils/xml.h"
namespace
@@ -93,9 +94,9 @@ void ItemDB::load()
if (id)
{
- ItemInfo *itemInfo = new ItemInfo();
+ ItemInfo *itemInfo = new ItemInfo;
itemInfo->setImageName(image);
- itemInfo->setName((name == "") ? "Unnamed" : name);
+ itemInfo->setName(name.empty() ? _("Unnamed") : name);
itemInfo->setDescription(description);
itemInfo->setEffect(effect);
itemInfo->setType(type);
diff --git a/src/utils/gettext.h b/src/utils/gettext.h
new file mode 100644
index 00000000..0cd9114b
--- /dev/null
+++ b/src/utils/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
+ */
+
+#ifndef _TMW_UTILS_GETTEXT_H
+#define _TMW_UTILS_GETTEXT_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#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