diff --git a/headers/private/shared/AboutMenuItem.h b/headers/private/shared/AboutMenuItem.h new file mode 100644 index 0000000000..6a1b96c3f6 --- /dev/null +++ b/headers/private/shared/AboutMenuItem.h @@ -0,0 +1,18 @@ +/* + * Copyright 2011 Haiku, Inc. + * Distributed under the terms of the MIT License. + */ +#ifndef B_ABOUT_MENU_ITEM_H +#define B_ABOUT_MENU_ITEM_H + + +#include + + +class BAboutMenuItem : public BMenuItem { +public: + BAboutMenuItem(const char* appName); +}; + + +#endif // B_ABOUT_MENU_ITEM_H diff --git a/src/kits/shared/AboutMenuItem.cpp b/src/kits/shared/AboutMenuItem.cpp new file mode 100644 index 0000000000..15cddd01a8 --- /dev/null +++ b/src/kits/shared/AboutMenuItem.cpp @@ -0,0 +1,42 @@ +/* + * Copyright 2007-2011 Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ryan Leavengood, leavengood@gmail.com + * Jonas Sundström, jonas@kirilla.se + */ + + +#include +#include +#include +#include + + +using BPrivate::gLocaleBackend; +using BPrivate::LocaleBackend; + + +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "AboutMenuItem" + + +BAboutMenuItem::BAboutMenuItem(const char* appName) + : + BMenuItem("", new BMessage(B_ABOUT_REQUESTED)) +{ + // we need to translate some strings, and in order to do so, we need + // to use the LocaleBackend to reach liblocale.so + if (gLocaleBackend == NULL) + LocaleBackend::LoadBackend(); + + const char* string = B_TRANSLATE_MARK("About %app%" B_UTF8_ELLIPSIS); + if (gLocaleBackend) { + string = gLocaleBackend->GetString(string, "AboutMenuItem"); + } + + BString label = string; + label.ReplaceFirst("%app%", appName); + SetLabel(label.String()); +} diff --git a/src/kits/shared/Jamfile b/src/kits/shared/Jamfile index 9a4007600d..c957f910d3 100644 --- a/src/kits/shared/Jamfile +++ b/src/kits/shared/Jamfile @@ -13,6 +13,7 @@ UsePrivateSystemHeaders ; UsePrivateHeaders kernel libroot ; StaticLibrary libshared.a : + AboutMenuItem.cpp AboutWindow.cpp CalendarView.cpp ColorQuantizer.cpp