[haiku-commits] r42950 - haiku/trunk/src/kits/locale

  • From: pulkomandy@xxxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 29 Oct 2011 16:35:55 +0200 (CEST)

Author: pulkomandy
Date: 2011-10-29 16:35:55 +0200 (Sat, 29 Oct 2011)
New Revision: 42950
Changeset: https://dev.haiku-os.org/changeset/42950
Ticket: https://dev.haiku-os.org/ticket/8037

Modified:
   haiku/trunk/src/kits/locale/DefaultCatalog.cpp
Log:
Try to load resource-embedded catalog from application. Should fix #8037.


Modified: haiku/trunk/src/kits/locale/DefaultCatalog.cpp
===================================================================
--- haiku/trunk/src/kits/locale/DefaultCatalog.cpp      2011-10-29 13:40:53 UTC 
(rev 42949)
+++ haiku/trunk/src/kits/locale/DefaultCatalog.cpp      2011-10-29 14:35:55 UTC 
(rev 42950)
@@ -65,22 +65,31 @@
        :
        BHashMapCatalog(signature, language, fingerprint)
 {
-       // give highest priority to catalog living in sub-folder of app's 
folder:
+       status_t status;
+
        app_info appInfo;
        be_app->GetAppInfo(&appInfo);
-       node_ref nref;
-       nref.device = appInfo.ref.device;
-       nref.node = appInfo.ref.directory;
-       BDirectory appDir(&nref);
-       BString catalogName("locale/");
-       catalogName << kCatFolder
-               << "/" << fSignature
-               << "/" << fLanguageName
-               << kCatExtension;
-       BPath catalogPath(&appDir, catalogName.String());
-       status_t status = ReadFromFile(catalogPath.Path());
 
+       // give highest priority to catalog embedded as resource in application
+       // executable:
+       status = ReadFromResource(&appInfo.ref);
+
+       // search for catalog living in sub-folder of app's folder:
        if (status != B_OK) {
+               node_ref nref;
+               nref.device = appInfo.ref.device;
+               nref.node = appInfo.ref.directory;
+               BDirectory appDir(&nref);
+               BString catalogName("locale/");
+               catalogName << kCatFolder
+                       << "/" << fSignature
+                       << "/" << fLanguageName
+                       << kCatExtension;
+               BPath catalogPath(&appDir, catalogName.String());
+               status = ReadFromFile(catalogPath.Path());
+       }
+
+       if (status != B_OK) {
                // search in data folders
 
                directory_which which[] = {
@@ -92,8 +101,8 @@
                for (size_t i = 0; i < sizeof(which) / sizeof(which[0]); i++) {
                        BPath path;
                        if (find_directory(which[i], &path) == B_OK) {
-                               catalogName = BString(path.Path())
-                                       << "/locale/" << kCatFolder
+                               BString catalogName(path.Path());
+                               catalogName << "/locale/" << kCatFolder
                                        << "/" << fSignature
                                        << "/" << fLanguageName
                                        << kCatExtension;


Other related posts:

  • » [haiku-commits] r42950 - haiku/trunk/src/kits/locale - pulkomandy