diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-07 07:54:13 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-07 07:54:13 +0000 |
commit | c09825097c0231c57f9ac416fae0003c5d68398c (patch) | |
tree | b5c4d8cb200e6382ffae66d5b1d98a5f22aabe60 | |
parent | 1389fc06cc578bdddd6d92cf3a239e33bb892026 (diff) | |
download | mana-c09825097c0231c57f9ac416fae0003c5d68398c.tar.gz mana-c09825097c0231c57f9ac416fae0003c5d68398c.tar.bz2 mana-c09825097c0231c57f9ac416fae0003c5d68398c.tar.xz mana-c09825097c0231c57f9ac416fae0003c5d68398c.zip |
Marked most of the GUI as translatable.
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | po/Makevars | 4 | ||||
-rw-r--r-- | src/gui/char_select.cpp | 82 | ||||
-rw-r--r-- | src/gui/confirm_dialog.cpp | 5 | ||||
-rw-r--r-- | src/gui/connection.cpp | 6 | ||||
-rw-r--r-- | src/gui/equipmentwindow.cpp | 5 | ||||
-rw-r--r-- | src/gui/item_amount.cpp | 12 | ||||
-rw-r--r-- | src/gui/login.cpp | 16 | ||||
-rw-r--r-- | src/gui/menuwindow.cpp | 19 | ||||
-rw-r--r-- | src/gui/minimap.cpp | 5 | ||||
-rw-r--r-- | src/gui/ministatus.cpp | 3 | ||||
-rw-r--r-- | src/gui/npc_text.cpp | 6 | ||||
-rw-r--r-- | src/gui/npclistdialog.cpp | 8 | ||||
-rw-r--r-- | src/gui/ok_dialog.cpp | 3 | ||||
-rw-r--r-- | src/gui/popupmenu.cpp | 25 | ||||
-rw-r--r-- | src/gui/quitdialog.cpp | 16 | ||||
-rw-r--r-- | src/gui/register.cpp | 47 | ||||
-rw-r--r-- | src/gui/serverdialog.cpp | 13 | ||||
-rw-r--r-- | src/gui/setup.cpp | 15 | ||||
-rw-r--r-- | src/gui/setup_audio.cpp | 8 | ||||
-rw-r--r-- | src/gui/setup_joystick.cpp | 18 | ||||
-rw-r--r-- | src/gui/setup_video.cpp | 37 | ||||
-rw-r--r-- | src/main.cpp | 5 |
23 files changed, 205 insertions, 166 deletions
@@ -1,3 +1,16 @@ +2007-08-07 Guillaume Melquiond <guillaume.melquiond@gmail.com> + + * po/Makevars, src/main.cpp: Replaced PACKAGE by tmw to reduce + preprocessing hell. Set gettext charset to utf8. + * src/gui/menuwindow.cpp, src/gui/connection.cpp, src/gui/register.cpp, + src/gui/equipmentwindow.cpp, src/gui/quitdialog.cpp, src/gui/login.cpp, + src/gui/item_amount.cpp, src/gui/npclistdialog.cpp, src/gui/setup.cpp, + src/gui/char_select.cpp, src/gui/setup_audio.cpp, src/gui/npc_text.cpp, + src/gui/setup_video.cpp, src/gui/ministatus.cpp, src/gui/ok_dialog.cpp, + src/gui/confirm_dialog.cpp, src/gui/setup_joystick.cpp, + src/gui/serverdialog.cpp, src/gui/minimap.cpp, src/gui/popupmenu.cpp: + Marked as translatable. + 2007-08-06 Guillaume Melquiond <guillaume.melquiond@gmail.com> * src/Makefile.am, src/utils/strprintf.h, src/utils/strprintf.cpp: diff --git a/po/Makevars b/po/Makevars index a72f85a3..76e72f50 100644 --- a/po/Makevars +++ b/po/Makevars @@ -1,9 +1,7 @@ # Makefile variables for PO directory in any package using GNU gettext. # Usually the message domain is the same as the package name. -#PACKAGE = $(PACKAGE_NAME) -DOMAIN = $(PACKAGE) -#VERSION = $(PACKAGE_VERSION) +DOMAIN = tmw # These two variables depend on the location of this directory. subdir = po diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 128a803e..d752cdb3 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -45,6 +45,8 @@ #include "../net/charserverhandler.h" #include "../net/messageout.h" +#include "../utils/gettext.h" +#include "../utils/strprintf.h" #include "../utils/tostring.h" // Defined in main.cpp, used here for setting the char create dialog @@ -63,8 +65,8 @@ class CharDeleteConfirm : public ConfirmDialog }; CharDeleteConfirm::CharDeleteConfirm(CharSelectDialog *m): - ConfirmDialog("Confirm", - "Are you sure you want to delete this character?", m), + ConfirmDialog(_("Confirm"), + _("Are you sure you want to delete this character?"), m), master(m) { } @@ -80,21 +82,21 @@ void CharDeleteConfirm::action(const gcn::ActionEvent &event) CharSelectDialog::CharSelectDialog(LockedArray<LocalPlayer*> *charInfo, LoginData *loginData): - Window("Select Character"), + Window(_("Select Character")), mCharInfo(charInfo), mCharSelected(false), mLoginData(loginData) { - 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); - mUnRegisterButton = new Button("Unregister", "unregister", this); - - mNameLabel = new gcn::Label("Name"); - mLevelLabel = new gcn::Label("Level"); - mMoneyLabel = new gcn::Label("Money"); + 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); + mUnRegisterButton = new Button(_("Unregister"), "unregister", this); + + mNameLabel = new gcn::Label(strprintf(_("Name: %s"), "")); + mLevelLabel = new gcn::Label(strprintf(_("Level: %d"), 0)); + mMoneyLabel = new gcn::Label(strprintf(_("Money: %d"), 0)); mPlayerBox = new PlayerBox(); int w = 195; @@ -198,9 +200,9 @@ void CharSelectDialog::updatePlayerInfo() if (pi) { - mNameLabel->setCaption(pi->getName()); - mLevelLabel->setCaption("Lvl: " + toString(pi->getLevel())); - mMoneyLabel->setCaption("Money: " + toString(pi->getMoney())); + mNameLabel->setCaption(strprintf(_("Name: %s"), pi->getName().c_str())); + mLevelLabel->setCaption(strprintf(_("Level: %d"), pi->getLevel())); + mMoneyLabel->setCaption(strprintf(_("Money: %d"), pi->getMoney())); if (!mCharSelected) { mNewCharButton->setEnabled(false); @@ -209,9 +211,9 @@ void CharSelectDialog::updatePlayerInfo() } } else { - mNameLabel->setCaption("Name"); - mLevelLabel->setCaption("Level"); - mMoneyLabel->setCaption("Money"); + mNameLabel->setCaption(strprintf(_("Name: %s"), "")); + mLevelLabel->setCaption(strprintf(_("Level: %d"), 0)); + mMoneyLabel->setCaption(strprintf(_("Money: %d"), 0)); mNewCharButton->setEnabled(true); mDelCharButton->setEnabled(false); mSelectButton->setEnabled(false); @@ -259,30 +261,30 @@ std::string CharSelectDialog::getName() } CharCreateDialog::CharCreateDialog(Window *parent, int slot): - Window("Create Character", true, parent), mSlot(slot) + Window(_("Create Character"), true, parent), mSlot(slot) { mPlayer = new Player(0, 0, NULL); mPlayer->setHairStyle(rand() % NR_HAIR_STYLES); mPlayer->setHairColor(rand() % NR_HAIR_COLORS); 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); - mAttributeLabel[0] = new gcn::Label("Strength:"); - mAttributeLabel[1] = new gcn::Label("Agility:"); - mAttributeLabel[2] = new gcn::Label("Dexterity:"); - mAttributeLabel[3] = new gcn::Label("Vitality:"); - mAttributeLabel[4] = new gcn::Label("Intelligence:"); - mAttributeLabel[5] = new gcn::Label("Willpower:"); - mAttributeLabel[6] = new gcn::Label("Charisma:"); + mAttributeLabel[0] = new gcn::Label(_("Strength:")); + mAttributeLabel[1] = new gcn::Label(_("Agility:")); + mAttributeLabel[2] = new gcn::Label(_("Dexterity:")); + mAttributeLabel[3] = new gcn::Label(_("Vitality:")); + mAttributeLabel[4] = new gcn::Label(_("Intelligence:")); + mAttributeLabel[5] = new gcn::Label(_("Willpower:")); + mAttributeLabel[6] = new gcn::Label(_("Charisma:")); for (int i=0; i<7; i++) { mAttributeLabel[i]->setWidth(70); @@ -290,7 +292,7 @@ CharCreateDialog::CharCreateDialog(Window *parent, int slot): mAttributeValue[i] = new gcn::Label("1"); }; - mAttributesLeft = new gcn::Label("Please distribute # points"); + mAttributesLeft = new gcn::Label(strprintf(_("Please distribute %d points"), 99)); mNameField->setActionEventId("create"); @@ -382,8 +384,8 @@ CharCreateDialog::action(const gcn::ActionEvent &event) ); } else { - new OkDialog("Error", - "Your name needs to be at least 4 characters.", this); + new OkDialog(_("Error"), + _("Your name needs to be at least 4 characters."), this); } } else if (event.getId() == "cancel") { @@ -428,7 +430,7 @@ void CharCreateDialog::UpdateSliders() int pointsLeft = 70 - getDistributedPoints(); if (pointsLeft == 0) { - mAttributesLeft->setCaption("Character stats OK"); + mAttributesLeft->setCaption(_("Character stats OK")); mCreateButton->setEnabled(true); } else @@ -436,13 +438,11 @@ void CharCreateDialog::UpdateSliders() mCreateButton->setEnabled(false); if (pointsLeft > 0) { - mAttributesLeft->setCaption(std::string("Please distribute " + - toString(pointsLeft) + " points")); + mAttributesLeft->setCaption(strprintf(_("Please distribute %d points"), pointsLeft)); } else { - mAttributesLeft->setCaption(std::string("Please remove " + - toString(-pointsLeft) + " points")); + mAttributesLeft->setCaption(strprintf(_("Please remove %d points"), -pointsLeft)); } } diff --git a/src/gui/confirm_dialog.cpp b/src/gui/confirm_dialog.cpp index 0ff8be17..65ca27f7 100644 --- a/src/gui/confirm_dialog.cpp +++ b/src/gui/confirm_dialog.cpp @@ -27,14 +27,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 3627689a..17b397ba 100644 --- a/src/gui/connection.cpp +++ b/src/gui/connection.cpp @@ -32,6 +32,8 @@ #include "../main.h" +#include "../utils/gettext.h" + namespace { struct ConnectionActionListener : public gcn::ActionListener { @@ -54,10 +56,10 @@ ConnectionDialog::ConnectionDialog(unsigned char previousState): ConnectionActionListener *connectionListener = new ConnectionActionListener(previousState); - Button *cancelButton = new Button("Cancel", "cancelButton", + Button *cancelButton = new Button(_("Cancel"), "cancelButton", connectionListener); 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 27c97ea0..2ee57cd9 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -31,12 +31,11 @@ #include "../resources/iteminfo.h" #include "../resources/resourcemanager.h" -#include "../utils/tostring.h" +#include "../utils/gettext.h" EquipmentWindow::EquipmentWindow(Equipment *equipment): - Window("Equipment"), mEquipment(equipment) + Window(_("Equipment")), mEquipment(equipment) { - setWindowName("Equipment"); setDefaultSize(5, 230, 200, 120); loadWindowState(); } diff --git a/src/gui/item_amount.cpp b/src/gui/item_amount.cpp index f72462f9..2e3ac4ad 100644 --- a/src/gui/item_amount.cpp +++ b/src/gui/item_amount.cpp @@ -31,8 +31,10 @@ #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 @@ -41,8 +43,8 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item): // 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); + Button *okButton = new Button(_("Ok"), "Drop", this); + Button *cancelButton = new Button(_("Cancel"), "Cancel", this); mItemAmountSlide = new Slider(1.0, mItem->getQuantity()); mItemAmountTextBox->setRange(1, mItem->getQuantity()); @@ -74,11 +76,11 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item): 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 15ec6314..fccfc05a 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -36,17 +36,19 @@ #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 *userLabel = new gcn::Label(_("Name:")); + gcn::Label *passLabel = new gcn::Label(_("Password:")); mUserField = new TextField(mLoginData->username); mPassField = new PasswordField(mLoginData->password); - 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(_("Keep"), 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 height = 100; diff --git a/src/gui/menuwindow.cpp b/src/gui/menuwindow.cpp index 943cc6f0..bfa2f1f2 100644 --- a/src/gui/menuwindow.cpp +++ b/src/gui/menuwindow.cpp @@ -30,6 +30,8 @@ #include "button.h" #include "windowcontainer.h" +#include "../utils/gettext.h" + extern Window *setupWindow; extern Window *inventoryWindow; extern Window *equipmentWindow; @@ -47,28 +49,27 @@ namespace { } MenuWindow::MenuWindow(): - Window("") + Window() { setResizable(false); - setWindowName("Menu"); setMovable(false); setTitleBarHeight(0); // Buttons - const char *buttonNames[] = + static char const *buttonNames[] = { - "Status", - "Equipment", - "Inventory", - "Skills", - "Setup", + N_("Status"), + N_("Equipment"), + N_("Inventory"), + N_("Skills"), + N_("Setup"), 0 }; int x = 0, y = 3, 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, y); add(btn); x += btn->getWidth() + 3; diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 2720225d..03a37e29 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -29,11 +29,12 @@ #include "../resources/image.h" +#include "../utils/gettext.h" + Minimap::Minimap(): - Window("Map"), + Window(_("MiniMap")), mMapImage(NULL) { - setWindowName("MiniMap"); setDefaultSize(5, 25, 100, 100); loadWindowState(); } diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp index 9a4c2273..3742be64 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -35,9 +35,8 @@ #include "../utils/tostring.h" MiniStatusWindow::MiniStatusWindow(): - Window("") + Window() { - setWindowName("MiniStatus"); setResizable(false); setMovable(false); setTitleBarHeight(0); diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index 2dd223bd..023307a7 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -31,13 +31,15 @@ #include "../npc.h" +#include "../utils/gettext.h" + NpcTextDialog::NpcTextDialog(): - Window("NPC") + Window(_("NPC")) { mTextBox = new TextBox(); mTextBox->setEditable(false); gcn::ScrollArea *scrollArea = new ScrollArea(mTextBox); - Button *okButton = new Button("OK", "ok", this); + Button *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 1bcdc8ff..487bdf60 100644 --- a/src/gui/npclistdialog.cpp +++ b/src/gui/npclistdialog.cpp @@ -31,13 +31,15 @@ #include "../npc.h" +#include "../utils/gettext.h" + NpcListDialog::NpcListDialog(): - Window("NPC") + Window(_("NPC")) { mItemList = new ListBox(this); ScrollArea *scrollArea = new ScrollArea(mItemList); - Button *okButton = new Button("OK", "ok", this); - Button *cancelButton = new Button("Cancel", "cancel", this); + Button *okButton = new Button(_("Ok"), "ok", this); + Button *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 ca9d2a7b..37d66353 100644 --- a/src/gui/ok_dialog.cpp +++ b/src/gui/ok_dialog.cpp @@ -27,13 +27,14 @@ #include "button.h" +#include "../utils/gettext.h" OkDialog::OkDialog(const std::string &title, const std::string &msg, Window *parent): Window(title, true, parent) { gcn::Label *textLabel = new gcn::Label(msg); - gcn::Button *okButton = new Button("Ok", "ok", this); + gcn::Button *okButton = new Button(_("Ok"), "ok", this); int w = textLabel->getWidth() + 20; int h = textLabel->getHeight() + 25 + okButton->getHeight(); diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index f308bbfd..9b1ce409 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,9 +77,9 @@ 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 = mBeing->getName(); - mBrowserBox->addRow("@@trade|Trade With " + name + "@@"); + mBrowserBox->addRow(strprintf(_("@@trade|Trade With %s@@"), name.c_str())); - mBrowserBox->addRow("@@attack|Attack " + name + "@@"); + mBrowserBox->addRow(strprintf(_("@@attack|Attack %s@@"), name.c_str())); //mBrowserBox->addRow("@@follow|Follow " + name + "@@"); //mBrowserBox->addRow("@@buddy|Add " + name + " to Buddy List@@"); } @@ -85,7 +88,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: @@ -95,7 +98,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); } @@ -107,11 +110,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); } @@ -214,15 +217,15 @@ void PopupMenu::showPopup(int x, int y, Item *item) if (item->isEquipment()) { - 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/quitdialog.cpp b/src/gui/quitdialog.cpp index 97be5f46..42c08080 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -31,16 +31,18 @@ #include "button.h" #include "radiobutton.h" +#include "../utils/gettext.h" + QuitDialog::QuitDialog(bool* quitGame, QuitDialog** pointerToMe): - Window("Quit", true, NULL), mQuitGame(quitGame), mMyPointer(pointerToMe) + Window(_("Quit"), true, NULL), mQuitGame(quitGame), mMyPointer(pointerToMe) { - mLogoutQuit = new RadioButton("Quit", "quitdialog"); - mForceQuit = new RadioButton("Quit", "quitdialog"); - mSwitchAccountServer = new RadioButton("Switch server", "quitdialog"); - mSwitchCharacter = new RadioButton("Switch character", "quitdialog"); - mOkButton = new Button("OK", "ok", this); - mCancelButton = new Button("Cancel", "cancel", this); + mLogoutQuit = new RadioButton(_("Quit"), "quitdialog"); + mForceQuit = new RadioButton(_("Quit"), "quitdialog"); + mSwitchAccountServer = new RadioButton(_("Switch server"), "quitdialog"); + mSwitchCharacter = new RadioButton(_("Switch character"), "quitdialog"); + mOkButton = new Button(_("Ok"), "ok", this); + mCancelButton = new Button(_("Cancel"), "cancel", this); setContentSize(200, 91); diff --git a/src/gui/register.cpp b/src/gui/register.cpp index c8e01a6c..7e236a7d 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -41,6 +41,9 @@ #include "textfield.h" #include "ok_dialog.h" +#include "../utils/gettext.h" +#include "../utils/strprintf.h" + void WrongDataNoticeListener::setTarget(gcn::TextField *textField) { @@ -57,20 +60,20 @@ WrongDataNoticeListener::action(const gcn::ActionEvent &event) } RegisterDialog::RegisterDialog(LoginData *loginData): - Window("Register"), + Window(_("Register")), 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 *emailLabel = new gcn::Label("Email:"); + gcn::Label *userLabel = new gcn::Label(_("Name:")); + gcn::Label *passwordLabel = new gcn::Label(_("Password:")); + gcn::Label *confirmLabel = new gcn::Label(_("Confirm:")); + gcn::Label *emailLabel = new gcn::Label(_("Email:")); mUserField = new TextField(loginData->username); mPasswordField = new PasswordField(loginData->password); mConfirmField = new PasswordField(); mEmailField = new TextField(); - mRegisterButton = new Button("Register", "register", this); - mCancelButton = new Button("Cancel", "cancel", this); + mRegisterButton = new Button(_("Register"), "register", this); + mCancelButton = new Button(_("Cancel"), "cancel", this); const int width = 220; const int height = 130; @@ -155,45 +158,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; } @@ -214,7 +217,7 @@ RegisterDialog::action(const gcn::ActionEvent &event) mWrongDataNoticeListener->setTarget(this->mPasswordField); } - OkDialog *dlg = new OkDialog("Error", errorMsg.str()); + OkDialog *dlg = new OkDialog(_("Error"), errorMsg); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index b47ce749..2eada7ad 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -39,6 +39,7 @@ #include "../logindata.h" #include "../main.h" +#include "../utils/gettext.h" #include "../utils/tostring.h" const short MAX_SERVERLIST = 5; @@ -98,10 +99,10 @@ void ServersListModel::addElement(Server server) } ServerDialog::ServerDialog(LoginData *loginData): - Window("Choose your Mana World Server"), mLoginData(loginData) + Window(_("Choose your Mana World Server")), mLoginData(loginData) { - gcn::Label *serverLabel = new gcn::Label("Server:"); - gcn::Label *portLabel = new gcn::Label("Port:"); + gcn::Label *serverLabel = new gcn::Label(_("Server:")); + gcn::Label *portLabel = new gcn::Label(_("Port:")); mServerNameField = new TextField(mLoginData->hostname); mPortField = new TextField(toString(mLoginData->port)); @@ -134,8 +135,8 @@ ServerDialog::ServerDialog(LoginData *loginData): mDropDownListener = new DropDownListener(mServerNameField, mPortField, mMostUsedServersListModel, mMostUsedServersListBox); - mOkButton = new Button("OK", "ok", this); - mCancelButton = new Button("Cancel", "cancel", this); + mOkButton = new Button(_("Ok"), "ok", this); + mCancelButton = new Button(_("Cancel"), "cancel", this); setContentSize(200, 100); @@ -201,7 +202,7 @@ ServerDialog::action(const gcn::ActionEvent &event) // Check login if (mServerNameField->getText().empty() || mPortField->getText().empty()) { - OkDialog *dlg = new OkDialog("Error", "Enter the chosen server."); + OkDialog *dlg = new OkDialog(_("Error"), "Enter the chosen server."); dlg->addActionListener(mDropDownListener); } else diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 3add3a18..3ea19059 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -30,6 +30,7 @@ #include "tabbedcontainer.h" #include "../utils/dtor.h" +#include "../utils/gettext.h" extern Window *statusWindow; extern Window *minimap; @@ -40,18 +41,18 @@ extern Window *helpWindow; extern Window *skillDialog; Setup::Setup(): - Window("Setup") + Window(_("Setup")) { int width = 230; int height = 245; setContentSize(width, height); - const char *buttonNames[] = { - "Apply", "Cancel", "Reset Windows", 0 + static char const *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); @@ -64,15 +65,15 @@ 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); add(panel); diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp index e5aadf80..89c21e2b 100644 --- a/src/gui/setup_audio.cpp +++ b/src/gui/setup_audio.cpp @@ -33,18 +33,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 56f411d7..59cfefa4 100644 --- a/src/gui/setup_joystick.cpp +++ b/src/gui/setup_joystick.cpp @@ -30,12 +30,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); @@ -65,13 +67,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 cd1507a7..ee46396b 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -44,6 +44,7 @@ #include "../log.h" #include "../main.h" +#include "../utils/gettext.h" #include "../utils/tostring.h" extern Graphics *graphics; @@ -109,11 +110,11 @@ Setup_Video::Setup_Video(): mFps((int)config.getValue("fpslimit", 60)), 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", 32)), @@ -129,7 +130,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 @@ -182,7 +183,7 @@ Setup_Video::Setup_Video(): mOverlayDetailField->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(180, 120); mScrollRadiusField->setWidth(30); @@ -190,7 +191,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(180, 140); mScrollLazinessField->setWidth(30); @@ -198,20 +199,20 @@ 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); @@ -264,8 +265,8 @@ void Setup_Video::apply() } } } 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.")); } config.setValue("screen", fullscreen ? 1 : 0); } @@ -276,8 +277,8 @@ void Setup_Video::apply() config.setValue("opengl", mOpenGLCheckBox->isMarked() ? 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 @@ -365,13 +366,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); diff --git a/src/main.cpp b/src/main.cpp index bde0877e..9a51f2e4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -669,8 +669,9 @@ int main(int argc, char *argv[]) #if ENABLE_NLS setlocale(LC_MESSAGES, ""); - bindtextdomain(PACKAGE, LOCALEDIR); - textdomain(PACKAGE); + bindtextdomain("tmw", LOCALEDIR); + bind_textdomain_codeset("tmw", "UTF-8"); + textdomain("tmw"); #endif // Initialize PhysicsFS |