From 5ae52982cc1f9b25ba00207a280a2e10ee1895af Mon Sep 17 00:00:00 2001 From: Philippe Houdoin Date: Fri, 17 Dec 2010 15:34:13 +0000 Subject: [PATCH] Made BAboutWindow class localized. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39878 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/locale/Jamfile | 11 ++++++---- src/kits/shared/AboutWindow.cpp | 38 +++++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/kits/locale/Jamfile b/src/kits/locale/Jamfile index ba39d87689..de642c1526 100644 --- a/src/kits/locale/Jamfile +++ b/src/kits/locale/Jamfile @@ -65,10 +65,13 @@ StaticLibrary liblocalestub.a ; 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 ] ; -DoCatalogs liblocale.so : - system - : StringForSize.cpp - ColorControl.cpp +DoCatalogs liblocale.so + : system + : + AboutWindow.cpp + ColorControl.cpp + StringForSize.cpp ; diff --git a/src/kits/shared/AboutWindow.cpp b/src/kits/shared/AboutWindow.cpp index 777d107ff9..073c1cb65f 100644 --- a/src/kits/shared/AboutWindow.cpp +++ b/src/kits/shared/AboutWindow.cpp @@ -7,13 +7,23 @@ */ #include + +#include +#include + #include #include #include #include -#include -#include +#include +#include +using BPrivate::gLocaleBackend; +using BPrivate::LocaleBackend; + + +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "AboutWindow" BAboutWindow::BAboutWindow(const char *appName, int32 firstCopyrightYear, @@ -21,21 +31,37 @@ BAboutWindow::BAboutWindow(const char *appName, int32 firstCopyrightYear, { 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 time_t tp; time(&tp); char currentYear[5]; strftime(currentYear, 5, "%Y", localtime(&tp)); + BString copyrightYears; + copyrightYears << firstCopyrightYear; + if (copyrightYears != currentYear) + copyrightYears << "-" << currentYear; // Build the text to display BString text(appName); - text << "\n\nCopyright " B_UTF8_COPYRIGHT " "; - text << firstCopyrightYear << "-" << currentYear << " Haiku, Inc.\n\n"; - text << "Written by:\n"; + text << copyright; + text.ReplaceAll("%years%", copyrightYears.String()); + text << writtenBy; for (int32 i = 0; authors[i]; i++) { text << " " << authors[i] << "\n"; } - + // The extra information is optional if (extraInfo != NULL) { text << "\n" << extraInfo << "\n";