Internationalization for WinBoard
authorH.G. Muller <h.g.muller@hccnet.nl>
Mon, 23 Aug 2010 11:23:22 +0000 (13:23 +0200)
committerArun Persaud <arun@nubati.net>
Wed, 1 Sep 2010 05:12:15 +0000 (22:12 -0700)
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.

backend.c
winboard/wchat.c
winboard/wclipbrd.c
winboard/wedittags.c
winboard/wengineoutput.c
winboard/wevalgraph.c
winboard/wgamelist.c
winboard/whistory.c
winboard/winboard.c
winboard/woptions.c
winboard/wsettings.c

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