From: H.G. Muller Date: Mon, 23 Aug 2010 11:23:22 +0000 (+0200) Subject: Internationalization for WinBoard X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=79173c63a1184a8c99f5b25ae5d20ccf27ac01bc;p=xboard.git Internationalization for WinBoard A function Translate() was added, which uses a list of item dialogs, reads their value, and replaces it by a translation (if available). It also reads the window title and sets a translation. Calls to this routine are added in the initialization code of every dialog callback. In addition all translatable strings in the WnBoard front end are marked by the gettext macro _(). Because WB is not gettexted yet, a hard re-definition of this macro is added in each file using it, to the string-translation routine T_() supplied in winboard.c. Code to read the translation file, and translate the menu texts is added in winboard.c. In backend.c the meaning of the gettet macros is redefined for the WIN32 case. --- diff --git a/backend.c b/backend.c index 8a2a8d8..7174d7a 100644 --- a/backend.c +++ b/backend.c @@ -132,8 +132,13 @@ extern int gettimeofday(struct timeval *, struct timezone *); # define _(s) gettext (s) # define N_(s) gettext_noop (s) #else -# define _(s) (s) -# define N_(s) s +# ifdef WIN32 +# define _(s) T_(s) +# define N_(s) s +# else +# define _(s) (s) +# define N_(s) s +# endif #endif diff --git a/winboard/wchat.c b/winboard/wchat.c index 80ea286..ecfbcbd 100644 --- a/winboard/wchat.c +++ b/winboard/wchat.c @@ -189,6 +189,7 @@ LRESULT CALLBACK ChatProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam switch (message) { case WM_INITDIALOG: + Translate(hDlg, DLG_Chat); if(partner<0) { for(i=0; ihf, MAKELPARAM(FALSE, 0)); SetDlgItemText(hDlg, OPT_TagsText, editTagsText); @@ -71,10 +74,10 @@ EditTagsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) EnableWindow(GetDlgItem(hDlg, OPT_EditTags), !canEditTags); SendMessage(hwndText, EM_SETREADONLY, !canEditTags, 0); if (canEditTags) { - SetWindowText(hDlg, "Edit Tags"); + SetWindowText(hDlg, _("Edit Tags")); SetFocus(hwndText); } else { - SetWindowText(hDlg, "Tags"); + SetWindowText(hDlg, _("Tags")); SetFocus(GetDlgItem(hDlg, IDOK)); } if (!editTagsDialog) { @@ -126,7 +129,7 @@ EditTagsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } *p = NULLCHAR; err = ReplaceTags(str, &gameInfo); - if (err) DisplayError("Error replacing tags.", err); + if (err) DisplayError(_("Error replacing tags."), err); free(str); } diff --git a/winboard/wengineoutput.c b/winboard/wengineoutput.c index 2acb145..0633f8a 100644 --- a/winboard/wengineoutput.c +++ b/winboard/wengineoutput.c @@ -284,6 +284,7 @@ LRESULT CALLBACK EngineOutputProc( HWND hDlg, UINT message, WPARAM wParam, LPARA if( engineOutputDialog == NULL ) { engineOutputDialog = hDlg; + Translate(hDlg, DLG_EngineOutput); RestoreWindowPlacement( hDlg, &wpEngineOutput ); /* Restore window placement */ ResizeWindowControls( windowMode ); diff --git a/winboard/wevalgraph.c b/winboard/wevalgraph.c index ec57ab3..bca5b95 100644 --- a/winboard/wevalgraph.c +++ b/winboard/wevalgraph.c @@ -171,6 +171,7 @@ LRESULT CALLBACK EvalGraphProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM l switch (message) { case WM_INITDIALOG: + Translate(hDlg, DLG_EvalGraph); if( evalGraphDialog == NULL ) { evalGraphDialog = hDlg; diff --git a/winboard/wgamelist.c b/winboard/wgamelist.c index d736a8d..e582a46 100644 --- a/winboard/wgamelist.c +++ b/winboard/wgamelist.c @@ -41,6 +41,8 @@ #include "wsnap.h" +#define _(s) T_(s) + /* Module globals */ static BOOLEAN gameListUp = FALSE; static FILE* gameFile; @@ -122,7 +124,7 @@ static int GameListUpdateTitle( HWND hDlg, char * pszTitle, int item_count, int { char buf[256]; - sprintf( buf, "%s - %d/%d games", pszTitle, item_count, item_total ); + sprintf( buf, _("%s - %d/%d games"), pszTitle, item_count, item_total ); if( stats != 0 ) { sprintf( buf+strlen(buf), " (%d-%d-%d)", stats->white_wins, stats->black_wins, stats->drawn ); @@ -152,6 +154,7 @@ GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) switch (message) { case WM_INITDIALOG: + Translate(hDlg, DLG_GameList); GetWindowText( hDlg, szDlgTitle, sizeof(szDlgTitle) ); szDlgTitle[ sizeof(szDlgTitle)-1 ] = '\0'; @@ -200,12 +203,11 @@ GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) newSizeX, newSizeY); sizeX = newSizeX; sizeY = newSizeY; - } - else - GetActualPlacement( gameListDialog, &wpGameList ); + } else + GetActualPlacement( gameListDialog, &wpGameList ); } - GameListUpdateTitle( hDlg, "Game List", count, ((ListGame *) gameList.tailPred)->number, &stats ); + GameListUpdateTitle( hDlg, _("Game List"), count, ((ListGame *) gameList.tailPred)->number, &stats ); // [HGM] always update title return FALSE; case WM_SIZE: @@ -264,7 +266,7 @@ GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) nItem = SendDlgItemMessage(hDlg, OPT_GameListText, LB_GETCURSEL, 0, 0); if (nItem < 0) { /* is this possible? */ - DisplayError("No game selected", 0); + DisplayError(_("No game selected"), 0); return TRUE; } break; /* load the game*/ @@ -274,7 +276,7 @@ GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) nItem++; if (nItem >= ((ListGame *) gameList.tailPred)->number) { /* [AS] Removed error message */ - /* DisplayError("Can't go forward any further", 0); */ + /* DisplayError(_("Can't go forward any further"), 0); */ return TRUE; } SendDlgItemMessage(hDlg, OPT_GameListText, LB_SETCURSEL, nItem, 0); @@ -285,7 +287,7 @@ GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) nItem--; if (nItem < 0) { /* [AS] Removed error message, added return */ - /* DisplayError("Can't back up any further", 0); */ + /* DisplayError(_("Can't back up any further"), 0); */ return TRUE; } SendDlgItemMessage(hDlg, OPT_GameListText, LB_SETCURSEL, nItem, 0); @@ -299,7 +301,7 @@ GameListDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if( GetDlgItemText( hDlg, IDC_GameListFilter, filter, sizeof(filter) ) >= 0 ) { filter[ sizeof(filter)-1 ] = '\0'; count = GameListToListBox( hDlg, TRUE, filter, &stats ); - GameListUpdateTitle( hDlg, "Game List", count, ((ListGame *) gameList.tailPred)->number, &stats ); + GameListUpdateTitle( hDlg, _("Game List"), count, ((ListGame *) gameList.tailPred)->number, &stats ); } } return FALSE; @@ -428,7 +430,7 @@ VOID ShowGameListProc() if (gameFileName) { GameListPopUp(gameFile, gameFileName); } else { - DisplayError("No game list", 0); + DisplayError(_("No game list"), 0); } } } @@ -442,7 +444,7 @@ HGLOBAL ExportGameListAsText() DWORD dwLen = 0; if( ! gameFileName || ((ListGame *) gameList.tailPred)->number <= 0 ) { - DisplayError("Game list not loaded or empty", 0); + DisplayError(_(_("Game list not loaded or empty")), 0); return NULL; } diff --git a/winboard/whistory.c b/winboard/whistory.c index 854557a..96a08e2 100644 --- a/winboard/whistory.c +++ b/winboard/whistory.c @@ -151,6 +151,7 @@ LRESULT CALLBACK HistoryDialogProc( HWND hDlg, UINT message, WPARAM wParam, LPAR case WM_INITDIALOG: if( moveHistoryDialog == NULL ) { moveHistoryDialog = hDlg; + Translate(hDlg, DLG_MoveHistory); /* Enable word wrapping and notifications */ SendDlgItemMessage( moveHistoryDialog, IDC_MoveHistory, EM_SETTARGETDEVICE, 0, 0 ); diff --git a/winboard/winboard.c b/winboard/winboard.c index 96bca01..243ff29 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -225,6 +225,212 @@ static struct { int x; int y; int mode; } backTextureSquareInfo[BOARD_RANKS][BOA #endif #endif +#define INTERNATIONAL + +#ifdef INTERNATIONAL +# define _(s) T_(s) +# define N_(s) s +#else +# define _(s) s +# define N_(s) s +# define T_(s) s +# define Translate(x, y) +# define LoadLanguageFile(s) +#endif + +#ifdef INTERNATIONAL + +Boolean barbaric; // flag indicating if translation is needed + +// list of item numbers used in each dialog (used to alter language at run time) + +#define ABOUTBOX -1 /* not sure why these are needed */ +#define ABOUTBOX2 -1 + +int dialogItems[][40] = { +{ ABOUTBOX, IDOK, 400 }, +{ DLG_TimeControl, IDC_Babble, OPT_TCUseMoves, OPT_TCUseInc, OPT_TCUseFixed, + OPT_TCtext1, OPT_TCtext2, OPT_TCitext1, OPT_TCitext2, OPT_TCftext, GPB_Factors, IDC_Factor1, IDC_Factor2, IDOK, IDCANCEL }, +{ DLG_LoadOptions, OPT_Autostep, OPT_AStext1, IDOK, IDCANCEL }, +{ DLG_SaveOptions, OPT_Autosave, OPT_AVPrompt, OPT_AVToFile, OPT_AVBrowse, + 801, OPT_PGN, OPT_Old, OPT_OutOfBookInfo, IDOK, IDCANCEL }, +{ 1536, 1090, IDC_Directories, 1089, 1091, IDOK, IDCANCEL, 1038, IDC_IndexNr, 1037 }, +{ DLG_CommPort, IDOK, IDCANCEL, IDC_Port, IDC_Rate, IDC_Bits, IDC_Parity, + IDC_Stop, IDC_Flow, OPT_SerialHelp }, +{ DLG_EditComment, IDOK, OPT_CancelComment, OPT_ClearComment, OPT_EditComment }, +{ DLG_PromotionKing, PB_Chancellor, PB_Archbishop, PB_Queen, PB_Rook, + PB_Bishop, PB_Knight, PB_King, IDCANCEL, IDC_Yes, IDC_No, IDC_Centaur }, +{ ABOUTBOX2, IDC_ChessBoard }, +{ DLG_GameList, OPT_GameListLoad, OPT_GameListPrev, OPT_GameListNext, + OPT_GameListClose, IDC_GameListDoFilter }, +{ DLG_EditTags, IDOK, OPT_TagsCancel, OPT_EditTags }, +{ DLG_Error, IDOK }, +{ DLG_Colorize, IDOK, IDCANCEL, OPT_ChooseColor, OPT_Bold, OPT_Italic, + OPT_Underline, OPT_Strikeout, OPT_Sample }, +{ DLG_Question, IDOK, IDCANCEL, OPT_QuestionText }, +{ DLG_Startup, IDC_Welcome, OPT_ChessEngine, OPT_ChessServer, OPT_View, + IDC_SPECIFY_ENG_STATIC, IDC_SPECIFY_SERVER_STATIC, OPT_AnyAdditional, + IDOK, IDCANCEL, IDM_HELPCONTENTS }, +{ DLG_IndexNumber, IDC_Index }, +{ DLG_TypeInMove, IDOK, IDCANCEL }, +{ DLG_TypeInName, IDOK, IDCANCEL }, +{ DLG_Sound, IDC_Event, OPT_NoSound, OPT_DefaultBeep, OPT_BuiltInSound, + OPT_WavFile, OPT_BrowseSound, OPT_DefaultSounds, IDOK, IDCANCEL, OPT_PlaySound }, +{ DLG_GeneralOptions, IDOK, IDCANCEL, OPT_AlwaysOnTop, OPT_HighlightLastMove, + OPT_AlwaysQueen, OPT_PeriodicUpdates, OPT_AnimateDragging, OPT_PonderNextMove, OPT_AnimateMoving, OPT_PopupExitMessage, OPT_AutoFlag, OPT_PopupMoveErrors, + OPT_AutoFlipView, OPT_ShowButtonBar, OPT_AutoRaiseBoard, OPT_ShowCoordinates, + OPT_Blindfold, OPT_ShowThinking, OPT_HighlightDragging, OPT_TestLegality, + OPT_SaveExtPGN, OPT_HideThinkFromHuman, OPT_ExtraInfoInMoveHistory, + OPT_HighlightMoveArrow, OPT_AutoLogo }, +{ DLG_IcsOptions, IDOK, IDCANCEL, OPT_AutoComment, OPT_AutoKibitz, OPT_AutoObserve, + OPT_GetMoveList, OPT_LocalLineEditing, OPT_QuietPlay, OPT_SeekGraph, OPT_AutoRefresh, + OPT_BgObserve, OPT_DualBoard, OPT_Premove, OPT_PremoveWhite, OPT_PremoveBlack, + OPT_SmartMove, OPT_IcsAlarm, IDC_Sec, OPT_ChooseShoutColor, OPT_ChooseSShoutColor, + OPT_ChooseChannel1Color, OPT_ChooseChannelColor, OPT_ChooseKibitzColor, + OPT_ChooseTellColor, OPT_ChooseChallengeColor, OPT_ChooseRequestColor, + OPT_ChooseSeekColor, OPT_ChooseNormalColor, OPT_ChooseBackgroundColor, + OPT_DefaultColors, OPT_DontColorize, IDC_Boxes, GPB_Colors, GPB_Premove, + GPB_General, GPB_Alarm }, +{ DLG_BoardOptions, IDOK, IDCANCEL, OPT_SizeTiny, OPT_SizeTeeny, OPT_SizeDinky, + OPT_SizePetite, OPT_SizeSlim, OPT_SizeSmall, OPT_SizeMediocre, OPT_SizeMiddling, + OPT_SizeAverage, OPT_SizeModerate, OPT_SizeMedium, OPT_SizeBulky, OPT_SizeLarge, + OPT_SizeBig, OPT_SizeHuge, OPT_SizeGiant, OPT_SizeColossal, OPT_SizeTitanic, + OPT_ChooseLightSquareColor, OPT_ChooseDarkSquareColor, OPT_ChooseWhitePieceColor, + OPT_ChooseBlackPieceColor, OPT_ChooseHighlightSquareColor, OPT_ChoosePremoveHighlightColor, + OPT_Monochrome, OPT_AllWhite, OPT_UpsideDown, OPT_DefaultBoardColors, GPB_Colors, + IDC_Light, IDC_Dark, IDC_White, IDC_Black, IDC_High, IDC_PreHigh, GPB_Size }, +{ DLG_NewVariant, IDOK, IDCANCEL, OPT_VariantNormal, OPT_VariantFRC, OPT_VariantWildcastle, + OPT_VariantNocastle, OPT_VariantLosers, OPT_VariantGiveaway, OPT_VariantSuicide, + OPT_Variant3Check, OPT_VariantTwoKings, OPT_VariantAtomic, OPT_VariantCrazyhouse, + OPT_VariantBughouse, OPT_VariantTwilight, OPT_VariantShogi, OPT_VariantSuper, + OPT_VariantKnightmate, OPT_VariantBerolina, OPT_VariantCylinder, OPT_VariantFairy, + OPT_VariantMakruk, OPT_VariantGothic, OPT_VariantCapablanca, OPT_VariantJanus, + OPT_VariantCRC, OPT_VariantFalcon, OPT_VariantCourier, OPT_VariantGreat, + OPT_VariantShatranj, OPT_VariantXiangqi, GPB_Variant, GPB_Board, IDC_Height, + IDC_Width, IDC_Hand, IDC_Pieces, IDC_Def }, +{ DLG_Fonts, IDOK, IDCANCEL, OPT_ChooseClockFont, OPT_ChooseMessageFont, + OPT_ChooseCoordFont, OPT_ChooseTagFont, OPT_ChooseCommentsFont, OPT_ChooseConsoleFont, OPT_ChooseMoveHistoryFont, OPT_DefaultFonts, + OPT_ClockFont, OPT_MessageFont, OPT_CoordFont, OPT_EditTagsFont, + OPT_CommentsFont, OPT_MessageFont5, GPB_Current, GPB_All, OPT_MessageFont6 }, +{ DLG_NewGameFRC, IDC_NFG_Label, IDC_NFG_Random, IDOK, IDCANCEL }, +{ DLG_GameListOptions, IDC_GLT, IDC_GLT_Up, IDC_GLT_Down, IDC_GLT_Restore, + IDC_GLT_Default, IDOK, IDCANCEL, IDC_GLT_RestoreTo }, +{ DLG_MoveHistory }, +{ DLG_EvalGraph }, +{ DLG_EngineOutput, IDC_EngineLabel1, IDC_Engine1_NPS, IDC_EngineLabel2, IDC_Engine2_NPS }, +{ DLG_Chat, IDC_Partner, IDC_Clear, IDC_Send, }, +{ DLG_EnginePlayOptions, IDC_EpPonder, IDC_EpShowThinking, IDC_EpHideThinkingHuman, + IDC_EpPeriodicUpdates, GPB_Adjudications, IDC_Draw, IDC_Moves, IDC_Threshold, + IDC_Centi, IDC_TestClaims, IDC_DetectMates, IDC_MaterialDraws, IDC_TrivialDraws, + GPB_Apply, IDC_Rule, IDC_Repeats, IDC_ScoreAbs1, IDC_ScoreAbs2, IDOK, IDCANCEL }, +{ DLG_OptionsUCI, IDC_PolyDir, IDC_BrowseForPolyglotDir, IDC_Hash, IDC_Path, + IDC_BrowseForEGTB, IDC_Cache, IDC_UseBook, IDC_BrowseForBook, IDC_CPU, IDC_OwnBook1, + IDC_OwnBook2, IDC_Depth, IDC_Variation, IDC_DefGames, IDOK, IDCANCEL }, +{ 0 } +}; + +char languageBuf[40000], *foreign[1000], *english[1000]; + +void +LoadLanguageFile(char *name) +{ //load the file with translations, and make a list of the strings to be translated, and their translations + FILE *f; + int i=0, j=0, n=0, k; + static char oldLanguage[MSG_SIZ]; + if(!strcmp(name, oldLanguage)) return; + if(!name || name[0] == NULLCHAR) return; + if((f = fopen(name, "r")) == NULL) return; + while((k = fgetc(f)) != EOF) { + if(i >= sizeof(languageBuf)) { DisplayError("Language file too big", 0); return; } + languageBuf[i] = k; + if(k == '\n') { + if(languageBuf[n] == '"' && languageBuf[i-1] == '"') { + char *p; + if(p = strstr(languageBuf + n + 1, "\" === \"")) { + if(p > languageBuf+n+2 && p+8 < languageBuf+i) { + if(j >= sizeof(english)) { DisplayError("Too many translated strings", 0); return; } + english[j] = languageBuf + n + 1; *p = 0; + foreign[j++] = p + 7; languageBuf[i-1] = 0; +if(appData.debugMode) fprintf(debugFP, "translation: replace '%s' by '%s'\n", english[j-1], foreign[j-1]); + } + } + } + n = i + 1; + } else if(i > 0 && languageBuf[i-1] == '\\') { + switch(k) { + case 'n': k = '\n'; break; + case 'r': k = '\r'; break; + case 't': k = '\t'; break; + } + languageBuf[--i] = k; + } + i++; + } + fclose(f); + barbaric = (j != 0); + if(barbaric) strcpy(oldLanguage, name); else oldLanguage[0] = NULLCHAR; +} + +char * +T_(char *s) +{ // return the translation of the given string + // efficiency can be improved a lot... + int i=0; +if(appData.debugMode) fprintf(debugFP, "T_(%s)\n", s); + if(!barbaric) return s; + if(!s) return ""; // sanity + while(english[i]) { + if(!strcmp(s, english[i])) return foreign[i]; + i++; + } + return s; +} + +void +Translate(HANDLE hDlg, int dialogID) +{ // translate all text items in the given dialog + int i=0, j, k; + char buf[MSG_SIZ], *s; +//if(appData.debugMode) fprintf(debugFP, "Translate(%d)\n", dialogID); + if(!barbaric) return; + while(dialogItems[i][0] && dialogItems[i][0] != dialogID) i++; // find the dialog description + if(dialogItems[i][0] != dialogID) return; // unknown dialog, should not happen + GetWindowText( hDlg, buf, MSG_SIZ ); + s = T_(buf); +if(appData.debugMode) fprintf(debugFP, "WindowText '%s' -> '%s'\n", buf, s); + if(strcmp(buf, s)) SetWindowText(hDlg, s); // replace by translated string (if different) + for(j=1; k=dialogItems[i][j]; j++) { // translate all listed dialog items + GetDlgItemText(hDlg, k, buf, MSG_SIZ); + if(strlen(buf) == 0) continue; + s = T_(buf); + if(strcmp(buf, s)) SetDlgItemText(hDlg, k, s); // replace by translated string (if different) + } +} + +void +TranslateMenus() +{ + int i, j; + if(barbaric) { + HMENU mainMenu = GetMenu(hwndMain); + for (i=GetMenuItemCount(mainMenu)-1; i>=0; i--) { + HMENU subMenu = GetSubMenu(mainMenu, i); + for(j=GetMenuItemCount(subMenu)-1; j>=0; j--){ + char buf[MSG_SIZ]; + UINT k = GetMenuItemID(subMenu, j); + GetMenuString(subMenu, j, buf, MSG_SIZ, MF_BYPOSITION); + if(buf[0] == NULLCHAR) continue; +//fprintf(debugFP, "menu(%d,%d) = %s (%08x, %08x) %d\n", i, j, buf, mainMenu, subMenu, k); + ModifyMenu(subMenu, j, MF_STRING|MF_BYPOSITION, + k, T_(buf)); + } + } + + } +} + +#endif + typedef struct { char *name; int squareSize; @@ -304,8 +510,8 @@ MyButtonDesc buttonDesc[N_BUTTONS] = int tinyLayout = 0, smallLayout = 0; #define MENU_BAR_ITEMS 7 char *menuBarText[2][MENU_BAR_ITEMS+1] = { - { "&File", "&Mode", "&Action", "&Step", "&Options", "&Help", NULL }, - { "&F", "&M", "&A", "&S", "&O", "&H", NULL }, + { N_("&File"), N_("&Mode"), N_("&Action"), N_("&Step"), N_("&Options"), N_("&Help"), NULL }, + { N_("&F"), N_("&M"), N_("&A"), N_("&S"), N_("&O"), N_("&H"), NULL }, }; @@ -313,17 +519,17 @@ MySound sounds[(int)NSoundClasses]; MyTextAttribs textAttribs[(int)NColorClasses]; MyColorizeAttribs colorizeAttribs[] = { - { (COLORREF)0, 0, "Shout Text" }, - { (COLORREF)0, 0, "SShout/CShout" }, - { (COLORREF)0, 0, "Channel 1 Text" }, - { (COLORREF)0, 0, "Channel Text" }, - { (COLORREF)0, 0, "Kibitz Text" }, - { (COLORREF)0, 0, "Tell Text" }, - { (COLORREF)0, 0, "Challenge Text" }, - { (COLORREF)0, 0, "Request Text" }, - { (COLORREF)0, 0, "Seek Text" }, - { (COLORREF)0, 0, "Normal Text" }, - { (COLORREF)0, 0, "None" } + { (COLORREF)0, 0, N_("Shout Text") }, + { (COLORREF)0, 0, N_("SShout/CShout") }, + { (COLORREF)0, 0, N_("Channel 1 Text") }, + { (COLORREF)0, 0, N_("Channel Text") }, + { (COLORREF)0, 0, N_("Kibitz Text") }, + { (COLORREF)0, 0, N_("Tell Text") }, + { (COLORREF)0, 0, N_("Challenge Text") }, + { (COLORREF)0, 0, N_("Request Text") }, + { (COLORREF)0, 0, N_("Seek Text") }, + { (COLORREF)0, 0, N_("Normal Text") }, + { (COLORREF)0, 0, N_("None") } }; @@ -728,6 +934,8 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) setbuf(debugFP, NULL); } + LoadLanguageFile(appData.language); + InitBackEnd1(); // InitEngineUCI( installDir, &first ); // [HGM] incorporated in InitBackEnd1() @@ -799,6 +1007,7 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) } InitDrawingSizes(boardSize, 0); + TranslateMenus(); InitMenuChecks(); buttonCount = GetSystemMetrics(SM_CMOUSEBUTTONS); @@ -968,7 +1177,7 @@ ParseFontName(char *name, MyFontParams *mfp) q = strchr(p, ':'); if (q) { if (q - p >= sizeof(mfp->faceName)) - ExitArgError("Font name too long:", name); + ExitArgError(_("Font name too long:"), name); memcpy(mfp->faceName, p, q - p); mfp->faceName[q - p] = NULLCHAR; p = q + 1; @@ -977,12 +1186,12 @@ ParseFontName(char *name, MyFontParams *mfp) while (*p && !isdigit(*p)) { *q++ = *p++; if (q - mfp->faceName >= sizeof(mfp->faceName)) - ExitArgError("Font name too long:", name); + ExitArgError(_("Font name too long:"), name); } while (q > mfp->faceName && q[-1] == ' ') q--; *q = NULLCHAR; } - if (!*p) ExitArgError("Font point size missing:", name); + if (!*p) ExitArgError(_("Font point size missing:"), name); mfp->pointSize = (float) atof(p); mfp->bold = (strchr(p, 'b') != NULL); mfp->italic = (strchr(p, 'i') != NULL); @@ -1039,7 +1248,7 @@ ParseColorName(char *name) &red, &green, &blue); } if (count != 3) { - sprintf(buf, "Can't parse color name %s", name); + sprintf(buf, _("Can't parse color name %s"), name); DisplayError(buf, 0); return RGB(0, 0, 0); } @@ -1088,7 +1297,7 @@ ParseBoardSize(void *addr, char *name) } bs++; } - ExitArgError("Unrecognized board size value", name); + ExitArgError(_("Unrecognized board size value"), name); } void @@ -1256,6 +1465,7 @@ PopUpStartupDialog() { FARPROC lpProc; + LoadLanguageFile(appData.language); lpProc = MakeProcInstance((FARPROC)StartupDialog, hInst); DialogBox(hInst, MAKEINTRESOURCE(DLG_Startup), NULL, (DLGPROC)lpProc); FreeProcInstance(lpProc); @@ -1831,7 +2041,7 @@ InsertInPalette(COLORREF color) LPPALETTEENTRY pe = &(pLogPal->palPalEntry[pLogPal->palNumEntries]); if (pLogPal->palNumEntries++ >= PALETTESIZE) { - DisplayFatalError("Too many colors", 0, 1); + DisplayFatalError(_("Too many colors"), 0, 1); pLogPal->palNumEntries--; return; } @@ -1973,7 +2183,7 @@ InitDrawingSizes(BoardSize boardSize, int flags) for (i=0; menuBarText[tinyLayout][i]; i++) { ModifyMenu(hmenu, i, MF_STRING|MF_BYPOSITION|MF_POPUP, - (UINT)GetSubMenu(hmenu, i), menuBarText[tinyLayout][i]); + (UINT)GetSubMenu(hmenu, i), T_(menuBarText[tinyLayout][i])); } DrawMenuBar(hwndMain); } @@ -1984,14 +2194,14 @@ InitDrawingSizes(BoardSize boardSize, int flags) /* Get text area sizes */ hdc = GetDC(hwndMain); if (appData.clockMode) { - sprintf(buf, "White: %s", TimeString(23*60*60*1000L)); + sprintf(buf, _("White: %s"), TimeString(23*60*60*1000L)); } else { - sprintf(buf, "White"); + sprintf(buf, _("White")); } oldFont = SelectObject(hdc, font[boardSize][CLOCK_FONT]->hf); GetTextExtentPoint(hdc, buf, strlen(buf), &clockSize); SelectObject(hdc, font[boardSize][MESSAGE_FONT]->hf); - str = "We only care about the height here"; + str = _("We only care about the height here"); GetTextExtentPoint(hdc, str, strlen(str), &messageSize); SelectObject(hdc, oldFont); ReleaseDC(hwndMain, hdc); @@ -3741,11 +3951,11 @@ typedef struct { } DropEnable; DropEnable dropEnables[] = { - { 'P', DP_Pawn, "Pawn" }, - { 'N', DP_Knight, "Knight" }, - { 'B', DP_Bishop, "Bishop" }, - { 'R', DP_Rook, "Rook" }, - { 'Q', DP_Queen, "Queen" }, + { 'P', DP_Pawn, N_("Pawn") }, + { 'N', DP_Knight, N_("Knight") }, + { 'B', DP_Bishop, N_("Bishop") }, + { 'R', DP_Rook, N_("Rook") }, + { 'Q', DP_Queen, N_("Queen") }, }; VOID @@ -3761,7 +3971,7 @@ SetupDropMenu(HMENU hmenu) dropEnables[i].piece); count = 0; while (p && *p++ == dropEnables[i].piece) count++; - sprintf(item, "%s %d", dropEnables[i].name, count); + sprintf(item, "%s %d", T_(dropEnables[i].name), count); enable = count > 0 || !appData.testLegality /*!!temp:*/ || (gameInfo.variant == VariantCrazyhouse && !appData.icsActive); @@ -4017,6 +4227,7 @@ Promotion(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: /* message: initialize dialog box */ /* Center the dialog over the application window */ CenterWindow(hDlg, GetWindow(hDlg, GW_OWNER)); + Translate(hDlg, DLG_PromotionKing); ShowWindow(GetDlgItem(hDlg, PB_King), (!appData.testLegality || gameInfo.variant == VariantSuicide || gameInfo.variant == VariantGiveaway || gameInfo.variant == VariantSuper ) ? @@ -4141,7 +4352,7 @@ LoadGameDialog(HWND hwnd, char* title) if (number == 0) { int error = GameListBuild(f); if (error) { - DisplayError("Cannot build game list", error); + DisplayError(_("Cannot build game list"), error); } else if (!ListEmpty(&gameList) && ((ListGame *) gameList.tailPred)->number > 1) { GameListPopUp(f, fileTitle); @@ -4363,7 +4574,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case IDM_LoadGame: - LoadGameDialog(hwnd, "Load Game from File"); + LoadGameDialog(hwnd, _("Load Game from File")); break; case IDM_LoadNextGame: @@ -4386,7 +4597,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) f = OpenFileDialog(hwnd, "rb", "", appData.oldSaveStyle ? "pos" : "fen", POSITION_FILT, - "Load Position from File", &number, fileTitle, NULL); + _("Load Position from File"), &number, fileTitle, NULL); if (f != NULL) { LoadPosition(f, number, fileTitle); } @@ -4409,7 +4620,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) f = OpenFileDialog(hwnd, "a", defName, appData.oldSaveStyle ? "gam" : "pgn", GAME_FILT, - "Save Game to File", NULL, fileTitle, NULL); + _("Save Game to File"), NULL, fileTitle, NULL); if (f != NULL) { SaveGame(f, 0, ""); } @@ -4420,7 +4631,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) f = OpenFileDialog(hwnd, "a", defName, appData.oldSaveStyle ? "pos" : "fen", POSITION_FILT, - "Save Position to File", NULL, fileTitle, NULL); + _("Save Position to File"), NULL, fileTitle, NULL); if (f != NULL) { SavePosition(f, 0, ""); } @@ -4582,7 +4793,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case IDM_AnalysisMode: if (!first.analysisSupport) { - sprintf(buf, "%s does not support analysis", first.tidy); + sprintf(buf, _("%s does not support analysis"), first.tidy); DisplayError(buf, 0); } else { SAY("analyzing current position"); @@ -4619,12 +4830,12 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case IDM_AnalyzeFile: if (!first.analysisSupport) { char buf[MSG_SIZ]; - sprintf(buf, "%s does not support analysis", first.tidy); + sprintf(buf, _("%s does not support analysis"), first.tidy); DisplayError(buf, 0); } else { if (!appData.showThinking) ToggleShowThinking(); AnalyzeFileEvent(); - LoadGameDialog(hwnd, "Analyze Game from File"); + LoadGameDialog(hwnd, _("Analyze Game from File")); AnalysisPeriodicEvent(1); } break; @@ -4873,7 +5084,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (!MyHelp (hwnd, "winboard.hlp", HELP_KEY,(DWORD)(LPSTR)"CONTENTS") && !HtmlHelp(hwnd, "winboard.chm", 0, 0) ) { MessageBox (GetFocus(), - "Unable to activate help", + _("Unable to activate help"), szAppName, MB_SYSTEMMODAL|MB_OK|MB_ICONHAND); } break; @@ -4882,7 +5093,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (!MyHelp (hwnd, "winboard.hlp", HELP_PARTIALKEY, (DWORD)(LPSTR)"") && !HtmlHelp(hwnd, "winboard.chm", 0, 0) ) { MessageBox (GetFocus(), - "Unable to activate help", + _("Unable to activate help"), szAppName, MB_SYSTEMMODAL|MB_OK|MB_ICONHAND); } break; @@ -4890,7 +5101,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case IDM_HELPHELP: if(!WinHelp(hwnd, (LPSTR)NULL, HELP_HELPONHELP, 0)) { MessageBox (GetFocus(), - "Unable to activate help", + _("Unable to activate help"), szAppName, MB_SYSTEMMODAL|MB_OK|MB_ICONHAND); } break; @@ -4904,12 +5115,12 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case IDM_DirectCommand1: - AskQuestionEvent("Direct Command", - "Send to chess program:", "", "1"); + AskQuestionEvent(_("Direct Command"), + _("Send to chess program:"), "", "1"); break; case IDM_DirectCommand2: - AskQuestionEvent("Direct Command", - "Send to second chess program:", "", "2"); + AskQuestionEvent(_("Direct Command"), + _("Send to second chess program:"), "", "2"); break; case EP_WhitePawn: @@ -5326,7 +5537,7 @@ MyLoadSound(MySound *ms) } if (!ok) { char buf[MSG_SIZ]; - sprintf(buf, "Error loading sound %s", ms->name); + sprintf(buf, _("Error loading sound %s"), ms->name); DisplayError(buf, GetLastError()); } return ok; @@ -5474,13 +5685,13 @@ OpenFileDialog(HWND hwnd, char *write, char *defName, char *defExt, // [HGM] dia /* open the file */ f = fopen(openFileName.lpstrFile, write); if (f == NULL) { - MessageBox(hwnd, "File open failed", NULL, + MessageBox(hwnd, _("File open failed"), NULL, MB_OK|MB_ICONEXCLAMATION); return NULL; } } else { int err = CommDlgExtendedError(); - if (err != 0) DisplayError("Internal error in file dialog box", err); + if (err != 0) DisplayError(_("Internal error in file dialog box"), err); return FALSE; } return f; @@ -5743,6 +5954,7 @@ StartupDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: /* Center the dialog */ CenterWindow (hDlg, GetDesktopWindow()); + Translate(hDlg, DLG_Startup); /* Initialize the dialog items */ InitEngineBox(hDlg, GetDlgItem(hDlg, OPT_ChessEngineName), appData.firstChessProgram, "fd", appData.firstDirectory, @@ -5807,8 +6019,8 @@ StartupDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) appData.noChessProgram = TRUE; appData.icsActive = FALSE; } else { - MessageBox(hDlg, "Choose an option, or cancel to exit", - "Option Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox(hDlg, _("Choose an option, or cancel to exit"), + _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return TRUE; } if (IsDlgButtonChecked(hDlg, OPT_AnyAdditional)) { @@ -5826,7 +6038,7 @@ StartupDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case IDM_HELPCONTENTS: if (!WinHelp (hDlg, "winboard.hlp", HELP_KEY,(DWORD)(LPSTR)"CONTENTS")) { MessageBox (GetFocus(), - "Unable to activate help", + _("Unable to activate help"), szAppName, MB_SYSTEMMODAL|MB_OK|MB_ICONHAND); } break; @@ -5888,6 +6100,7 @@ CommentDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) switch (message) { case WM_INITDIALOG: /* message: initialize dialog box */ /* Initialize the dialog items */ + Translate(hDlg, DLG_EditComment); hwndText = GetDlgItem(hDlg, OPT_CommentText); SetDlgItemText(hDlg, OPT_CommentText, commentText); EnableWindow(GetDlgItem(hDlg, OPT_CancelComment), editComment); @@ -6082,6 +6295,7 @@ TypeInMoveDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) move[0] = (char) lParam; move[1] = NULLCHAR; CenterWindowEx(hDlg, GetWindow(hDlg, GW_OWNER), 1 ); + Translate(hDlg, DLG_TypeInMove); hInput = GetDlgItem(hDlg, OPT_Move); SetWindowText(hInput, move); SetFocus(hInput); @@ -6108,7 +6322,7 @@ TypeInMoveDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } if (gameMode != EditGame && currentMove != forwardMostMove && gameMode != Training) { - DisplayMoveError("Displayed move is not current"); + DisplayMoveError(_("Displayed move is not current")); } else { // GetDlgItemText(hDlg, OPT_Move, move, sizeof(move)); // moved upstream int ok = ParseOneMove(move, gameMode == EditPosition ? blackPlaysFirst : currentMove, @@ -6120,7 +6334,7 @@ TypeInMoveDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) forwardMostMove = currentMove; UserMoveEvent(fromX, fromY, toX, toY, promoChar); } else { - DisplayMoveError("Could not parse move"); + DisplayMoveError(_("Could not parse move")); } } EndDialog(hDlg, TRUE); @@ -6174,6 +6388,7 @@ TypeInNameDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) move[0] = (char) lParam; move[1] = NULLCHAR; CenterWindowEx(hDlg, GetWindow(hDlg, GW_OWNER), 1 ); + Translate(hDlg, DLG_TypeInName); hInput = GetDlgItem(hDlg, OPT_Name); SetWindowText(hInput, move); SetFocus(hInput); @@ -6296,6 +6511,7 @@ ErrorDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) For now, just give it a default position. */ SetWindowPos(hDlg, NULL, boardRect.left+8, boardRect.top+8, 0, 0, SWP_NOZORDER|SWP_NOSIZE); + Translate(hDlg, DLG_Error); errorDialog = hDlg; SetWindowText(hDlg, errorTitle); @@ -7856,7 +8072,7 @@ DisplayError(char *str, int error) } } - ErrorPopUp("Error", buf); + ErrorPopUp(_("Error"), buf); } @@ -7867,7 +8083,7 @@ DisplayMoveError(char *str) ClearHighlights(); DrawPosition(FALSE, NULL); if (appData.popupMoveErrors) { - ErrorPopUp("Error", str); + ErrorPopUp(_("Error"), str); } else { DisplayMessage(str, ""); moveErrorMessageUp = TRUE; @@ -7879,7 +8095,7 @@ DisplayFatalError(char *str, int error, int exitStatus) { char buf[2*MSG_SIZ], buf2[MSG_SIZ]; int len; - char *label = exitStatus ? "Fatal Error" : "Exiting"; + char *label = exitStatus ? _("Fatal Error") : _("Exiting"); if (error != 0) { len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, @@ -7912,14 +8128,14 @@ DisplayFatalError(char *str, int error, int exitStatus) VOID DisplayInformation(char *str) { - (void) MessageBox(hwndMain, str, "Information", MB_OK|MB_ICONINFORMATION); + (void) MessageBox(hwndMain, str, _("Information"), MB_OK|MB_ICONINFORMATION); } VOID DisplayNote(char *str) { - ErrorPopUp("Note", str); + ErrorPopUp(_("Note"), str); } @@ -7939,6 +8155,7 @@ QuestionDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: qp = (QuestionParams *) lParam; CenterWindow(hDlg, GetWindow(hDlg, GW_OWNER)); + Translate(hDlg, DLG_Question); SetWindowText(hDlg, qp->title); SetDlgItemText(hDlg, OPT_QuestionText, qp->question); SetFocus(GetDlgItem(hDlg, OPT_QuestionInput)); @@ -7954,7 +8171,7 @@ QuestionDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) strcat(reply, "\n"); OutputToProcess(qp->pr, reply, strlen(reply), &err); EndDialog(hDlg, TRUE); - if (err) DisplayFatalError("Error writing to chess program", err, 1); + if (err) DisplayFatalError(_("Error writing to chess program"), err, 1); return TRUE; case IDCANCEL: EndDialog(hDlg, FALSE); @@ -7996,6 +8213,7 @@ LRESULT CALLBACK NewGameFRC_Proc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lpIndexFRC = (int *) lParam; CenterWindow(hDlg, GetWindow(hDlg, GW_OWNER)); + Translate(hDlg, DLG_NewGameFRC); SendDlgItemMessage( hDlg, IDC_NFG_Edit, EM_SETLIMITTEXT, sizeof(buf)-1, 0 ); SetDlgItemInt( hDlg, IDC_NFG_Edit, *lpIndexFRC, TRUE ); @@ -8110,6 +8328,7 @@ LRESULT CALLBACK GameListOptions_Proc(HWND hDlg, UINT message, WPARAM wParam, LP gameListOptionsDialog = hDlg; // [HGM] pass through global to keep out off back-end CenterWindow(hDlg, GetWindow(hDlg, GW_OWNER)); + Translate(hDlg, DLG_GameListOptions); /* Initialize list */ GLT_TagsToList( lpUserGLT ); @@ -8312,7 +8531,7 @@ UserName() } if (!GetUserName(buf, &bufsiz)) { /*DisplayError("Error getting user name", GetLastError());*/ - strcpy(buf, "User"); + strcpy(buf, _("User")); } return buf; } @@ -8325,7 +8544,7 @@ HostName() if (!GetComputerName(buf, &bufsiz)) { /*DisplayError("Error getting host name", GetLastError());*/ - strcpy(buf, "Unknown"); + strcpy(buf, _("Unknown")); } return buf; } @@ -8363,7 +8582,7 @@ DisplayWhiteClock(long timeRemaining, int highlight) hdc = GetDC(hwndMain); if (!IsIconic(hwndMain)) { DisplayAClock(hdc, timeRemaining, highlight, - flipClock ? &blackRect : &whiteRect, "White", flag); + flipClock ? &blackRect : &whiteRect, _("White"), flag); } if (highlight && iconCurrent == iconBlack) { iconCurrent = iconWhite; @@ -8387,7 +8606,7 @@ DisplayBlackClock(long timeRemaining, int highlight) hdc = GetDC(hwndMain); if (!IsIconic(hwndMain)) { DisplayAClock(hdc, timeRemaining, highlight, - flipClock ? &whiteRect : &blackRect, "Black", flag); + flipClock ? &whiteRect : &blackRect, _("Black"), flag); } if (highlight && iconCurrent == iconWhite) { iconCurrent = iconBlack; @@ -8435,7 +8654,7 @@ AutoSaveGame() f = OpenFileDialog(hwndMain, "a", defName, appData.oldSaveStyle ? "gam" : "pgn", GAME_FILT, - "Save Game to File", NULL, fileTitle, NULL); + _("Save Game to File"), NULL, fileTitle, NULL); if (f != NULL) { SaveGame(f, 0, ""); fclose(f); @@ -8874,7 +9093,7 @@ OpenCommPort(char *name, ProcRef *pr) int OpenLoopback(ProcRef *pr) { - DisplayFatalError("Not implemented", 0, 1); + DisplayFatalError(_("Not implemented"), 0, 1); return NO_ERROR; } @@ -9244,7 +9463,7 @@ void CmailSigHandlerCallBack(InputSourceRef isr, VOIDSTAR closure, char *buf, int count, int error) { - DisplayFatalError("Not implemented", 0, 1); + DisplayFatalError(_("Not implemented"), 0, 1); } /* see wgamelist.c for Game List functions */ diff --git a/winboard/woptions.c b/winboard/woptions.c index 0f035b9..4c2721e 100644 --- a/winboard/woptions.c +++ b/winboard/woptions.c @@ -44,6 +44,9 @@ #include #endif +#define _(s) T_(s) +#define N_(s) s + /* Imports from winboard.c */ extern MyFont *font[NUM_SIZES][NUM_FONTS]; @@ -497,6 +500,7 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: /* message: initialize dialog box */ /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); + Translate(hDlg, DLG_BoardOptions); /* Initialize the dialog items */ switch (boardSize) { case SizeTiny: @@ -794,6 +798,7 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: /* message: initialize dialog box */ /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); + Translate(hDlg, DLG_NewVariant); /* Initialize the dialog items */ switch (gameInfo.variant) { case VariantNormal: @@ -913,12 +918,12 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if(!appData.noChessProgram) { char *name = VariantName(v), buf[MSG_SIZ]; if (first.protocolVersion > 1 && StrStr(first.variants, name) == NULL) { /* [HGM] in protocol 2 we check if variant is suported by engine */ - sprintf(buf, "Variant %s not supported by %s", name, first.tidy); + sprintf(buf, _("Variant %s not supported by %s"), name, first.tidy); DisplayError(buf, 0); - return TRUE; /* treat as "Cancel" if first engine does not support it */ + return TRUE; /* treat as _("Cancel") if first engine does not support it */ } else if (second.initDone && second.protocolVersion > 1 && StrStr(second.variants, name) == NULL) { - sprintf(buf, "Warning: second engine (%s) does not support this!", second.tidy); + sprintf(buf, _("Warning: second engine (%s) does not support this!"), second.tidy); DisplayError(buf, 0); /* use of second engine is optional; only warn user */ } } @@ -1061,6 +1066,7 @@ ColorizeTextDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) mca = colorizeAttribs[cc]; /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); + Translate(hDlg, DLG_Colorize); /* Initialize the dialog items */ CheckDlgButton(hDlg, OPT_Bold, (mca.effects & CFE_BOLD) != 0); CheckDlgButton(hDlg, OPT_Italic, (mca.effects & CFE_ITALIC) != 0); @@ -1172,6 +1178,7 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); + Translate(hDlg, DLG_IcsOptions); /* Initialize the dialog items */ #define CHECK_BOX(x,y) CheckDlgButton(hDlg, (x), (BOOL)(y)) @@ -1250,8 +1257,8 @@ IcsOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) /* Read changed options from the dialog box */ GetDlgItemText(hDlg, OPT_IcsAlarmTime, buf, MSG_SIZ); if (sscanf(buf, "%d", &number) != 1 || (number < 0)){ - MessageBox(hDlg, "Invalid ICS Alarm Time", - "Option Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox(hDlg, _("Invalid ICS Alarm Time"), + _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return FALSE; } @@ -1545,6 +1552,7 @@ FontOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) for (i=0; i < NUM_FONTS; i++) CopyFont(&workFont[i], font[boardSize][i]); + Translate(hDlg, DLG_Fonts); if (!appData.icsActive) EnableWindow(GetDlgItem(hDlg, OPT_ChooseConsoleFont), FALSE); @@ -1724,22 +1732,22 @@ FontsOptionsPopup(HWND hwnd) SoundComboData soundComboData[] = { - {"Move", NULL}, - {"Bell", NULL}, - {"ICS Alarm", NULL}, - {"ICS Win", NULL}, - {"ICS Loss", NULL}, - {"ICS Draw", NULL}, - {"ICS Unfinished", NULL}, - {"Shout", NULL}, - {"SShout/CShout", NULL}, - {"Channel 1", NULL}, - {"Channel", NULL}, - {"Kibitz", NULL}, - {"Tell", NULL}, - {"Challenge", NULL}, - {"Request", NULL}, - {"Seek", NULL}, + {N_("Move"), NULL}, + {N_("Bell"), NULL}, + {N_("ICS Alarm"), NULL}, + {N_("ICS Win"), NULL}, + {N_("ICS Loss"), NULL}, + {N_("ICS Draw"), NULL}, + {N_("ICS Unfinished"), NULL}, + {N_("Shout"), NULL}, + {N_("SShout/CShout"), NULL}, + {N_("Channel 1"), NULL}, + {N_("Channel"), NULL}, + {N_("Kibitz"), NULL}, + {N_("Tell"), NULL}, + {N_("Challenge"), NULL}, + {N_("Request"), NULL}, + {N_("Seek"), NULL}, {NULL, NULL}, }; @@ -1913,6 +1921,7 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); + Translate(hDlg, DLG_Sound); /* Initialize the built-in sounds combo */ hBISN = GetDlgItem(hDlg, OPT_BuiltInSoundName); @@ -2028,7 +2037,7 @@ SoundOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case OPT_BrowseSound: f = OpenFileDialog(hDlg, "rb", NULL, "wav", SOUND_FILT, - "Browse for Sound File", NULL, NULL, buf); + _("Browse for Sound File"), NULL, NULL, buf); if (f != NULL) { fclose(f); SetDlgItemText(hDlg, OPT_WavFileName, buf); @@ -2153,7 +2162,7 @@ ParseCommSettings(char *arg, DCB *dcb) if (cd->label == NULL) goto cant_parse; return; cant_parse: - ExitArgError("Can't parse com port settings", arg); + ExitArgError(_("Can't parse com port settings"), arg); } @@ -2233,6 +2242,7 @@ CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: /* message: initialize dialog box */ /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow(hDlg, GW_OWNER)); + Translate(hDlg, DLG_CommPort); /* Initialize the dialog items */ /* !! There should probably be some synchronization in accessing hCommPort and dcb. Or does modal nature @@ -2312,8 +2322,8 @@ CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) hwndCombo = GetDlgItem(hDlg, OPT_DataRate); SendMessage(hwndCombo, WM_GETTEXT, (WPARAM) MSG_SIZ, (LPARAM) buf); if (sscanf(buf, "%u", &value) != 1) { - MessageBox(hDlg, "Invalid data rate", - "Option Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox(hDlg, _("Invalid data rate"), + _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return TRUE; } dcb.BaudRate = value; @@ -2358,9 +2368,9 @@ CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) err = GetLastError(); switch(MessageBox(hDlg, "Failed to set comm port state;\r\ninvalid options?", - "Option Error", MB_ABORTRETRYIGNORE|MB_ICONQUESTION)) { + _("Option Error"), MB_ABORTRETRYIGNORE|MB_ICONQUESTION)) { case IDABORT: - DisplayFatalError("Failed to set comm port state", err, 1); + DisplayFatalError(_("Failed to set comm port state"), err, 1); exit(1); /*is it ok to do this from here?*/ case IDRETRY: @@ -2421,6 +2431,7 @@ LoadOptions(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: /* message: initialize dialog box */ /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); + Translate(hDlg, DLG_LoadOptions); /* Initialize the dialog items */ if (appData.timeDelay >= 0.0) { CheckDlgButton(hDlg, OPT_Autostep, TRUE); @@ -2439,8 +2450,8 @@ LoadOptions(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if (IsDlgButtonChecked(hDlg, OPT_Autostep)) { GetDlgItemText(hDlg, OPT_ASTimeDelay, buf, MSG_SIZ); if (sscanf(buf, "%f", &fnumber) != 1) { - MessageBox(hDlg, "Invalid load game step rate", - "Option Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox(hDlg, _("Invalid load game step rate"), + _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return FALSE; } appData.timeDelay = fnumber; @@ -2506,6 +2517,7 @@ SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: /* message: initialize dialog box */ /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); + Translate(hDlg, DLG_SaveOptions); /* Initialize the dialog items */ if (*appData.saveGameFile != NULLCHAR) { CheckDlgButton(hDlg, OPT_Autosave, (UINT) TRUE); @@ -2537,8 +2549,8 @@ SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } else /*if (IsDlgButtonChecked(hDlg, OPT_AVToFile))*/ { GetDlgItemText(hDlg, OPT_AVFilename, buf, MSG_SIZ); if (*buf == NULLCHAR) { - MessageBox(hDlg, "Invalid save game file name", - "Option Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox(hDlg, _("Invalid save game file name"), + _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return FALSE; } if ((isalpha(buf[0]) && buf[1] == ':') || @@ -2573,7 +2585,7 @@ SaveOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case OPT_AVBrowse: f = OpenFileDialog(hDlg, "a", NULL, appData.oldSaveStyle ? "gam" : "pgn", - GAME_FILT, "Browse for Auto Save File", + GAME_FILT, _("Browse for Auto Save File"), NULL, NULL, buf); if (f != NULL) { fclose(f); @@ -2636,6 +2648,7 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: /* message: initialize dialog box */ /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); + Translate(hDlg, DLG_TimeControl); /* Initialize the dialog items */ if (appData.clockMode && !appData.icsActive) { if (searchTime) { @@ -2676,8 +2689,8 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if (IsDlgButtonChecked(hDlg, OPT_TCUseFixed)) { st = GetDlgItemInt(hDlg, OPT_TCFixed, &ok, FALSE); if (!ok || st <= 0) { - MessageBox(hDlg, "Invalid max time per move", - "Option Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox(hDlg, _("Invalid max time per move"), + _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return FALSE; } } else @@ -2685,28 +2698,28 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) increment = -1; mps = GetDlgItemInt(hDlg, OPT_TCMoves, &ok, FALSE); if (!ok || mps <= 0) { - MessageBox(hDlg, "Invalid moves per time control", - "Option Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox(hDlg, _("Invalid moves per time control"), + _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return FALSE; } GetDlgItemText(hDlg, OPT_TCTime, buf, MSG_SIZ); if (!ParseTimeControl(buf, increment, mps)) { - MessageBox(hDlg, "Invalid minutes per time control", - "Option Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox(hDlg, _("Invalid minutes per time control"), + _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return FALSE; } tc = buf; } else { increment = GetDlgItemInt(hDlg, OPT_TCInc, &ok, FALSE); if (!ok || increment < 0) { - MessageBox(hDlg, "Invalid increment", - "Option Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox(hDlg, _("Invalid increment"), + _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return FALSE; } GetDlgItemText(hDlg, OPT_TCTime2, buf, MSG_SIZ); if (!ParseTimeControl(buf, increment, mps)) { - MessageBox(hDlg, "Invalid initial time", - "Option Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox(hDlg, _("Invalid initial time"), + _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return FALSE; } tc = buf; @@ -2714,8 +2727,8 @@ TimeControl(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) odds1 = GetDlgItemInt(hDlg, OPT_TCOdds1, &ok, FALSE); odds2 = GetDlgItemInt(hDlg, OPT_TCOdds2, &ok2, FALSE); if (!ok || !ok2 || odds1 <= 0 || odds2 <= 0) { - MessageBox(hDlg, "Invalid time-odds factor", - "Option Error", MB_OK|MB_ICONEXCLAMATION); + MessageBox(hDlg, _("Invalid time-odds factor"), + _("Option Error"), MB_OK|MB_ICONEXCLAMATION); return FALSE; } searchTime = st; @@ -2745,7 +2758,7 @@ VOID TimeControlOptionsPopup(HWND hwnd) { if (gameMode != BeginningOfGame) { - DisplayError("Changing time control during a game is not implemented", 0); + DisplayError(_("Changing time control during a game is not implemented"), 0); } else { FARPROC lpProc = MakeProcInstance((FARPROC)TimeControl, hInst); DialogBox(hInst, MAKEINTRESOURCE(DLG_TimeControl), hwnd, (DLGPROC) lpProc); @@ -2770,6 +2783,7 @@ LRESULT CALLBACK EnginePlayOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); + Translate(hDlg, DLG_EnginePlayOptions); /* Initialize the dialog items */ CHECK_BOX(IDC_EpPeriodicUpdates, appData.periodicUpdates); @@ -2874,7 +2888,7 @@ static BOOL BrowseForFolder( const char * title, char * path ) ZeroMemory( &bi, sizeof(bi) ); - bi.lpszTitle = title == 0 ? "Choose Folder" : title; + bi.lpszTitle = title == 0 ? _("Choose Folder") : title; bi.ulFlags = BIF_RETURNONLYFSDIRS; pidl = SHBrowseForFolder( &bi ); @@ -2905,6 +2919,7 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM /* Center the dialog over the application window */ CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER)); + Translate(hDlg, DLG_OptionsUCI); /* Initialize the dialog items */ SetDlgItemText( hDlg, IDC_PolyglotDir, appData.polyglotDir ); @@ -2978,7 +2993,7 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM ofn.lpstrFilter = filter; ofn.lpstrFile = buf; ofn.nMaxFile = sizeof(buf); - ofn.lpstrTitle = "Choose Book"; + ofn.lpstrTitle = _("Choose Book"); ofn.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY; if( GetOpenFileName( &ofn ) ) { @@ -2988,19 +3003,19 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM return TRUE; case IDC_BrowseForPolyglotDir: - if( BrowseForFolder( "Choose Polyglot Directory", buf ) ) { + if( BrowseForFolder( _("Choose Polyglot Directory"), buf ) ) { SetDlgItemText( hDlg, IDC_PolyglotDir, buf ); strcat( buf, "\\polyglot.exe" ); if( GetFileAttributes(buf) == 0xFFFFFFFF ) { - MessageBox( hDlg, "Polyglot was not found in the specified folder!", "Warning", MB_OK | MB_ICONWARNING ); + MessageBox( hDlg, _("Polyglot was not found in the specified folder!"), "Warning", MB_OK | MB_ICONWARNING ); } } return TRUE; case IDC_BrowseForEGTB: - if( BrowseForFolder( "Choose EGTB Directory:", buf ) ) { + if( BrowseForFolder( _("Choose EGTB Directory:"), buf ) ) { SetDlgItemText( hDlg, IDC_PathToEGTB, buf ); } return TRUE; diff --git a/winboard/wsettings.c b/winboard/wsettings.c index 856d76b..ac2c3b1 100644 --- a/winboard/wsettings.c +++ b/winboard/wsettings.c @@ -20,6 +20,8 @@ #include "winboard.h" #include "backendz.h" +#define _(s) T_(s) + int layoutList[2*MAX_OPTIONS]; int checkList[2*MAX_OPTIONS]; int comboList[2*MAX_OPTIONS]; @@ -277,9 +279,9 @@ SetOptionValues(HWND hDlg, ChessProgramState *cps) break; } } - SetDlgItemText( hDlg, IDOK, "OK" ); - SetDlgItemText( hDlg, IDCANCEL, "Cancel" ); - sprintf(title, "%s Engine Settings (%s)", cps->which, cps->tidy); + SetDlgItemText( hDlg, IDOK, _("OK") ); + SetDlgItemText( hDlg, IDCANCEL, _("Cancel") ); + sprintf(title, _("%s Engine Settings (%s)"), T_(cps->which), cps->tidy); title[0] &= ~32; // capitalize SetWindowText( hDlg, title); for(i=0; i