xref: /haiku/src/kits/shared/AboutMenuItem.cpp (revision 922e7ba1f3228e6f28db69b0ded8f86eb32dea17)
1 /*
2  * Copyright 2007-2011 Haiku, Inc.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Ryan Leavengood, leavengood@gmail.com
7  *		Jonas Sundström, jonas@kirilla.se
8  */
9 
10 
11 #include <AboutMenuItem.h>
12 #include <Application.h>
13 #include <Catalog.h>
14 #include <LocaleBackend.h>
15 #include <Roster.h>
16 #include <String.h>
17 
18 
19 using BPrivate::gLocaleBackend;
20 using BPrivate::LocaleBackend;
21 
22 
23 #undef B_TRANSLATE_CONTEXT
24 #define B_TRANSLATE_CONTEXT "AboutMenuItem"
25 
26 
27 BAboutMenuItem::BAboutMenuItem()
28 	:
29 	BMenuItem("", new BMessage(B_ABOUT_REQUESTED))
30 {
31 	app_info info;
32 	const char* name = NULL;
33 	if (be_app != NULL && be_app->GetAppInfo(&info) == B_OK)
34 		name = B_TRANSLATE_NOCOLLECT_SYSTEM_NAME(info.ref.name);
35 
36 	// we need to translate some strings, and in order to do so, we need
37 	// to use the LocaleBackend to reach liblocale.so
38 	if (gLocaleBackend == NULL)
39 		LocaleBackend::LoadBackend();
40 
41 	const char* string = B_TRANSLATE_MARK("About %app%");
42 	if (gLocaleBackend) {
43 		string = gLocaleBackend->GetString(string, "AboutMenuItem");
44 	}
45 
46 	BString label = string;
47 	if (name != NULL)
48 		label.ReplaceFirst("%app%", name);
49 	else
50 		label.ReplaceFirst("%app%", "(NULL)");
51 	SetLabel(label.String());
52 }
53