From 62943728a803f81d5bd3155e0c6d4f34668535aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dancs=C3=B3=20R=C3=B3bert?= <dancso.robert@d-rendszer.hu>
Date: Fri, 4 Jan 2013 19:05:33 +0100
Subject: [PATCH] Added localization support for Playground app.
---
src/tests/servers/app/playground/Jamfile | 9 ++-
src/tests/servers/app/playground/ObjectView.cpp | 9 ++-
src/tests/servers/app/playground/ObjectWindow.cpp | 61 +++++++++++----------
src/tests/servers/app/playground/main.cpp | 7 ++-
4 files changed, 54 insertions(+), 32 deletions(-)
diff --git a/src/tests/servers/app/playground/Jamfile b/src/tests/servers/app/playground/Jamfile
index 343845d..327085d 100644
a
|
b
|
Application Playground :
|
11 | 11 | ObjectView.cpp |
12 | 12 | ObjectWindow.cpp |
13 | 13 | States.cpp |
14 | | : be $(TARGET_LIBSUPC++) |
| 14 | : be $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS) |
15 | 15 | : Playground.rdef |
16 | 16 | ; |
17 | 17 | |
… |
… |
if ( $(TARGET_PLATFORM) = libbe_test ) {
|
20 | 20 | : tests!apps ; |
21 | 21 | } |
22 | 22 | |
| 23 | DoCatalogs Playground : |
| 24 | application/x-vnd.Haiku-Playground |
| 25 | : |
| 26 | main.cpp |
| 27 | ObjectView.cpp |
| 28 | ObjectWindow.cpp |
| 29 | ; |
diff --git a/src/tests/servers/app/playground/ObjectView.cpp b/src/tests/servers/app/playground/ObjectView.cpp
index 497304f..932cfc1 100644
a
|
b
|
|
11 | 11 | #include <Shape.h> |
12 | 12 | #include <String.h> |
13 | 13 | #include <Window.h> |
| 14 | // Locale Kit |
| 15 | #include <Catalog.h> |
| 16 | |
| 17 | #undef B_TRANSLATION_CONTEXT |
| 18 | #define B_TRANSLATION_CONTEXT "Playground" |
14 | 19 | |
15 | 20 | #include "States.h" |
16 | 21 | |
… |
… |
ObjectView::Draw(BRect updateRect)
|
157 | 162 | SetDrawingMode(B_OP_OVER); |
158 | 163 | SetHighColor(255, 0, 0, 128); |
159 | 164 | |
160 | | const char* message = "Click and drag to draw an object"; |
| 165 | const char* message = B_TRANSLATE("Click and drag to draw an object"); |
161 | 166 | float width = StringWidth(message); |
162 | 167 | |
163 | 168 | BPoint p((r.Width() - width) / 2.0, r.Height() / 2.0); |
… |
… |
if (dragMessage) {
|
341 | 346 | helper->FillRect(r); |
342 | 347 | |
343 | 348 | helper->SetHighColor(0, 0, 0, 255); |
344 | | const char* text = "Test"; |
| 349 | const char* text = B_TRANSLATE("Test"); |
345 | 350 | float pos = (r.Width() - helper->StringWidth(text)) / 2; |
346 | 351 | helper->DrawString(text, BPoint(pos, 25)); |
347 | 352 | helper->Sync(); |
diff --git a/src/tests/servers/app/playground/ObjectWindow.cpp b/src/tests/servers/app/playground/ObjectWindow.cpp
index 3b9129b..ca9e90e 100644
a
|
b
|
|
26 | 26 | #include <TabView.h> |
27 | 27 | #include <TextControl.h> |
28 | 28 | #include <TextView.h> |
| 29 | // Locale Kit |
| 30 | #include <Catalog.h> |
| 31 | |
| 32 | #undef B_TRANSLATION_CONTEXT |
| 33 | #define B_TRANSLATION_CONTEXT "Playground" |
29 | 34 | |
30 | 35 | #include "ObjectView.h" |
31 | 36 | #include "States.h" |
… |
… |
ObjectWindow::ObjectWindow(BRect frame, const char* name)
|
126 | 131 | BMenuBar* menuBar = new BMenuBar(b, "menu bar"); |
127 | 132 | AddChild(menuBar); |
128 | 133 | |
129 | | BMenu* menu = new BMenu("File"); |
| 134 | BMenu* menu = new BMenu(B_TRANSLATE("File")); |
130 | 135 | menuBar->AddItem(menu); |
131 | 136 | |
132 | | menu->AddItem(new BMenu("Submenu")); |
| 137 | menu->AddItem(new BMenu(B_TRANSLATE("Submenu"))); |
133 | 138 | |
134 | | BMenuItem* menuItem = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), |
| 139 | BMenuItem* menuItem = new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED), |
135 | 140 | 'Q'); |
136 | 141 | menu->AddItem(menuItem); |
137 | 142 | |
… |
… |
ObjectWindow::ObjectWindow(BRect frame, const char* name)
|
170 | 175 | BBox* controlGroup = new BBox(b, "controls box", |
171 | 176 | B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW, B_FANCY_BORDER); |
172 | 177 | |
173 | | controlGroup->SetLabel("Controls"); |
| 178 | controlGroup->SetLabel(B_TRANSLATE("Controls")); |
174 | 179 | bg->AddChild(controlGroup); |
175 | 180 | |
176 | 181 | b = controlGroup->Bounds(); |
… |
… |
ObjectWindow::ObjectWindow(BRect frame, const char* name)
|
180 | 185 | b.right = b.left + b.Width() / 2.0 - 5.0; |
181 | 186 | |
182 | 187 | // new button |
183 | | fNewB = new BButton(b, "new button", "New Object", |
| 188 | fNewB = new BButton(b, "new button", B_TRANSLATE("New Object"), |
184 | 189 | new BMessage(MSG_NEW_OBJECT)); |
185 | 190 | controlGroup->AddChild(fNewB); |
186 | 191 | SetDefaultButton(fNewB); |
187 | 192 | |
188 | 193 | // clear button |
189 | 194 | b.OffsetBy(0, fNewB->Bounds().Height() + 5.0); |
190 | | fClearB = new BButton(b, "clear button", "Clear", new BMessage(MSG_CLEAR)); |
| 195 | fClearB = new BButton(b, "clear button", B_TRANSLATE("Clear"), new BMessage(MSG_CLEAR)); |
191 | 196 | controlGroup->AddChild(fClearB); |
192 | 197 | |
193 | 198 | // object type radio buttons |
… |
… |
ObjectWindow::ObjectWindow(BRect frame, const char* name)
|
197 | 202 | b.OffsetBy(0, fClearB->Bounds().Height() + 5.0); |
198 | 203 | message = new BMessage(MSG_SET_OBJECT_TYPE); |
199 | 204 | message->AddInt32("type", OBJECT_LINE); |
200 | | radioButton = new BRadioButton(b, "radio 1", "Line", message); |
| 205 | radioButton = new BRadioButton(b, "radio 1", B_TRANSLATE("Line"), message); |
201 | 206 | controlGroup->AddChild(radioButton); |
202 | 207 | |
203 | 208 | radioButton->SetValue(B_CONTROL_ON); |
… |
… |
ObjectWindow::ObjectWindow(BRect frame, const char* name)
|
205 | 210 | b.OffsetBy(0, radioButton->Bounds().Height() + 5.0); |
206 | 211 | message = new BMessage(MSG_SET_OBJECT_TYPE); |
207 | 212 | message->AddInt32("type", OBJECT_RECT); |
208 | | radioButton = new BRadioButton(b, "radio 2", "Rect", message); |
| 213 | radioButton = new BRadioButton(b, "radio 2", B_TRANSLATE("Rect"), message); |
209 | 214 | controlGroup->AddChild(radioButton); |
210 | 215 | |
211 | 216 | b.OffsetBy(0, radioButton->Bounds().Height() + 5.0); |
212 | 217 | message = new BMessage(MSG_SET_OBJECT_TYPE); |
213 | 218 | message->AddInt32("type", OBJECT_ROUND_RECT); |
214 | | radioButton = new BRadioButton(b, "radio 3", "Round Rect", message); |
| 219 | radioButton = new BRadioButton(b, "radio 3", B_TRANSLATE("Round Rect"), message); |
215 | 220 | controlGroup->AddChild(radioButton); |
216 | 221 | |
217 | 222 | b.OffsetBy(0, radioButton->Bounds().Height() + 5.0); |
218 | 223 | message = new BMessage(MSG_SET_OBJECT_TYPE); |
219 | 224 | message->AddInt32("type", OBJECT_ELLIPSE); |
220 | | radioButton = new BRadioButton(b, "radio 4", "Ellipse", message); |
| 225 | radioButton = new BRadioButton(b, "radio 4", B_TRANSLATE("Ellipse"), message); |
221 | 226 | controlGroup->AddChild(radioButton); |
222 | 227 | |
223 | 228 | // drawing mode |
224 | | BPopUpMenu* popupMenu = new BPopUpMenu("<pick>"); |
| 229 | BPopUpMenu* popupMenu = new BPopUpMenu(B_TRANSLATE("<pick>")); |
225 | 230 | |
226 | 231 | message = new BMessage(MSG_SET_DRAWING_MODE); |
227 | 232 | message->AddInt32("mode", B_OP_COPY); |
228 | | popupMenu->AddItem(new BMenuItem("Copy", message)); |
| 233 | popupMenu->AddItem(new BMenuItem(B_TRANSLATE("Copy"), message)); |
229 | 234 | |
230 | 235 | message = new BMessage(MSG_SET_DRAWING_MODE); |
231 | 236 | message->AddInt32("mode", B_OP_OVER); |
232 | | popupMenu->AddItem(new BMenuItem("Over", message)); |
| 237 | popupMenu->AddItem(new BMenuItem(B_TRANSLATE("Over"), message)); |
233 | 238 | |
234 | 239 | message = new BMessage(MSG_SET_DRAWING_MODE); |
235 | 240 | message->AddInt32("mode", B_OP_INVERT); |
236 | | popupMenu->AddItem(new BMenuItem("Invert", message)); |
| 241 | popupMenu->AddItem(new BMenuItem(B_TRANSLATE("Invert"), message)); |
237 | 242 | |
238 | 243 | message = new BMessage(MSG_SET_DRAWING_MODE); |
239 | 244 | message->AddInt32("mode", B_OP_BLEND); |
240 | | popupMenu->AddItem(new BMenuItem("Blend", message)); |
| 245 | popupMenu->AddItem(new BMenuItem(B_TRANSLATE("Blend"), message)); |
241 | 246 | |
242 | 247 | message = new BMessage(MSG_SET_DRAWING_MODE); |
243 | 248 | message->AddInt32("mode", B_OP_SELECT); |
244 | | popupMenu->AddItem(new BMenuItem("Select", message)); |
| 249 | popupMenu->AddItem(new BMenuItem(B_TRANSLATE("Select"), message)); |
245 | 250 | |
246 | 251 | message = new BMessage(MSG_SET_DRAWING_MODE); |
247 | 252 | message->AddInt32("mode", B_OP_ERASE); |
248 | | popupMenu->AddItem(new BMenuItem("Erase", message)); |
| 253 | popupMenu->AddItem(new BMenuItem(B_TRANSLATE("Erase"), message)); |
249 | 254 | |
250 | 255 | message = new BMessage(MSG_SET_DRAWING_MODE); |
251 | 256 | message->AddInt32("mode", B_OP_ADD); |
252 | | popupMenu->AddItem(new BMenuItem("Add", message)); |
| 257 | popupMenu->AddItem(new BMenuItem(B_TRANSLATE("Add"), message)); |
253 | 258 | |
254 | 259 | message = new BMessage(MSG_SET_DRAWING_MODE); |
255 | 260 | message->AddInt32("mode", B_OP_SUBTRACT); |
256 | | popupMenu->AddItem(new BMenuItem("Subtract", message)); |
| 261 | popupMenu->AddItem(new BMenuItem(B_TRANSLATE("Subtract"), message)); |
257 | 262 | |
258 | 263 | message = new BMessage(MSG_SET_DRAWING_MODE); |
259 | 264 | message->AddInt32("mode", B_OP_MIN); |
260 | | popupMenu->AddItem(new BMenuItem("Min", message)); |
| 265 | popupMenu->AddItem(new BMenuItem(B_TRANSLATE("Min"), message)); |
261 | 266 | |
262 | 267 | message = new BMessage(MSG_SET_DRAWING_MODE); |
263 | 268 | message->AddInt32("mode", B_OP_MAX); |
264 | | popupMenu->AddItem(new BMenuItem("Max", message)); |
| 269 | popupMenu->AddItem(new BMenuItem(B_TRANSLATE("Max"), message)); |
265 | 270 | |
266 | 271 | message = new BMessage(MSG_SET_DRAWING_MODE); |
267 | 272 | message->AddInt32("mode", B_OP_ALPHA); |
268 | | BMenuItem* item = new BMenuItem("Alpha", message); |
| 273 | BMenuItem* item = new BMenuItem(B_TRANSLATE("Alpha"), message); |
269 | 274 | item->SetMarked(true); |
270 | 275 | popupMenu->AddItem(item); |
271 | 276 | |
272 | 277 | b.OffsetBy(0, radioButton->Bounds().Height() + 10.0); |
273 | | fDrawingModeMF = new BMenuField(b, "drawing mode field", "Mode:", |
| 278 | fDrawingModeMF = new BMenuField(b, "drawing mode field", B_TRANSLATE("Mode:"), |
274 | 279 | popupMenu); |
275 | 280 | |
276 | 281 | controlGroup->AddChild(fDrawingModeMF); |
… |
… |
ObjectWindow::ObjectWindow(BRect frame, const char* name)
|
286 | 291 | |
287 | 292 | // alpha text control |
288 | 293 | b.OffsetBy(0, fColorControl-> Bounds().Height() + 5.0); |
289 | | fAlphaTC = new BTextControl(b, "alpha text control", "Alpha:", "", |
| 294 | fAlphaTC = new BTextControl(b, "alpha text control", B_TRANSLATE("Alpha:"), "", |
290 | 295 | new BMessage(MSG_SET_COLOR)); |
291 | 296 | controlGroup->AddChild(fAlphaTC); |
292 | 297 | |
… |
… |
ObjectWindow::ObjectWindow(BRect frame, const char* name)
|
300 | 305 | |
301 | 306 | // fill check box |
302 | 307 | b.OffsetBy(0, fAlphaTC->Bounds().Height() + 5.0); |
303 | | fFillCB = new BCheckBox(b, "fill check box", "Fill", |
| 308 | fFillCB = new BCheckBox(b, "fill check box", B_TRANSLATE("Fill"), |
304 | 309 | new BMessage(MSG_SET_FILL_OR_STROKE)); |
305 | 310 | controlGroup->AddChild(fFillCB); |
306 | 311 | |
307 | 312 | // pen size text control |
308 | 313 | b.OffsetBy(0, radioButton->Bounds().Height() + 5.0); |
309 | 314 | b.bottom = b.top + 10.0;//35; |
310 | | fPenSizeS = new BSlider(b, "width slider", "Width:", NULL, 1, 100, |
| 315 | fPenSizeS = new BSlider(b, "width slider", B_TRANSLATE("Width:"), NULL, 1, 100, |
311 | 316 | B_TRIANGLE_THUMB); |
312 | 317 | fPenSizeS->SetLimitLabels("1", "100"); |
313 | 318 | fPenSizeS->SetModificationMessage(new BMessage(MSG_SET_PEN_SIZE)); |
… |
… |
ObjectWindow::MessageReceived(BMessage* message)
|
417 | 422 | break; |
418 | 423 | case MSG_CLEAR: { |
419 | 424 | BAlert *alert = new BAlert("Playground", |
420 | | "Do you really want to clear all drawing objects?", |
421 | | "No", "Yes"); |
| 425 | B_TRANSLATE("Do you really want to clear all drawing objects?"), |
| 426 | B_TRANSLATE("No"), B_TRANSLATE("Yes")); |
422 | 427 | if (alert->Go() == 1) { |
423 | 428 | fObjectView->MakeEmpty(); |
424 | 429 | fObjectLV->MakeEmpty(); |
diff --git a/src/tests/servers/app/playground/main.cpp b/src/tests/servers/app/playground/main.cpp
index 5612123..db3c202 100644
a
|
b
|
|
3 | 3 | |
4 | 4 | #include <Application.h> |
5 | 5 | #include <Message.h> |
| 6 | // Locale Kit |
| 7 | #include <Catalog.h> |
| 8 | |
| 9 | #undef B_TRANSLATION_CONTEXT |
| 10 | #define B_TRANSLATION_CONTEXT "Playground" |
6 | 11 | |
7 | 12 | #include "ObjectWindow.h" |
8 | 13 | |
… |
… |
main(int argc, char** argv)
|
13 | 18 | BApplication* app = new BApplication("application/x-vnd.Haiku-Playground"); |
14 | 19 | |
15 | 20 | BRect frame(50.0, 50.0, 600.0, 400.0); |
16 | | BWindow* window = new ObjectWindow(frame, "Playground"); |
| 21 | BWindow* window = new ObjectWindow(frame, B_TRANSLATE_SYSTEM_NAME("Playground")); |
17 | 22 | |
18 | 23 | window->Show(); |
19 | 24 | |