Ticket #6104: text_searchLocalization.patch

File text_searchLocalization.patch, 11.0 KB (added by Karvjorm, 14 years ago)

A localization patch for TextSearch

  • src/apps/text_search/Grepper.cpp

     
    2828#include <stdlib.h>
    2929#include <string.h>
    3030
     31#include <Catalog.h>
    3132#include <Directory.h>
    3233#include <List.h>
     34#include <Locale.h>
    3335#include <NodeInfo.h>
    3436#include <Path.h>
    3537#include <UTF8.h>
     
    3739#include "FileIterator.h"
    3840#include "Model.h"
    3941
     42#undef B_TRANSLATE_CONTEXT
     43#define B_TRANSLATE_CONTEXT "Grepper"
     44
     45
    4046using std::nothrow;
    4147
    4248// TODO: stippi: Check if this is a the best place to maintain a global
     
    203209        }
    204210
    205211        if (!_EscapeSpecialChars(fileName, B_PATH_NAME_LENGTH)) {
    206             sprintf(tempString, "%s: Not enough room to escape the filename.",
    207                 fileName);
     212            sprintf(tempString, B_TRANSLATE("%s: Not enough room to escape "
     213                "the filename."), fileName);
    208214
    209215            message.MakeEmpty();
    210216            message.what = MSG_REPORT_ERROR;
     
    240246            }
    241247        }
    242248
    243         sprintf(tempString, "%s: There was a problem running grep.", fileName);
     249        sprintf(tempString, B_TRANSLATE("%s: There was a problem running grep."), fileName);
    244250
    245251        message.MakeEmpty();
    246252        message.what = MSG_REPORT_ERROR;
  • src/apps/text_search/GrepWindow.cpp

     
    4646#include "InitialIterator.h"
    4747#include "Translation.h"
    4848
     49#undef B_TRANSLATE_CONTEXT
     50#define B_TRANSLATE_CONTEXT "GrepWindow"
     51
     52
    4953using std::nothrow;
    5054
    5155static const bigtime_t kChangesPulseInterval = 150000;
     
    123127      fChangesIterator(NULL),
    124128      fChangesPulse(NULL),
    125129
    126       fFilePanel(NULL)
     130      fFilePanel(NULL),
     131      fAppCatalog(NULL)
    127132{
    128133    if (fModel == NULL)
    129134        return;
    130135
     136    be_locale->GetAppCatalog(&fAppCatalog);
     137   
    131138    entry_ref directory;
    132139    _InitRefsReceived(&directory, message);
    133140
     
    399406    if (entry.InitCheck() == B_OK) {
    400407        BPath path;
    401408        if (entry.GetPath(&path) == B_OK)
    402             title << APP_NAME << ": " << path.Path();
     409            if (strcmp(APP_NAME, "TextSearch") == 0)
     410                title << B_TRANSLATE("TextSearch") << path.Path();
     411            else
     412                title << APP_NAME << ": " << path.Path();
    403413    }
    404414
    405415    if (!title.Length())
    406         title = APP_NAME;
     416        if (strcmp(APP_NAME, "TextSearch") == 0)
     417            title << B_TRANSLATE("TextSearch");
     418        else
     419            title = APP_NAME;
    407420
    408421    SetTitle(title.String());
    409422}
     
    414427{
    415428    fMenuBar = new BMenuBar(BRect(0,0,1,1), "menubar");
    416429
    417     fFileMenu = new BMenu(_T("File"));
    418     fActionMenu = new BMenu(_T("Actions"));
    419     fPreferencesMenu = new BMenu(_T("Settings"));
    420     fHistoryMenu = new BMenu(_T("History"));
    421     fEncodingMenu = new BMenu(_T("Encoding"));
     430    fFileMenu = new BMenu(B_TRANSLATE("File"));
     431    fActionMenu = new BMenu(B_TRANSLATE("Actions"));
     432    fPreferencesMenu = new BMenu(B_TRANSLATE("Settings"));
     433    fHistoryMenu = new BMenu(B_TRANSLATE("History"));
     434    fEncodingMenu = new BMenu(B_TRANSLATE("Encoding"));
    422435
    423436    fNew = new BMenuItem(
    424         _T("New window"), new BMessage(MSG_NEW_WINDOW), 'N');
     437        B_TRANSLATE("New window"), new BMessage(MSG_NEW_WINDOW), 'N');
    425438
    426439    fOpen = new BMenuItem(
    427         _T("Set which files to search"), new BMessage(MSG_OPEN_PANEL), 'F');
     440        B_TRANSLATE("Set which files to search"), new BMessage(MSG_OPEN_PANEL), 'F');
    428441
    429442    fClose = new BMenuItem(
    430         _T("Close"), new BMessage(B_QUIT_REQUESTED), 'W');
     443        B_TRANSLATE("Close"), new BMessage(B_QUIT_REQUESTED), 'W');
    431444
    432445    fAbout = new BMenuItem(
    433         _T("About TextSearch" B_UTF8_ELLIPSIS), new BMessage(B_ABOUT_REQUESTED));
     446        B_TRANSLATE("About TextSearch" B_UTF8_ELLIPSIS), new BMessage(B_ABOUT_REQUESTED));
    434447
    435448    fQuit = new BMenuItem(
    436         _T("Quit"), new BMessage(MSG_QUIT_NOW), 'Q');
     449        B_TRANSLATE("Quit"), new BMessage(MSG_QUIT_NOW), 'Q');
    437450
    438451    fSearch = new BMenuItem(
    439         _T("Search"), new BMessage(MSG_START_CANCEL), 'S');
     452        B_TRANSLATE("Search"), new BMessage(MSG_START_CANCEL), 'S');
    440453
    441454    fSelectAll = new BMenuItem(
    442         _T("Select all"), new BMessage(MSG_SELECT_ALL), 'A');
     455        B_TRANSLATE("Select all"), new BMessage(MSG_SELECT_ALL), 'A');
    443456
    444457    fTrimSelection = new BMenuItem(
    445         _T("Trim to selection"), new BMessage(MSG_TRIM_SELECTION), 'T');
     458        B_TRANSLATE("Trim to selection"), new BMessage(MSG_TRIM_SELECTION), 'T');
    446459
    447460    fOpenSelection = new BMenuItem(
    448         _T("Open selection"), new BMessage(MSG_OPEN_SELECTION), 'O');
     461        B_TRANSLATE("Open selection"), new BMessage(MSG_OPEN_SELECTION), 'O');
    449462
    450463    fSelectInTracker = new BMenuItem(
    451         _T("Show files in Tracker"), new BMessage(MSG_SELECT_IN_TRACKER), 'K');
     464        B_TRANSLATE("Show files in Tracker"), new BMessage(MSG_SELECT_IN_TRACKER), 'K');
    452465
    453466    fCopyText = new BMenuItem(
    454         _T("Copy text to clipboard"), new BMessage(MSG_COPY_TEXT), 'B');
     467        B_TRANSLATE("Copy text to clipboard"), new BMessage(MSG_COPY_TEXT), 'B');
    455468
    456469    fRecurseLinks = new BMenuItem(
    457         _T("Follow symbolic links"), new BMessage(MSG_RECURSE_LINKS));
     470        B_TRANSLATE("Follow symbolic links"), new BMessage(MSG_RECURSE_LINKS));
    458471
    459472    fRecurseDirs = new BMenuItem(
    460         _T("Look in sub-folders"), new BMessage(MSG_RECURSE_DIRS));
     473        B_TRANSLATE("Look in sub-folders"), new BMessage(MSG_RECURSE_DIRS));
    461474
    462475    fSkipDotDirs = new BMenuItem(
    463         _T("Skip sub-folders starting with a dot"), new BMessage(MSG_SKIP_DOT_DIRS));
     476        B_TRANSLATE("Skip sub-folders starting with a dot"), new BMessage(MSG_SKIP_DOT_DIRS));
    464477
    465478    fCaseSensitive = new BMenuItem(
    466         _T("Case-sensitive"), new BMessage(MSG_CASE_SENSITIVE));
     479        B_TRANSLATE("Case-sensitive"), new BMessage(MSG_CASE_SENSITIVE));
    467480
    468481    fEscapeText = new BMenuItem(
    469         _T("Escape search text"), new BMessage(MSG_ESCAPE_TEXT));
     482        B_TRANSLATE("Escape search text"), new BMessage(MSG_ESCAPE_TEXT));
    470483
    471484    fTextOnly = new BMenuItem(
    472         _T("Text files only"), new BMessage(MSG_TEXT_ONLY));
     485        B_TRANSLATE("Text files only"), new BMessage(MSG_TEXT_ONLY));
    473486
    474487    fInvokePe = new BMenuItem(
    475         _T("Open files in Pe"), new BMessage(MSG_INVOKE_PE));
     488        B_TRANSLATE("Open files in Pe"), new BMessage(MSG_INVOKE_PE));
    476489
    477490    fShowLinesMenuitem = new BMenuItem(
    478         _T("Show lines"), new BMessage(MSG_MENU_SHOW_LINES), 'L');
     491        B_TRANSLATE("Show lines"), new BMessage(MSG_MENU_SHOW_LINES), 'L');
    479492    fShowLinesMenuitem->SetMarked(true);
    480493
    481494    fUTF8 = new BMenuItem("UTF8", new BMessage('utf8'));
     
    553566    fSearchText->SetModificationMessage(new BMessage(MSG_SEARCH_TEXT));
    554567
    555568    fButton = new BButton(
    556         BRect(0, 1, 80, 1), "Button", _T("Search"),
     569        BRect(0, 1, 80, 1), "Button", B_TRANSLATE("Search"),
    557570        new BMessage(MSG_START_CANCEL), B_FOLLOW_RIGHT);
    558571
    559572    fButton->MakeDefault(true);
     
    561574    fButton->SetEnabled(false);
    562575
    563576    fShowLinesCheckbox = new BCheckBox(
    564         BRect(0, 0, 1, 1), "ShowLines", _T("Show lines"),
     577        BRect(0, 0, 1, 1), "ShowLines", B_TRANSLATE("Show lines"),
    565578        new BMessage(MSG_CHECKBOX_SHOW_LINES), B_FOLLOW_LEFT);
    566579
    567580    fShowLinesCheckbox->SetValue(B_CONTROL_ON);
     
    792805        fSearchText->SetEnabled(false);
    793806
    794807        fButton->MakeFocus(true);
    795         fButton->SetLabel(_T("Cancel"));
     808        fButton->SetLabel(B_TRANSLATE("Cancel"));
    796809        fSearch->SetEnabled(false);
    797810
    798811        // We need to remember the search pattern, because during
     
    842855    fHistoryMenu->SetEnabled(true);
    843856    fEncodingMenu->SetEnabled(true);
    844857
    845     fButton->SetLabel(_T("Search"));
     858    fButton->SetLabel(B_TRANSLATE("Search"));
    846859    fButton->SetEnabled(true);
    847860    fSearch->SetEnabled(true);
    848861
     
    12801293{
    12811294    if (fSearchResults->CurrentSelection() < 0) {
    12821295        BString text;
    1283         text << _T("Please select the files you wish to keep searching.");
     1296        text << B_TRANSLATE("Please select the files you wish to keep searching.");
    12841297        text << "\n";
    1285         text << _T("The unselected files will be removed from the list.");
     1298        text << B_TRANSLATE("The unselected files will be removed from the list.");
    12861299        text << "\n";
    1287         BAlert* alert = new BAlert(NULL, text.String(), _T("OK"), NULL, NULL,
     1300        BAlert* alert = new BAlert(NULL, text.String(), B_TRANSLATE("OK"), NULL, NULL,
    12881301            B_WIDTH_AS_USUAL, B_WARNING_ALERT);
    12891302        alert->Go(NULL);
    12901303        return;
     
    13751388{
    13761389    if (fSearchResults->CurrentSelection() < 0) {
    13771390        BAlert* alert = new BAlert("Info",
    1378             _T("Please select the files you wish to have selected for you in "
     1391            B_TRANSLATE("Please select the files you wish to have selected for you in "
    13791392                "Tracker."),
    1380             _T("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
     1393            B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
    13811394        alert->Go(NULL);
    13821395        return;
    13831396    }
     
    14371450    }
    14381451
    14391452    if (!_AreAllFoldersOpenInTracker(&folderList)) {
    1440         BAlert* alert = new BAlert(NULL,
    1441             _T(APP_NAME " couldn't open one or more folders,"),
    1442             _T("OK"), NULL, NULL, B_WIDTH_AS_USUAL,
    1443             B_STOP_ALERT);
     1453        BString str1;
     1454        if (strcmp(APP_NAME, "TextSearch") == 0)
     1455            str1 << B_TRANSLATE("TextSearch couldn't open one or more folders.");
     1456        else
     1457            str1 << APP_NAME << " couldn't open one or more folders.";
     1458        BAlert* alert = new BAlert(NULL, str1.String(), B_TRANSLATE("OK"),
     1459            NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
    14441460        alert->Go(NULL);
    14451461        goto out;
    14461462    }
     
    14691485GrepWindow::_OnAboutRequested()
    14701486{
    14711487    BString text;
    1472     text << APP_NAME << " " << "\n\n";
     1488    if (strcmp(APP_NAME, "TextSearch") == 0)
     1489        text << B_TRANSLATE("TextSearch") << "\n\n";
     1490    else
     1491        text << APP_NAME << " " << "\n\n";
    14731492    int32 titleLength = text.Length();
    1474     text << _T("Created by Matthijs Hollemans.") << "\n\n";
    1475     text << _T("Contributed to by ");
    1476     text << _T("Peter Hinely, Serge Fantino, Hideki Naito, Oscar Lesta, "
    1477         "Oliver Tappe, Jonas Sundström, Luc Schrijvers and momoziro.");
    1478     text << "\n";
     1493    text << B_TRANSLATE("Created by Matthijs Hollemans.") << "\n\n";
     1494    text << B_TRANSLATE("Contributed to by ");
     1495    text << "Peter Hinely, Serge Fantino, Hideki Naito, Oscar Lesta, "
     1496        "Oliver Tappe, Jonas Sundström, Luc Schrijvers ";
     1497    text << B_TRANSLATE("and");
     1498    text << " momoziro.\n";
    14791499
    1480     BAlert* alert = new BAlert("TextSearch", text.String(), _T("OK"), NULL,
     1500    BAlert* alert = new BAlert("TextSearch", text.String(), B_TRANSLATE("OK"), NULL,
    14811501        NULL, B_WIDTH_AS_USUAL, B_INFO_ALERT);
    14821502
    14831503    BTextView* view = alert->TextView();
  • src/apps/text_search/Jamfile

     
    2424
    2525    $(additionalBeOSSources)
    2626
    27     : be tracker textencoding libshared.a $(TARGET_LIBSUPC++)
     27    : be locale tracker textencoding libshared.a $(TARGET_LIBSUPC++)
    2828    : TextSearch.rdef
    2929;
     30
     31DoCatalogs TextSearch :
     32    x-vnd.Haiku.TextSearch
     33    :
     34    GrepWindow.cpp
     35    Grepper.cpp
     36;
  • src/apps/text_search/GrepWindow.h

     
    2222#ifndef GREP_WINDOW_H
    2323#define GREP_WINDOW_H
    2424
     25#include <Catalog.h>
    2526#include <InterfaceKit.h>
    2627#include <FilePanel.h>
     28#include <Locale.h>
    2729
    2830#include "Model.h"
    2931#include "GrepListView.h"
     
    143145            BMessageRunner*     fChangesPulse;
    144146
    145147            BFilePanel*         fFilePanel;
     148            BCatalog            fAppCatalog;
    146149};
    147150
    148151#endif // GREP_WINDOW_H