Made BAboutWindow class localized.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39878 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Philippe Houdoin 2010-12-17 15:34:13 +00:00
parent 5b6139e398
commit 5ae52982cc
2 changed files with 39 additions and 10 deletions

View File

@ -65,10 +65,13 @@ StaticLibrary liblocalestub.a
; ;
SEARCH on [ FGristFiles StringForSize.cpp ] += [ FDirName $(HAIKU_TOP) src kits shared ] ; SEARCH on [ FGristFiles StringForSize.cpp ] += [ FDirName $(HAIKU_TOP) src kits shared ] ;
SEARCH on [ FGristFiles AboutWindow.cpp ] += [ FDirName $(HAIKU_TOP) src kits shared ] ;
SEARCH on [ FGristFiles ColorControl.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ; SEARCH on [ FGristFiles ColorControl.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ;
DoCatalogs liblocale.so : DoCatalogs liblocale.so
system : system
: StringForSize.cpp :
ColorControl.cpp AboutWindow.cpp
ColorControl.cpp
StringForSize.cpp
; ;

View File

@ -7,13 +7,23 @@
*/ */
#include <AboutWindow.h> #include <AboutWindow.h>
#include <stdarg.h>
#include <time.h>
#include <Alert.h> #include <Alert.h>
#include <Font.h> #include <Font.h>
#include <String.h> #include <String.h>
#include <TextView.h> #include <TextView.h>
#include <stdarg.h> #include <Catalog.h>
#include <time.h> #include <LocaleBackend.h>
using BPrivate::gLocaleBackend;
using BPrivate::LocaleBackend;
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "AboutWindow"
BAboutWindow::BAboutWindow(const char *appName, int32 firstCopyrightYear, BAboutWindow::BAboutWindow(const char *appName, int32 firstCopyrightYear,
@ -21,21 +31,37 @@ BAboutWindow::BAboutWindow(const char *appName, int32 firstCopyrightYear,
{ {
fAppName = new BString(appName); fAppName = new BString(appName);
// we need to translate some strings, and in order to do so, we need
// to use the LocaleBackend to reache liblocale.so
if (gLocaleBackend == NULL)
LocaleBackend::LoadBackend();
const char* copyright = B_TRANSLATE_MARK("Copyright " B_UTF8_COPYRIGHT " %years% Haiku, Inc.\n\n");
const char* writtenBy = B_TRANSLATE_MARK("Written by:\n");
if (gLocaleBackend) {
copyright = gLocaleBackend->GetString(copyright, "AboutWindow");
writtenBy = gLocaleBackend->GetString(writtenBy, "AboutWindow");
}
// Get current year // Get current year
time_t tp; time_t tp;
time(&tp); time(&tp);
char currentYear[5]; char currentYear[5];
strftime(currentYear, 5, "%Y", localtime(&tp)); strftime(currentYear, 5, "%Y", localtime(&tp));
BString copyrightYears;
copyrightYears << firstCopyrightYear;
if (copyrightYears != currentYear)
copyrightYears << "-" << currentYear;
// Build the text to display // Build the text to display
BString text(appName); BString text(appName);
text << "\n\nCopyright " B_UTF8_COPYRIGHT " "; text << copyright;
text << firstCopyrightYear << "-" << currentYear << " Haiku, Inc.\n\n"; text.ReplaceAll("%years%", copyrightYears.String());
text << "Written by:\n"; text << writtenBy;
for (int32 i = 0; authors[i]; i++) { for (int32 i = 0; authors[i]; i++) {
text << " " << authors[i] << "\n"; text << " " << authors[i] << "\n";
} }
// The extra information is optional // The extra information is optional
if (extraInfo != NULL) { if (extraInfo != NULL) {
text << "\n" << extraInfo << "\n"; text << "\n" << extraInfo << "\n";