diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-01-06 13:52:30 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-01-06 15:50:02 +0100 |
commit | bfd1d1bcc2a6ecd7efe301bfbf22a1e9b9188706 (patch) | |
tree | b30134f93042e4afb5554b5f14a83528ed2ef069 /src/gui/buy.cpp | |
parent | ce0d7b62824d620ec8c3daceac5710fbbd6b12f1 (diff) | |
download | mana-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.
Diffstat (limited to 'src/gui/buy.cpp')
-rw-r--r-- | src/gui/buy.cpp | 34 |
1 files changed, 18 insertions, 16 deletions
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)); } |