[haiku-commits] haiku: hrev51141 - src/preferences/datatranslations

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 30 Apr 2017 11:01:46 +0200 (CEST)

hrev51141 adds 1 changeset to branch 'master'
old head: b8a6139981c9dc0e000d32c0a70f8e6f0681f721
new head: 0702f3b191c5e202e9c020eeaba4610017097841
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=0702f3b191c5+%5Eb8a6139981c9

----------------------------------------------------------------------------

0702f3b191c5: DataTranslations: fix formatting of localized text
  
  The about window relied on two sets of strings to be translated exactly
  the same way and used lengths from one set to do things in the other.
  
  Several translations got this wrong, and as a reult, the bold text in
  the window was not at the expected places.
  
  Fix by having only one set of translated strings, and build the dialog
  from it.
  
  Fixes #10559.

                             [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev51141
Commit:      0702f3b191c5e202e9c020eeaba4610017097841
URL:         http://cgit.haiku-os.org/haiku/commit/?id=0702f3b191c5
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Sun Apr 30 09:00:08 2017 UTC

Ticket:      https://dev.haiku-os.org/ticket/10559

----------------------------------------------------------------------------

1 file changed, 28 insertions(+), 10 deletions(-)
.../datatranslations/DataTranslationsWindow.cpp  | 38 ++++++++++++++------

----------------------------------------------------------------------------

diff --git a/src/preferences/datatranslations/DataTranslationsWindow.cpp 
b/src/preferences/datatranslations/DataTranslationsWindow.cpp
index 93bce4c..f5e5113 100644
--- a/src/preferences/datatranslations/DataTranslationsWindow.cpp
+++ b/src/preferences/datatranslations/DataTranslationsWindow.cpp
@@ -293,15 +293,36 @@ DataTranslationsWindow::_ShowInfoAlert(int32 id)
        int32 version = 0;
        _GetTranslatorInfo(id, name, info, version, path);
 
+       const char* labels[] = { B_TRANSLATE("Name:"), B_TRANSLATE("Version:"),
+               B_TRANSLATE("Info:"), B_TRANSLATE("Path:"), NULL };
+       int offsets[4];
+
        BString message;
+       BString temp;
+
+       offsets[0] = 0;
+       temp.SetToFormat("%s %s\n", labels[0], name);
+
+       message.Append(temp);
+
+       offsets[1] = message.Length();
        // Convert the version number into a readable format
-       snprintf(message.LockBuffer(2048), 2048,
-               B_TRANSLATE("Name: %s \nVersion: %ld.%ld.%ld\n\n"
-                       "Info:\n%s\n\nPath:\n%s\n"),
-               name, B_TRANSLATION_MAJOR_VERSION(version),
+       temp.SetToFormat("%s %ld.%ld.%ld\n\n", labels[1], 
+               B_TRANSLATION_MAJOR_VERSION(version),
                B_TRANSLATION_MINOR_VERSION(version),
-               B_TRANSLATION_REVISION_VERSION(version), info, path.Path());
-       message.UnlockBuffer();
+               B_TRANSLATION_REVISION_VERSION(version));
+
+       message.Append(temp);
+
+       offsets[2] = message.Length();
+       temp.SetToFormat("%s\n%s\n\n", labels[2], info);
+
+       message.Append(temp);
+
+       offsets[3] = message.Length();
+       temp.SetToFormat("%s %s\n", labels[3], path.Path());
+
+       message.Append(temp);
 
        BAlert* alert = new BAlert(B_TRANSLATE("Info"), message.String(),
                B_TRANSLATE("OK"));
@@ -313,11 +334,8 @@ DataTranslationsWindow::_ShowInfoAlert(int32 id)
        view->GetFont(&font);
        font.SetFace(B_BOLD_FACE);
 
-       const char* labels[] = { B_TRANSLATE("Name:"), B_TRANSLATE("Version:"),
-               B_TRANSLATE("Info:"), B_TRANSLATE("Path:"), NULL };
        for (int32 i = 0; labels[i]; i++) {
-               int32 index = message.FindFirst(labels[i]);
-               view->SetFontAndColor(index, index + strlen(labels[i]), &font);
+               view->SetFontAndColor(offsets[i], offsets[i] + 
strlen(labels[i]), &font);
        }
 
        alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);


Other related posts:

  • » [haiku-commits] haiku: hrev51141 - src/preferences/datatranslations - pulkomandy