[haiku-commits] r39878 - in haiku/trunk/src/kits: locale shared

  • From: philippe.houdoin@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 17 Dec 2010 16:34:13 +0100 (CET)

Author: phoudoin
Date: 2010-12-17 16:34:13 +0100 (Fri, 17 Dec 2010)
New Revision: 39878
Changeset: http://dev.haiku-os.org/changeset/39878

Modified:
   haiku/trunk/src/kits/locale/Jamfile
   haiku/trunk/src/kits/shared/AboutWindow.cpp
Log:
Made BAboutWindow class localized.


Modified: haiku/trunk/src/kits/locale/Jamfile
===================================================================
--- haiku/trunk/src/kits/locale/Jamfile 2010-12-17 11:20:49 UTC (rev 39877)
+++ haiku/trunk/src/kits/locale/Jamfile 2010-12-17 15:34:13 UTC (rev 39878)
@@ -65,10 +65,13 @@
        ;
 
 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
        ;

Modified: haiku/trunk/src/kits/shared/AboutWindow.cpp
===================================================================
--- haiku/trunk/src/kits/shared/AboutWindow.cpp 2010-12-17 11:20:49 UTC (rev 
39877)
+++ haiku/trunk/src/kits/shared/AboutWindow.cpp 2010-12-17 15:34:13 UTC (rev 
39878)
@@ -7,35 +7,61 @@
  */
 
 #include <AboutWindow.h>
+
+#include <stdarg.h>
+#include <time.h>
+
 #include <Alert.h>
 #include <Font.h>
 #include <String.h>
 #include <TextView.h>
 
-#include <stdarg.h>
-#include <time.h>
+#include <Catalog.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,
        const char **authors, const char *extraInfo)
 {
        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";


Other related posts:

  • » [haiku-commits] r39878 - in haiku/trunk/src/kits: locale shared - philippe . houdoin