From: uid69079 Date: Thu, 25 Dec 2003 23:45:37 +0000 (+0000) Subject: Added xboard i18n X-Git-Tag: v4.2.8~61 X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=fb8fa22c61533dc438d2e3152305d3f1253fb24a;p=xboard.git Added xboard i18n --- diff --git a/Makefile.in b/Makefile.in index cc5eb21..a3199ff 100644 --- a/Makefile.in +++ b/Makefile.in @@ -15,6 +15,8 @@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ +datadir = @datadir@ +localedir = $(datadir)/locale mandir = @mandir@ man6dir = $(mandir)/man6 man6ext = .6 @@ -26,7 +28,7 @@ infodir = $(prefix)/share/info CC = @CC@ CFLAGS = @CFLAGS@ @CPPFLAGS@ -DINFODIR=\"$(infodir)\" ALL_CFLAGS = -I. -I$(srcdir) @X_CFLAGS@ @CONF_CFLAGS@ $(CFLAGS) -DEFINES = @DEFS@ +DEFINES = @DEFS@ -DLOCALEDIR=\"$(localedir)\" INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ @@ -36,7 +38,7 @@ LEX = @LEX@ LEXFLAGS = LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBS = @X_LIBS@ @XAW_LIBS@ @PRE_XMULIB@ -lXmu @POST_XMULIB@ -lXt -lXext \ - @X_PRE_LIBS@ -lX11 @X_EXTRA_LIBS@ @LIBS@ -lm + @X_PRE_LIBS@ -lX11 @X_EXTRA_LIBS@ @LTLIBINTL@ @LIBS@ -lm NROFF = @NROFF@ NROFFFLAGS = @NROFFFLAGS@ @@ -58,7 +60,7 @@ DISTDIR = @PRODUCT@-@VERSION@.@PATCHLEVEL@ XBOARDOBJ = parser.o xboard.o backend.o moves.o childio.o gamelist.o \ lists.o pgntags.o xgamelist.o xedittags.o xhistory.o @ZIPPY_O@ -default: xboard zic2xpm +default: xboard pot zic2xpm all: default pseudosource info FAQ html dvi ps @@ -70,6 +72,7 @@ install: installdirs default $(INSTALL_DATA) $(srcdir)/xboard.man $(man6dir)/xboard$(man6ext) $(INSTALL_DATA) $(srcdir)/zic2xpm.man $(man6dir)/zic2xpm$(man6ext) $(INSTALL_DATA) xboard.info $(infodir)/xboard.info + (cd po && $(MAKE) $@) -PATH=$$PATH:/sbin:/usr/sbin install-info \ $(infodir)/xboard.info $(infodir)/dir @@ -82,6 +85,7 @@ uninstall: rm -f $(man6dir)/xboard$(man6ext) $(man6dir)/cmail$(man6ext) rm -f $(man6dir)/zic2xpm$(man6ext) rm -f $(infodir)/xboard.info + (cd po && $(MAKE) $@) -PATH=$$PATH:/sbin:/usr/sbin install-info --delete \ $(infodir)/xboard.info $(infodir)/dir @@ -92,6 +96,7 @@ clean: rm -f xboard.vr* xboard.ps distclean: clean tidy + (cd po && $(MAKE) $@) rm -f config.cache config.log config.status Makefile rm -f config.h stamp-h xboard.texinfo cmail -cd winboard ; make -f cygwin.mak clean @@ -158,6 +163,10 @@ check: all xboard: $(XBOARDOBJ) $(CC) -o xboard $(ALL_LDFLAGS) $(XBOARDOBJ) $(LIBS) +pot: + rm -f po/stamp-po + (cd po && $(MAKE)) + zic2xpm: zic2xpm.o $(CC) -o zic2xpm zic2xpm.o diff --git a/backend.c b/backend.c index f28d863..43f5ed5 100644 --- a/backend.c +++ b/backend.c @@ -107,6 +107,16 @@ extern int gettimeofday(struct timeval *, struct timezone *); # include "zippy.h" #endif #include "backendz.h" +#include "gettext.h" + +#ifdef ENABLE_NLS +# define _(s) gettext (s) +# define N_(s) gettext_noop (s) +#else +# define _(s) (s) +# define N_(s) s +#endif + /* A point in time */ typedef struct { @@ -452,7 +462,7 @@ InitBackEnd1() if (!ParseTimeControl(appData.timeControl, appData.timeIncrement, appData.movesPerSession)) { char buf[MSG_SIZ]; - sprintf(buf, "bad timeControl option %s", appData.timeControl); + sprintf(buf, _("bad timeControl option %s"), appData.timeControl); DisplayFatalError(buf, 0, 2); } @@ -467,7 +477,7 @@ InitBackEnd1() searchTime = min * 60 + sec; } else { char buf[MSG_SIZ]; - sprintf(buf, "bad searchTime option %s", appData.searchTime); + sprintf(buf, _("bad searchTime option %s"), appData.searchTime); DisplayFatalError(buf, 0, 2); } } @@ -526,7 +536,7 @@ InitBackEnd1() if (appData.firstProtocolVersion > PROTOVER || appData.firstProtocolVersion < 1) { char buf[MSG_SIZ]; - sprintf(buf, "protocol version %d not supported", + sprintf(buf, _("protocol version %d not supported"), appData.firstProtocolVersion); DisplayFatalError(buf, 0, 2); } else { @@ -536,7 +546,7 @@ InitBackEnd1() if (appData.secondProtocolVersion > PROTOVER || appData.secondProtocolVersion < 1) { char buf[MSG_SIZ]; - sprintf(buf, "protocol version %d not supported", + sprintf(buf, _("protocol version %d not supported"), appData.secondProtocolVersion); DisplayFatalError(buf, 0, 2); } else { @@ -587,7 +597,7 @@ InitBackEnd1() case VariantBughouse: /* need four players and two boards */ case VariantKriegspiel: /* need to hide pieces and move details */ case VariantFischeRandom: /* castling doesn't work, shuffle not done */ - sprintf(buf, "Variant %s supported only in ICS mode", appData.variant); + sprintf(buf, _("Variant %s supported only in ICS mode"), appData.variant); DisplayFatalError(buf, 0, 2); return; @@ -602,7 +612,7 @@ InitBackEnd1() case Variant35: case Variant36: default: - sprintf(buf, "Unknown variant name %s", appData.variant); + sprintf(buf, _("Unknown variant name %s"), appData.variant); DisplayFatalError(buf, 0, 2); return; @@ -689,10 +699,10 @@ InitBackEnd3 P((void)) err = establish(); if (err != 0) { if (*appData.icsCommPort != NULLCHAR) { - sprintf(buf, "Could not open comm port %s", + sprintf(buf, _("Could not open comm port %s"), appData.icsCommPort); } else { - sprintf(buf, "Could not connect to host %s, port %s", + sprintf(buf, _("Could not connect to host %s, port %s"), appData.icsHost, appData.icsPort); } DisplayFatalError(buf, err, 1); @@ -737,7 +747,7 @@ InitBackEnd3 P((void)) } else if (StrCaseCmp(appData.initialMode, "Training") == 0) { initialMode = Training; } else { - sprintf(buf, "Unknown initialMode %s", appData.initialMode); + sprintf(buf, _("Unknown initialMode %s"), appData.initialMode); DisplayFatalError(buf, 0, 2); return; } @@ -745,7 +755,7 @@ InitBackEnd3 P((void)) if (appData.matchMode) { /* Set up machine vs. machine match */ if (appData.noChessProgram) { - DisplayFatalError("Can't have a match with no chess programs", + DisplayFatalError(_("Can't have a match with no chess programs"), 0, 2); return; } @@ -755,14 +765,14 @@ InitBackEnd3 P((void)) if (!LoadGameFromFile(appData.loadGameFile, appData.loadGameIndex, appData.loadGameFile, FALSE)) { - DisplayFatalError("Bad game file", 0, 1); + DisplayFatalError(_("Bad game file"), 0, 1); return; } } else if (*appData.loadPositionFile != NULLCHAR) { if (!LoadPositionFromFile(appData.loadPositionFile, appData.loadPositionIndex, appData.loadPositionFile)) { - DisplayFatalError("Bad position file", 0, 1); + DisplayFatalError(_("Bad position file"), 0, 1); return; } } @@ -774,7 +784,7 @@ InitBackEnd3 P((void)) /* Set up other modes */ if (initialMode == AnalyzeFile) { if (*appData.loadGameFile == NULLCHAR) { - DisplayFatalError("AnalyzeFile mode requires a game file", 0, 1); + DisplayFatalError(_("AnalyzeFile mode requires a game file"), 0, 1); return; } } @@ -789,11 +799,11 @@ InitBackEnd3 P((void)) } if (initialMode == AnalyzeMode) { if (appData.noChessProgram) { - DisplayFatalError("Analysis mode requires a chess engine", 0, 2); + DisplayFatalError(_("Analysis mode requires a chess engine"), 0, 2); return; } if (appData.icsActive) { - DisplayFatalError("Analysis mode does not work with ICS mode",0,2); + DisplayFatalError(_("Analysis mode does not work with ICS mode"),0,2); return; } AnalyzeModeEvent(); @@ -803,36 +813,36 @@ InitBackEnd3 P((void)) AnalysisPeriodicEvent(1); } else if (initialMode == MachinePlaysWhite) { if (appData.noChessProgram) { - DisplayFatalError("MachineWhite mode requires a chess engine", + DisplayFatalError(_("MachineWhite mode requires a chess engine"), 0, 2); return; } if (appData.icsActive) { - DisplayFatalError("MachineWhite mode does not work with ICS mode", + DisplayFatalError(_("MachineWhite mode does not work with ICS mode"), 0, 2); return; } MachineWhiteEvent(); } else if (initialMode == MachinePlaysBlack) { if (appData.noChessProgram) { - DisplayFatalError("MachineBlack mode requires a chess engine", + DisplayFatalError(_("MachineBlack mode requires a chess engine"), 0, 2); return; } if (appData.icsActive) { - DisplayFatalError("MachineBlack mode does not work with ICS mode", + DisplayFatalError(_("MachineBlack mode does not work with ICS mode"), 0, 2); return; } MachineBlackEvent(); } else if (initialMode == TwoMachinesPlay) { if (appData.noChessProgram) { - DisplayFatalError("TwoMachines mode requires a chess engine", + DisplayFatalError(_("TwoMachines mode requires a chess engine"), 0, 2); return; } if (appData.icsActive) { - DisplayFatalError("TwoMachines mode does not work with ICS mode", + DisplayFatalError(_("TwoMachines mode does not work with ICS mode"), 0, 2); return; } @@ -843,7 +853,7 @@ InitBackEnd3 P((void)) EditPositionEvent(); } else if (initialMode == Training) { if (*appData.loadGameFile == NULLCHAR) { - DisplayFatalError("Training mode requires a game file", 0, 2); + DisplayFatalError(_("Training mode requires a game file"), 0, 2); return; } TrainingEvent(); @@ -991,14 +1001,14 @@ read_from_player(isr, closure, message, count, error) gotEof = 0; outCount = OutputMaybeTelnet(icsPR, message, count, &outError); if (outCount < count) { - DisplayFatalError("Error writing to ICS", outError, 1); + DisplayFatalError(_("Error writing to ICS"), outError, 1); } } else if (count < 0) { RemoveInputSource(isr); - DisplayFatalError("Error reading from keyboard", error, 1); + DisplayFatalError(_("Error reading from keyboard"), error, 1); } else if (gotEof++ > 0) { RemoveInputSource(isr); - DisplayFatalError("Got end of file from keyboard", 0, 0); + DisplayFatalError(_("Got end of file from keyboard"), 0, 0); } } @@ -1013,7 +1023,7 @@ SendToICS(s) count = strlen(s); outCount = OutputMaybeTelnet(icsPR, s, count, &outError); if (outCount < count) { - DisplayFatalError("Error writing to ICS", outError, 1); + DisplayFatalError(_("Error writing to ICS"), outError, 1); } } @@ -1038,7 +1048,7 @@ SendToICSDelayed(s,msdelay) outCount = OutputToProcessDelayed(icsPR, s, count, &outError, msdelay); if (outCount < count) { - DisplayFatalError("Error writing to ICS", outError, 1); + DisplayFatalError(_("Error writing to ICS"), outError, 1); } } @@ -1242,7 +1252,7 @@ StringToVariant(e) } } if (appData.debugMode) { - fprintf(debugFP, "recognized '%s' (%d) as variant %s\n", + fprintf(debugFP, _("recognized '%s' (%d) as variant %s\n"), e, wnum, VariantName(v)); } return v; @@ -1307,7 +1317,7 @@ SendToPlayer(data, length) int error, outCount; outCount = OutputToProcess(NoProc, data, length, &error); if (outCount < length) { - DisplayFatalError("Error writing to display", error, 1); + DisplayFatalError(_("Error writing to display"), error, 1); } } @@ -1393,7 +1403,7 @@ TelnetRequest(ddww, option) msg[2] = option; outCount = OutputToProcess(icsPR, (char *)msg, 3, &outError); if (outCount < 3) { - DisplayFatalError("Error writing to ICS", outError, 1); + DisplayFatalError(_("Error writing to ICS"), outError, 1); } } @@ -1984,7 +1994,7 @@ read_from_ics(isr, closure, data, count, error) case H_GOT_UNWANTED_HEADER: case H_GETTING_MOVES: /* Should not happen */ - DisplayError("Error gathering move list: two headers", 0); + DisplayError(_("Error gathering move list: two headers"), 0); ics_getting_history = H_FALSE; break; } @@ -1998,7 +2008,7 @@ read_from_ics(isr, closure, data, count, error) gameInfo.whiteRating = string_to_rating(star_match[1]); gameInfo.blackRating = string_to_rating(star_match[3]); if (appData.debugMode) - fprintf(debugFP, "Ratings from header: W %d, B %d\n", + fprintf(debugFP, _("Ratings from header: W %d, B %d\n"), gameInfo.whiteRating, gameInfo.blackRating); } continue; @@ -2031,7 +2041,7 @@ read_from_ics(isr, closure, data, count, error) break; case H_GETTING_MOVES: /* Should not happen */ - DisplayError("Error gathering move list: nested", 0); + DisplayError(_("Error gathering move list: nested"), 0); ics_getting_history = H_FALSE; break; case H_GOT_REQ_HEADER: @@ -2540,9 +2550,9 @@ read_from_ics(isr, closure, data, count, error) } else if (count == 0) { RemoveInputSource(isr); - DisplayFatalError("Connection closed by ICS", 0, 0); + DisplayFatalError(_("Connection closed by ICS"), 0, 0); } else { - DisplayFatalError("Error reading from ICS", error, 1); + DisplayFatalError(_("Error reading from ICS"), error, 1); } } @@ -2590,7 +2600,7 @@ ParseBoard12(string) newGame = FALSE; if (appData.debugMode) - fprintf(debugFP, "Parsing board: %s\n", string); + fprintf(debugFP, _("Parsing board: %s\n"), string); move_str[0] = NULLCHAR; elapsed_time[0] = NULLCHAR; @@ -2602,7 +2612,7 @@ ParseBoard12(string) &ticking); if (n < 22) { - sprintf(str, "Failed to parse board string:\n\"%s\"", string); + sprintf(str, _("Failed to parse board string:\n\"%s\""), string); DisplayError(str, 0); return; } @@ -2611,7 +2621,7 @@ ParseBoard12(string) moveNum = (moveNum - 1) * 2; if (to_play == 'B') moveNum++; if (moveNum >= MAX_MOVES) { - DisplayFatalError("Game too long; increase MAX_MOVES and recompile", + DisplayFatalError(_("Game too long; increase MAX_MOVES and recompile"), 0, 1); return; } @@ -2673,7 +2683,7 @@ ParseBoard12(string) return; case H_GETTING_MOVES: /* Should not happen */ - DisplayError("Error gathering move list: extra board", 0); + DisplayError(_("Error gathering move list: extra board"), 0); ics_getting_history = H_FALSE; return; } @@ -2920,7 +2930,7 @@ ParseBoard12(string) if ((gameMode == IcsPlayingWhite && WhiteOnMove(moveNum)) || (gameMode == IcsPlayingBlack && !WhiteOnMove(moveNum))) { if (moveList[moveNum - 1][0] == NULLCHAR) { - sprintf(str, "Couldn't parse move \"%s\" from ICS", + sprintf(str, _("Couldn't parse move \"%s\" from ICS"), move_str); DisplayError(str, 0); } else { @@ -2942,7 +2952,7 @@ ParseBoard12(string) } } else if (gameMode == IcsObserving || gameMode == IcsExamining) { if (moveList[moveNum - 1][0] == NULLCHAR) { - sprintf(str, "Couldn't parse move \"%s\" from ICS", move_str); + sprintf(str, _("Couldn't parse move \"%s\" from ICS"), move_str); DisplayError(str, 0); } else { SendMoveToProgram(moveNum - 1, &first); @@ -3375,7 +3385,7 @@ OKToStartUserMove(x, y) case IcsPlayingBlack: if (appData.zippyPlay) return FALSE; if (white_piece) { - DisplayMoveError("You are playing Black"); + DisplayMoveError(_("You are playing Black")); return FALSE; } break; @@ -3384,18 +3394,18 @@ OKToStartUserMove(x, y) case IcsPlayingWhite: if (appData.zippyPlay) return FALSE; if (!white_piece) { - DisplayMoveError("You are playing White"); + DisplayMoveError(_("You are playing White")); return FALSE; } break; case EditGame: if (!white_piece && WhiteOnMove(currentMove)) { - DisplayMoveError("It is White's turn"); + DisplayMoveError(_("It is White's turn")); return FALSE; } if (white_piece && !WhiteOnMove(currentMove)) { - DisplayMoveError("It is Black's turn"); + DisplayMoveError(_("It is Black's turn")); return FALSE; } if (cmailMsgLoaded && (currentMove < cmailOldMove)) { @@ -3415,7 +3425,7 @@ OKToStartUserMove(x, y) if (appData.icsActive) return FALSE; if (!appData.noChessProgram) { if (!white_piece) { - DisplayMoveError("You are playing White"); + DisplayMoveError(_("You are playing White")); return FALSE; } } @@ -3423,11 +3433,11 @@ OKToStartUserMove(x, y) case Training: if (!white_piece && WhiteOnMove(currentMove)) { - DisplayMoveError("It is White's turn"); + DisplayMoveError(_("It is White's turn")); return FALSE; } if (white_piece && !WhiteOnMove(currentMove)) { - DisplayMoveError("It is Black's turn"); + DisplayMoveError(_("It is Black's turn")); return FALSE; } break; @@ -3438,7 +3448,7 @@ OKToStartUserMove(x, y) } if (currentMove != forwardMostMove && gameMode != AnalyzeMode && gameMode != AnalyzeFile && gameMode != Training) { - DisplayMoveError("Displayed position is not current"); + DisplayMoveError(_("Displayed position is not current")); return FALSE; } return TRUE; @@ -3488,7 +3498,7 @@ UserMoveEvent(fromX, fromY, toX, toY, promoChar) case MachinePlaysWhite: /* User is moving for Black */ if (WhiteOnMove(currentMove)) { - DisplayMoveError("It is White's turn"); + DisplayMoveError(_("It is White's turn")); return; } break; @@ -3496,7 +3506,7 @@ UserMoveEvent(fromX, fromY, toX, toY, promoChar) case MachinePlaysBlack: /* User is moving for White */ if (!WhiteOnMove(currentMove)) { - DisplayMoveError("It is Black's turn"); + DisplayMoveError(_("It is Black's turn")); return; } break; @@ -3510,13 +3520,13 @@ UserMoveEvent(fromX, fromY, toX, toY, promoChar) (int) boards[currentMove][fromY][fromX] <= (int) BlackKing) { /* User is moving for Black */ if (WhiteOnMove(currentMove)) { - DisplayMoveError("It is White's turn"); + DisplayMoveError(_("It is White's turn")); return; } } else { /* User is moving for White */ if (!WhiteOnMove(currentMove)) { - DisplayMoveError("It is Black's turn"); + DisplayMoveError(_("It is Black's turn")); return; } } @@ -3526,7 +3536,7 @@ UserMoveEvent(fromX, fromY, toX, toY, promoChar) /* User is moving for Black */ if (WhiteOnMove(currentMove)) { if (!appData.premove) { - DisplayMoveError("It is White's turn"); + DisplayMoveError(_("It is White's turn")); } else if (toX >= 0 && toY >= 0) { premoveToX = toX; premoveToY = toY; @@ -3547,7 +3557,7 @@ UserMoveEvent(fromX, fromY, toX, toY, promoChar) /* User is moving for White */ if (!WhiteOnMove(currentMove)) { if (!appData.premove) { - DisplayMoveError("It is Black's turn"); + DisplayMoveError(_("It is Black's turn")); } else if (toX >= 0 && toY >= 0) { premoveToX = toX; premoveToY = toY; @@ -3586,7 +3596,7 @@ UserMoveEvent(fromX, fromY, toX, toY, promoChar) moveType = LegalityTest(boards[currentMove], PosFlags(currentMove), EP_UNKNOWN, fromY, fromX, toY, toX, promoChar); if (moveType == IllegalMove || moveType == ImpossibleMove) { - DisplayMoveError("Illegal move"); + DisplayMoveError(_("Illegal move")); return; } } else { @@ -3620,10 +3630,10 @@ UserMoveEvent(fromX, fromY, toX, toY, promoChar) gameMode = PlayFromGameFile; ModeHighlight(); SetTrainingModeOff(); - DisplayInformation("End of game"); + DisplayInformation(_("End of game")); } } else { - DisplayError("Incorrect move", 0); + DisplayError(_("Incorrect move"), 0); } return; } @@ -3842,7 +3852,7 @@ HandleMachineMove(message, cps) if (!ParseOneMove(machineMove, forwardMostMove, &moveType, &fromX, &fromY, &toX, &toY, &promoChar)) { /* Machine move could not be parsed; ignore it. */ - sprintf(buf1, "Illegal move \"%s\" from %s machine", + sprintf(buf1, _("Illegal move \"%s\" from %s machine"), machineMove, cps->which); DisplayError(buf1, 0); if (gameMode == TwoMachinesPlay) { @@ -4083,7 +4093,7 @@ HandleMachineMove(message, cps) DisplayMove(currentMove-1); /* before DisplayMoveError */ SwitchClocks(); DisplayBothClocks(); - sprintf(buf1, "Illegal move \"%s\" (rejected by %s chess program)", + sprintf(buf1, _("Illegal move \"%s\" (rejected by %s chess program)"), parseList[currentMove], cps->which); DisplayMoveError(buf1); DrawPosition(FALSE, boards[currentMove]); @@ -4108,7 +4118,7 @@ HandleMachineMove(message, cps) || (StrStr(message, "Permission denied") != NULL)) { cps->maybeThinking = FALSE; - sprintf(buf1, "Failed to start %s chess program %s on %s: %s\n", + sprintf(buf1, _("Failed to start %s chess program %s on %s: %s\n"), cps->which, cps->program, cps->host, message); RemoveInputSource(cps->isr); DisplayFatalError(buf1, 0, 1); @@ -4131,7 +4141,7 @@ HandleMachineMove(message, cps) } else { /* Hint move could not be parsed!? */ sprintf(buf2, - "Illegal hint move \"%s\"\nfrom %s chess program", + _("Illegal hint move \"%s\"\nfrom %s chess program"), buf1, cps->which); DisplayError(buf2, 0); } @@ -4303,10 +4313,10 @@ HandleMachineMove(message, cps) } else if (gameMode == MachinePlaysWhite || gameMode == MachinePlaysBlack) { if (userOfferedDraw) { - DisplayInformation("Machine accepts your draw offer"); + DisplayInformation(_("Machine accepts your draw offer")); GameEnds(GameIsDrawn, "Draw agreed", GE_XBOARD); } else { - DisplayInformation("Machine offers a draw\nSelect Action / Draw to agree"); + DisplayInformation(_("Machine offers a draw\nSelect Action / Draw to agree")); } } } @@ -4562,18 +4572,18 @@ ParseGameHistory(game) break; case AmbiguousMove: /* bug? */ - sprintf(buf, "Ambiguous move in ICS output: \"%s\"", yy_text); + sprintf(buf, _("Ambiguous move in ICS output: \"%s\""), yy_text); DisplayError(buf, 0); return; case ImpossibleMove: /* bug? */ - sprintf(buf, "Illegal move in ICS output: \"%s\"", yy_text); + sprintf(buf, _("Illegal move in ICS output: \"%s\""), yy_text); DisplayError(buf, 0); return; case (ChessMove) 0: /* end of file */ if (boardIndex < backwardMostMove) { /* Oops, gap. How did that happen? */ - DisplayError("Gap in move list", 0); + DisplayError(_("Gap in move list"), 0); return; } backwardMostMove = blackPlaysFirst ? 1 : 0; @@ -4795,7 +4805,7 @@ MakeMove(fromX, fromY, toX, toY, promoChar) { forwardMostMove++; if (forwardMostMove >= MAX_MOVES) { - DisplayFatalError("Game too long; increase MAX_MOVES and recompile", + DisplayFatalError(_("Game too long; increase MAX_MOVES and recompile"), 0, 1); return; } @@ -4874,7 +4884,7 @@ InitChessProgram(cps) gameInfo.variant != VariantLoadable) { char *v = VariantName(gameInfo.variant); if (StrStr(cps->variants, v) == NULL) { - sprintf(buf, "Variant %s not supported by %s", v, cps->tidy); + sprintf(buf, _("Variant %s not supported by %s"), v, cps->tidy); DisplayFatalError(buf, 0, 1); return; } @@ -5226,7 +5236,7 @@ GameEnds(result, resultDetails, whosays) } else { char buf[MSG_SIZ]; gameMode = nextGameMode; - sprintf(buf, "Match %s vs. %s: final score %d-%d-%d", + sprintf(buf, _("Match %s vs. %s: final score %d-%d-%d"), first.tidy, second.tidy, first.matchWins, second.matchWins, appData.matchGames - (first.matchWins + second.matchWins)); @@ -5592,7 +5602,7 @@ LoadGameOneMove(readAhead) if (appData.testLegality) { if (appData.debugMode) fprintf(debugFP, "Parsed IllegalMove: %s\n", yy_text); - sprintf(move, "Illegal move: %d.%s%s", + sprintf(move, _("Illegal move: %d.%s%s"), (forwardMostMove / 2) + 1, WhiteOnMove(forwardMostMove) ? " " : ".. ", yy_text); DisplayError(move, 0); @@ -5612,7 +5622,7 @@ LoadGameOneMove(readAhead) case AmbiguousMove: if (appData.debugMode) fprintf(debugFP, "Parsed AmbiguousMove: %s\n", yy_text); - sprintf(move, "Ambiguous move: %d.%s%s", + sprintf(move, _("Ambiguous move: %d.%s%s"), (forwardMostMove / 2) + 1, WhiteOnMove(forwardMostMove) ? " " : ".. ", yy_text); DisplayError(move, 0); @@ -5623,7 +5633,7 @@ LoadGameOneMove(readAhead) case ImpossibleMove: if (appData.debugMode) fprintf(debugFP, "Parsed ImpossibleMove: %s\n", yy_text); - sprintf(move, "Illegal move: %d.%s%s", + sprintf(move, _("Illegal move: %d.%s%s"), (forwardMostMove / 2) + 1, WhiteOnMove(forwardMostMove) ? " " : ".. ", yy_text); DisplayError(move, 0); @@ -5671,7 +5681,7 @@ LoadGameFromFile(filename, n, title, useList) } else { f = fopen(filename, "rb"); if (f == NULL) { - sprintf(buf, "Can't open \"%s\"", filename); + sprintf(buf, _("Can't open \"%s\""), filename); DisplayError(buf, errno); return FALSE; } @@ -5683,7 +5693,7 @@ LoadGameFromFile(filename, n, title, useList) if (useList && n == 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, title); @@ -5772,7 +5782,7 @@ CmailLoadGame(f, gameNumber, title, useList) int retVal; if (gameNumber > nCmailGames) { - DisplayError("No more games in this message", 0); + DisplayError(_("No more games in this message"), 0); return FALSE; } if (f == lastLoadGameFP) { @@ -5813,11 +5823,11 @@ ReloadGame(offset) { int gameNumber = lastLoadGameNumber + offset; if (lastLoadGameFP == NULL) { - DisplayError("No game has been loaded yet", 0); + DisplayError(_("No game has been loaded yet"), 0); return FALSE; } if (gameNumber <= 0) { - DisplayError("Can't back up any further", 0); + DisplayError(_("Can't back up any further"), 0); return FALSE; } if (cmailMsgLoaded) { @@ -5872,7 +5882,7 @@ LoadGame(f, gameNumber, title, useList) gn = 1; } else { - DisplayError("Game number out of range", 0); + DisplayError(_("Game number out of range"), 0); return FALSE; } } else { @@ -5883,7 +5893,7 @@ LoadGame(f, gameNumber, title, useList) gameNumber == 1) { gn = 1; } else { - DisplayError("Can't seek on game file", 0); + DisplayError(_("Can't seek on game file"), 0); return FALSE; } } @@ -5942,7 +5952,7 @@ LoadGame(f, gameNumber, title, useList) nCmailGames = CMAIL_MAX_GAMES - gn; } else { Reset(TRUE, TRUE); - DisplayError("Game not found in file", 0); + DisplayError(_("Game not found in file"), 0); } return FALSE; @@ -6059,7 +6069,7 @@ LoadGame(f, gameNumber, title, useList) startedFromSetupPosition = TRUE; if (!ParseFEN(initial_position, &blackPlaysFirst, gameInfo.fen)) { Reset(TRUE, TRUE); - DisplayError("Bad FEN position in file", 0); + DisplayError(_("Bad FEN position in file"), 0); return FALSE; } CopyBoard(boards[0], initial_position); @@ -6202,7 +6212,7 @@ LoadGame(f, gameNumber, title, useList) if ((cm == (ChessMove) 0 && lastLoadGameStart != (ChessMove) 0) || cm == WhiteWins || cm == BlackWins || cm == GameIsDrawn || cm == GameUnfinished) { - DisplayMessage("", "No moves in game"); + DisplayMessage("", _("No moves in game")); if (cmailMsgLoaded) { if (appData.debugMode) fprintf(debugFP, "Setting flipView to %d.\n", FALSE); @@ -6272,11 +6282,11 @@ ReloadPosition(offset) { int positionNumber = lastLoadPositionNumber + offset; if (lastLoadPositionFP == NULL) { - DisplayError("No position has been loaded yet", 0); + DisplayError(_("No position has been loaded yet"), 0); return FALSE; } if (positionNumber <= 0) { - DisplayError("Can't back up any further", 0); + DisplayError(_("Can't back up any further"), 0); return FALSE; } return LoadPosition(lastLoadPositionFP, positionNumber, @@ -6298,7 +6308,7 @@ LoadPositionFromFile(filename, n, title) } else { f = fopen(filename, "rb"); if (f == NULL) { - sprintf(buf, "Can't open \"%s\"", filename); + sprintf(buf, _("Can't open \"%s\""), filename); DisplayError(buf, errno); return FALSE; } else { @@ -6339,7 +6349,7 @@ LoadPosition(f, positionNumber, title) if (positionNumber < 0) { /* Negative position number means to seek to that byte offset */ if (fseek(f, -positionNumber, 0) == -1) { - DisplayError("Can't seek on position file", 0); + DisplayError(_("Can't seek on position file"), 0); return FALSE; }; pn = 1; @@ -6350,14 +6360,14 @@ LoadPosition(f, positionNumber, title) positionNumber == 1) { pn = 1; } else { - DisplayError("Can't seek on position file", 0); + DisplayError(_("Can't seek on position file"), 0); return FALSE; } } } /* See if this file is FEN or old-style xboard */ if (fgets(line, MSG_SIZ, f) == NULL) { - DisplayError("Position not found in file", 0); + DisplayError(_("Position not found in file"), 0); return FALSE; } switch (line[0]) { @@ -6379,7 +6389,7 @@ LoadPosition(f, positionNumber, title) /* skip postions before number pn */ if (fgets(line, MSG_SIZ, f) == NULL) { Reset(TRUE, TRUE); - DisplayError("Position not found in file", 0); + DisplayError(_("Position not found in file"), 0); return FALSE; } if (fenMode || line[0] == '#') pn--; @@ -6388,7 +6398,7 @@ LoadPosition(f, positionNumber, title) if (fenMode) { if (!ParseFEN(initial_position, &blackPlaysFirst, line)) { - DisplayError("Bad FEN position in file", 0); + DisplayError(_("Bad FEN position in file"), 0); return FALSE; } } else { @@ -6420,10 +6430,10 @@ LoadPosition(f, positionNumber, title) strcpy(moveList[0], ""); strcpy(parseList[0], ""); CopyBoard(boards[1], initial_position); - DisplayMessage("", "Black to play"); + DisplayMessage("", _("Black to play")); } else { currentMove = forwardMostMove = backwardMostMove = 0; - DisplayMessage("", "White to play"); + DisplayMessage("", _("White to play")); } SendBoard(&first, forwardMostMove); @@ -6491,7 +6501,7 @@ SaveGameToFile(filename, append) } else { f = fopen(filename, append ? "a" : "w"); if (f == NULL) { - sprintf(buf, "Can't open \"%s\"", filename); + sprintf(buf, _("Can't open \"%s\""), filename); DisplayError(buf, errno); return FALSE; } else { @@ -6717,7 +6727,7 @@ SavePositionToFile(filename) } else { f = fopen(filename, "a"); if (f == NULL) { - sprintf(buf, "Can't open \"%s\"", filename); + sprintf(buf, _("Can't open \"%s\""), filename); DisplayError(buf, errno); return FALSE; } else { @@ -6847,17 +6857,17 @@ RegisterMove() } if (cmailOldMove == -1) { - DisplayError("You have edited the game history.\nUse Reload Same Game and make your move again.", 0); + DisplayError(_("You have edited the game history.\nUse Reload Same Game and make your move again."), 0); return FALSE; } if (currentMove > cmailOldMove + 1) { - DisplayError("You have entered too many moves.\nBack up to the correct position and try again.", 0); + DisplayError(_("You have entered too many moves.\nBack up to the correct position and try again."), 0); return FALSE; } if (currentMove < cmailOldMove) { - DisplayError("Displayed position is not current.\nStep forward to the correct position and try again.", 0); + DisplayError(_("Displayed position is not current.\nStep forward to the correct position and try again."), 0); return FALSE; } @@ -6905,7 +6915,7 @@ RegisterMove() cmailMoveRegistered[lastLoadGameNumber - 1] = TRUE; nCmailMovesRegistered ++; } else if (nCmailGames == 1) { - DisplayError("You have not made a move yet", 0); + DisplayError(_("You have not made a move yet"), 0); return FALSE; } @@ -6926,18 +6936,18 @@ MailMoveEvent() char *arcDir; if (! cmailMsgLoaded) { - DisplayError("The cmail message is not loaded.\nUse Reload CMail Message and make your move again.", 0); + DisplayError(_("The cmail message is not loaded.\nUse Reload CMail Message and make your move again."), 0); return; } if (nCmailGames == nCmailResults) { - DisplayError("No unfinished games", 0); + DisplayError(_("No unfinished games"), 0); return; } #if CMAIL_PROHIBIT_REMAIL if (cmailMailedMove) { - sprintf(msg, "You have already mailed a move.\nWait until a move arrives from your opponent.\nTo resend the same move, type\n\"cmail -remail -game %s\"\non the command line.", appData.cmailGameName); + sprintf(msg, _("You have already mailed a move.\nWait until a move arrives from your opponent.\nTo resend the same move, type\n\"cmail -remail -game %s\"\non the command line."), appData.cmailGameName); DisplayError(msg, 0); return; } @@ -6952,7 +6962,7 @@ MailMoveEvent() commandOutput = popen(string, "rb"); if (commandOutput == NULL) { - DisplayError("Failed to invoke cmail", 0); + DisplayError(_("Failed to invoke cmail"), 0); } else { for (nBuffers = 0; (! feof(commandOutput)); nBuffers ++) { nBytes = fread(buffer, 1, MSG_SIZ - 1, commandOutput); @@ -7014,7 +7024,7 @@ CmailMsg() if (!cmailMsgLoaded) return ""; if (cmailMailedMove) { - sprintf(cmailMsg, "Waiting for reply from opponent\n"); + sprintf(cmailMsg, _("Waiting for reply from opponent\n")); } else { /* Create a list of games left */ sprintf(string, "["); @@ -7037,17 +7047,17 @@ CmailMsg() switch (nCmailGames) { case 1: sprintf(cmailMsg, - "Still need to make move for game\n"); + _("Still need to make move for game\n")); break; case 2: sprintf(cmailMsg, - "Still need to make moves for both games\n"); + _("Still need to make moves for both games\n")); break; default: sprintf(cmailMsg, - "Still need to make moves for all %d games\n", + _("Still need to make moves for all %d games\n"), nCmailGames); break; } @@ -7055,21 +7065,21 @@ CmailMsg() switch (nCmailGames - nCmailMovesRegistered - nCmailResults) { case 1: sprintf(cmailMsg, - "Still need to make a move for game %s\n", + _("Still need to make a move for game %s\n"), string); break; case 0: if (nCmailResults == nCmailGames) { - sprintf(cmailMsg, "No unfinished games\n"); + sprintf(cmailMsg, _("No unfinished games\n")); } else { - sprintf(cmailMsg, "Ready to send mail\n"); + sprintf(cmailMsg, _("Ready to send mail\n")); } break; default: sprintf(cmailMsg, - "Still need to make moves for games %s\n", + _("Still need to make moves for games %s\n"), string); } } @@ -7221,9 +7231,9 @@ EditCommentEvent() char title[MSG_SIZ]; if (currentMove < 1 || parseList[currentMove - 1][0] == NULLCHAR) { - strcpy(title, "Edit comment"); + strcpy(title, _("Edit comment")); } else { - sprintf(title, "Edit comment on %d.%s%s", (currentMove - 1) / 2 + 1, + sprintf(title, _("Edit comment on %d.%s%s"), (currentMove - 1) / 2 + 1, WhiteOnMove(currentMove - 1) ? " " : ".. ", parseList[currentMove - 1]); } @@ -7254,8 +7264,8 @@ AnalyzeModeEvent() first.analyzing = TRUE; /*first.maybeThinking = TRUE;*/ first.maybeThinking = FALSE; /* avoid killing GNU Chess */ - AnalysisPopUp("Analysis", - "Starting analysis mode...\nIf this message stays up, your chess program does not support analysis."); + AnalysisPopUp(_("Analysis"), + _("Starting analysis mode...\nIf this message stays up, your chess program does not support analysis.")); } gameMode = AnalyzeMode; pausing = FALSE; @@ -7281,8 +7291,8 @@ AnalyzeFileEvent() first.analyzing = TRUE; /*first.maybeThinking = TRUE;*/ first.maybeThinking = FALSE; /* avoid killing GNU Chess */ - AnalysisPopUp("Analysis", - "Starting analysis mode...\nIf this message stays up, your chess program does not support analysis."); + AnalysisPopUp(_("Analysis"), + _("Starting analysis mode...\nIf this message stays up, your chess program does not support analysis.")); } gameMode = AnalyzeFile; pausing = FALSE; @@ -7314,7 +7324,7 @@ MachineWhiteEvent() EditPositionDone(); if (!WhiteOnMove(currentMove)) { - DisplayError("It is not White's turn", 0); + DisplayError(_("It is not White's turn"), 0); return; } @@ -7377,7 +7387,7 @@ MachineBlackEvent() EditPositionDone(); if (WhiteOnMove(currentMove)) { - DisplayError("It is not Black's turn", 0); + DisplayError(_("It is not Black's turn"), 0); return; } @@ -7458,7 +7468,7 @@ TwoMachinesEvent P((void)) case MachinePlaysWhite: case MachinePlaysBlack: if (WhiteOnMove(forwardMostMove) == (gameMode == MachinePlaysWhite)) { - DisplayError("Wait until your turn,\nor select Move Now", 0); + DisplayError(_("Wait until your turn,\nor select Move Now"), 0); return; } /* fall through */ @@ -7490,7 +7500,7 @@ TwoMachinesEvent P((void)) } else { /* kludge: allow timeout for initial "feature" command */ FreezeUI(); - DisplayMessage("", "Starting second chess program"); + DisplayMessage("", _("Starting second chess program")); ScheduleDelayedEvent(TwoMachinesEventIfReady, FEATURE_TIMEOUT); } return; @@ -7555,7 +7565,7 @@ TrainingEvent() if (gameMode == Training) { SetTrainingModeOff(); gameMode = PlayFromGameFile; - DisplayMessage("", "Training mode off"); + DisplayMessage("", _("Training mode off")); } else { gameMode = Training; animateTraining = appData.animate; @@ -7563,10 +7573,10 @@ TrainingEvent() /* make sure we are not already at the end of the game */ if (currentMove < forwardMostMove) { SetTrainingModeOn(); - DisplayMessage("", "Training mode on"); + DisplayMessage("", _("Training mode on")); } else { gameMode = PlayFromGameFile; - DisplayError("Already at end of game", 0); + DisplayError(_("Already at end of game"), 0); } } ModeHighlight(); @@ -7647,13 +7657,13 @@ EditGameEvent() break; case IcsPlayingBlack: case IcsPlayingWhite: - DisplayError("Warning: You are still playing a game", 0); + DisplayError(_("Warning: You are still playing a game"), 0); break; case IcsObserving: - DisplayError("Warning: You are still observing a game", 0); + DisplayError(_("Warning: You are still observing a game"), 0); break; case IcsExamining: - DisplayError("Warning: You are still examining a game", 0); + DisplayError(_("Warning: You are still examining a game"), 0); break; case IcsIdle: break; @@ -7901,7 +7911,7 @@ DropMenuEvent(selection, x, y) case IcsPlayingWhite: case MachinePlaysBlack: if (!WhiteOnMove(currentMove)) { - DisplayMoveError("It is Black's turn"); + DisplayMoveError(_("It is Black's turn")); return; } moveType = WhiteDrop; @@ -7909,7 +7919,7 @@ DropMenuEvent(selection, x, y) case IcsPlayingBlack: case MachinePlaysWhite: if (WhiteOnMove(currentMove)) { - DisplayMoveError("It is White's turn"); + DisplayMoveError(_("It is White's turn")); return; } moveType = BlackDrop; @@ -7926,7 +7936,7 @@ DropMenuEvent(selection, x, y) + (int) BlackPawn - (int) WhitePawn); } if (boards[currentMove][y][x] != EmptySquare) { - DisplayMoveError("That square is occupied"); + DisplayMoveError(_("That square is occupied")); return; } @@ -7950,7 +7960,7 @@ AcceptEvent() GameEnds(GameIsDrawn, "Draw agreed", GE_PLAYER); cmailMoveType[lastLoadGameNumber - 1] = CMAIL_ACCEPT; } else { - DisplayError("There is no pending offer on this move", 0); + DisplayError(_("There is no pending offer on this move"), 0); cmailMoveType[lastLoadGameNumber - 1] = CMAIL_MOVE; } } else { @@ -7976,7 +7986,7 @@ DeclineEvent() DisplayComment(cmailOldMove - 1, "Draw declined"); #endif /*NOTDEF*/ } else { - DisplayError("There is no pending offer on this move", 0); + DisplayError(_("There is no pending offer on this move"), 0); } } else { /* Not used for offers from chess program */ @@ -8012,7 +8022,7 @@ CallFlagEvent() else GameEnds(BlackWins, "Black wins on time", GE_PLAYER); } else { - DisplayError("Your opponent is not out of time", 0); + DisplayError(_("Your opponent is not out of time"), 0); } break; case MachinePlaysBlack: @@ -8023,7 +8033,7 @@ CallFlagEvent() else GameEnds(WhiteWins, "White wins on time", GE_PLAYER); } else { - DisplayError("Your opponent is not out of time", 0); + DisplayError(_("Your opponent is not out of time"), 0); } break; } @@ -8058,7 +8068,7 @@ DrawEvent() DisplayComment(currentMove - 1, offer); cmailMoveType[lastLoadGameNumber - 1] = CMAIL_DRAW; } else { - DisplayError("You must make your move before offering a draw", 0); + DisplayError(_("You must make your move before offering a draw"), 0); cmailMoveType[lastLoadGameNumber - 1] = CMAIL_MOVE; } } else if (first.offeredDraw) { @@ -8371,11 +8381,11 @@ void RevertEvent() { if (gameMode != IcsExamining) { - DisplayError("You are not examining a game", 0); + DisplayError(_("You are not examining a game"), 0); return; } if (pausing) { - DisplayError("You can't revert while pausing", 0); + DisplayError(_("You can't revert while pausing"), 0); return; } SendToICS(ics_prefix); @@ -8389,7 +8399,7 @@ RetractMoveEvent() case MachinePlaysWhite: case MachinePlaysBlack: if (WhiteOnMove(forwardMostMove) == (gameMode == MachinePlaysWhite)) { - DisplayError("Wait until your turn,\nor select Move Now", 0); + DisplayError(_("Wait until your turn,\nor select Move Now"), 0); return; } if (forwardMostMove < 2) return; @@ -8429,14 +8439,14 @@ MoveNowEvent() switch (gameMode) { case MachinePlaysWhite: if (!WhiteOnMove(forwardMostMove)) { - DisplayError("It is your turn", 0); + DisplayError(_("It is your turn"), 0); return; } cps = &first; break; case MachinePlaysBlack: if (WhiteOnMove(forwardMostMove)) { - DisplayError("It is your turn", 0); + DisplayError(_("It is your turn"), 0); return; } cps = &first; @@ -8486,19 +8496,19 @@ HintEvent() switch (gameMode) { case MachinePlaysWhite: if (WhiteOnMove(forwardMostMove)) { - DisplayError("Wait until your turn", 0); + DisplayError(_("Wait until your turn"), 0); return; } break; case BeginningOfGame: case MachinePlaysBlack: if (!WhiteOnMove(forwardMostMove)) { - DisplayError("Wait until your turn", 0); + DisplayError(_("Wait until your turn"), 0); return; } break; default: - DisplayError("No hint available", 0); + DisplayError(_("No hint available"), 0); return; } SendToProgram("hint\n", &first); @@ -8512,14 +8522,14 @@ BookEvent() switch (gameMode) { case MachinePlaysWhite: if (WhiteOnMove(forwardMostMove)) { - DisplayError("Wait until your turn", 0); + DisplayError(_("Wait until your turn"), 0); return; } break; case BeginningOfGame: case MachinePlaysBlack: if (!WhiteOnMove(forwardMostMove)) { - DisplayError("Wait until your turn", 0); + DisplayError(_("Wait until your turn"), 0); return; } break; @@ -8804,7 +8814,7 @@ SendToProgram(message, cps) count = strlen(message); outCount = OutputToProcess(cps->pr, message, count, &error); if (outCount < count && !exiting) { - sprintf(buf, "Error writing to %s chess program", cps->which); + sprintf(buf, _("Error writing to %s chess program"), cps->which); DisplayFatalError(buf, error, 1); } } @@ -8825,13 +8835,13 @@ ReceiveFromProgram(isr, closure, message, count, error) if (count <= 0) { if (count == 0) { sprintf(buf, - "Error: %s chess program (%s) exited unexpectedly", + _("Error: %s chess program (%s) exited unexpectedly"), cps->which, cps->program); RemoveInputSource(cps->isr); DisplayFatalError(buf, 0, 1); } else { sprintf(buf, - "Error reading from %s chess program (%s)", + _("Error reading from %s chess program (%s)"), cps->which, cps->program); RemoveInputSource(cps->isr); DisplayFatalError(buf, error, 1); @@ -9334,9 +9344,9 @@ CheckFlags() } } else { if (blackFlag) { - DisplayTitle("Both flags fell"); + DisplayTitle(_("Both flags fell")); } else { - DisplayTitle("White's flag fell"); + DisplayTitle(_("White's flag fell")); if (appData.autoCallFlag) { GameEnds(BlackWins, "Black wins on time", GE_XBOARD); return TRUE; @@ -9356,9 +9366,9 @@ CheckFlags() } } else { if (whiteFlag) { - DisplayTitle("Both flags fell"); + DisplayTitle(_("Both flags fell")); } else { - DisplayTitle("Black's flag fell"); + DisplayTitle(_("Black's flag fell")); if (appData.autoCallFlag) { GameEnds(WhiteWins, "White wins on time", GE_XBOARD); return TRUE; @@ -9956,7 +9966,7 @@ EditPositionPasteFEN(char *fen) Board initial_position; if (!ParseFEN(initial_position, &blackPlaysFirst, fen)) { - DisplayError("Bad FEN position in clipboard", 0); + DisplayError(_("Bad FEN position in clipboard"), 0); return ; } else { int savedBlackPlaysFirst = blackPlaysFirst; diff --git a/config.h.in b/config.h.in index 5f518f1..2e894b6 100644 --- a/config.h.in +++ b/config.h.in @@ -21,6 +21,10 @@ /* Define if lex declares yytext as a char * by default, not a char[]. */ #undef YYTEXT_POINTER +/* Define to 1 if translation of program messages to the user's + native language is desired */ +#undef ENABLE_NLS + #define FIRST_PTY_LETTER 'p' #undef IBMRTAIX diff --git a/configure.in b/configure.in index c7f55f6..2009c9a 100644 --- a/configure.in +++ b/configure.in @@ -70,6 +70,8 @@ fi AC_CANONICAL_HOST +AM_GNU_GETTEXT([external]) + dnl| The following info is mostly gathered from GNU Emacs 19.24. Basically, dnl| we are trying to find out whether this is a System-V derivative in dnl| which pipes don't work with select() and if so, whether there is anything @@ -315,7 +317,7 @@ AC_SUBST(PRODUCT) AC_SUBST(VERSION) AC_SUBST(PATCHLEVEL) -AC_OUTPUT(Makefile cmail xboard.texinfo, +AC_OUTPUT(Makefile cmail xboard.texinfo po/Makefile.in , [test -z "$CONFIG_HEADERS" || date > stamp-h chmod 755 cmail ]) diff --git a/mkinstalldirs b/mkinstalldirs index d0fd194..d2d5f21 100755 --- a/mkinstalldirs +++ b/mkinstalldirs @@ -4,37 +4,108 @@ # Created: 1993-05-16 # Public domain -# $Id$ - errstatus=0 +dirmode="" + +usage="\ +Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." + +# process command line arguments +while test $# -gt 0 ; do + case $1 in + -h | --help | --h*) # -h for help + echo "$usage" 1>&2 + exit 0 + ;; + -m) # -m PERM arg + shift + test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } + dirmode=$1 + shift + ;; + --) # stop option processing + shift + break + ;; + -*) # unknown option + echo "$usage" 1>&2 + exit 1 + ;; + *) # first non-opt arg + break + ;; + esac +done for file do - set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` - shift + if test -d "$file"; then + shift + else + break + fi +done + +case $# in + 0) exit 0 ;; +esac + +case $dirmode in + '') + if mkdir -p -- . 2>/dev/null; then + echo "mkdir -p -- $*" + exec mkdir -p -- "$@" + fi + ;; + *) + if mkdir -m "$dirmode" -p -- . 2>/dev/null; then + echo "mkdir -m $dirmode -p -- $*" + exec mkdir -m "$dirmode" -p -- "$@" + fi + ;; +esac + +for file +do + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift + + pathcomp= + for d + do + pathcomp="$pathcomp$d" + case $pathcomp in + -*) pathcomp=./$pathcomp ;; + esac - pathcomp= - for d - do - pathcomp="$pathcomp$d" - case "$pathcomp" in - -* ) pathcomp=./$pathcomp ;; - esac + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" 1>&2 + mkdir "$pathcomp" || lasterr=$? - mkdir "$pathcomp" || lasterr=$? + if test ! -d "$pathcomp"; then + errstatus=$lasterr + else + if test ! -z "$dirmode"; then + echo "chmod $dirmode $pathcomp" + lasterr="" + chmod "$dirmode" "$pathcomp" || lasterr=$? - if test ! -d "$pathcomp"; then - errstatus=$lasterr - fi - fi + if test ! -z "$lasterr"; then + errstatus=$lasterr + fi + fi + fi + fi - pathcomp="$pathcomp/" - done + pathcomp="$pathcomp/" + done done exit $errstatus +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# End: # mkinstalldirs ends here diff --git a/xboard.c b/xboard.c index bc864fe..e31a7a6 100644 --- a/xboard.c +++ b/xboard.c @@ -191,6 +191,7 @@ extern char *getenv(); #include "xgamelist.h" #include "xhistory.h" #include "xedittags.h" +#include "gettext.h" #ifdef __EMX__ #ifndef HAVE_USLEEP @@ -199,6 +200,14 @@ extern char *getenv(); #define usleep(t) _sleep2(((t)+500)/1000) #endif +#ifdef ENABLE_NLS +# define _(s) gettext (s) +# define N_(s) gettext_noop (s) +#else +# define _(s) (s) +# define N_(s) s +#endif + typedef struct { String string; XtActionProc proc; @@ -499,137 +508,139 @@ static Pixmap xpmMask[BlackKing + 1]; SizeDefaults sizeDefaults[] = SIZE_DEFAULTS; MenuItem fileMenu[] = { - {"Reset Game", ResetProc}, + {N_("Reset Game"), ResetProc}, {"----", NothingProc}, - {"Load Game", LoadGameProc}, - {"Load Next Game", LoadNextGameProc}, - {"Load Previous Game", LoadPrevGameProc}, - {"Reload Same Game", ReloadGameProc}, - {"Save Game", SaveGameProc}, + {N_("Load Game"), LoadGameProc}, + {N_("Load Next Game"), LoadNextGameProc}, + {N_("Load Previous Game"), LoadPrevGameProc}, + {N_("Reload Same Game"), ReloadGameProc}, + {N_("Save Game"), SaveGameProc}, {"----", NothingProc}, - {"Copy Game", CopyGameProc}, - {"Paste Game", PasteGameProc}, + {N_("Copy Game"), CopyGameProc}, + {N_("Paste Game"), PasteGameProc}, {"----", NothingProc}, - {"Load Position", LoadPositionProc}, - {"Load Next Position", LoadNextPositionProc}, - {"Load Previous Position", LoadPrevPositionProc}, - {"Reload Same Position", ReloadPositionProc}, - {"Save Position", SavePositionProc}, + {N_("Load Position"), LoadPositionProc}, + {N_("Load Next Position"), LoadNextPositionProc}, + {N_("Load Previous Position"), LoadPrevPositionProc}, + {N_("Reload Same Position"), ReloadPositionProc}, + {N_("Save Position"), SavePositionProc}, {"----", NothingProc}, - {"Copy Position", CopyPositionProc}, - {"Paste Position", PastePositionProc}, + {N_("Copy Position"), CopyPositionProc}, + {N_("Paste Position"), PastePositionProc}, {"----", NothingProc}, - {"Mail Move", MailMoveProc}, - {"Reload CMail Message", ReloadCmailMsgProc}, + {N_("Mail Move"), MailMoveProc}, + {N_("Reload CMail Message"), ReloadCmailMsgProc}, {"----", NothingProc}, - {"Exit", QuitProc}, + {N_("Exit"), QuitProc}, {NULL, NULL} }; MenuItem modeMenu[] = { - {"Machine White", MachineWhiteProc}, - {"Machine Black", MachineBlackProc}, - {"Two Machines", TwoMachinesProc}, - {"Analysis Mode", AnalyzeModeProc}, - {"Analyze File", AnalyzeFileProc }, - {"ICS Client", IcsClientProc}, - {"Edit Game", EditGameProc}, - {"Edit Position", EditPositionProc}, - {"Training", TrainingProc}, + {N_("Machine White"), MachineWhiteProc}, + {N_("Machine Black"), MachineBlackProc}, + {N_("Two Machines"), TwoMachinesProc}, + {N_("Analysis Mode"), AnalyzeModeProc}, + {N_("Analyze File"), AnalyzeFileProc }, + {N_("ICS Client"), IcsClientProc}, + {N_("Edit Game"), EditGameProc}, + {N_("Edit Position"), EditPositionProc}, + {N_("Training"), TrainingProc}, {"----", NothingProc}, - {"Show Game List", ShowGameListProc}, - {"Show Move List", HistoryShowProc}, - {"Edit Tags", EditTagsProc}, - {"Edit Comment", EditCommentProc}, - {"ICS Input Box", IcsInputBoxProc}, - {"Pause", PauseProc}, + {N_("Show Game List"), ShowGameListProc}, + {N_("Show Move List"), HistoryShowProc}, + {N_("Edit Tags"), EditTagsProc}, + {N_("Edit Comment"), EditCommentProc}, + {N_("ICS Input Box"), IcsInputBoxProc}, + {N_("Pause"), PauseProc}, {NULL, NULL} }; MenuItem actionMenu[] = { - {"Accept", AcceptProc}, - {"Decline", DeclineProc}, - {"Rematch", RematchProc}, + {N_("Accept"), AcceptProc}, + {N_("Decline"), DeclineProc}, + {N_("Rematch"), RematchProc}, {"----", NothingProc}, - {"Call Flag", CallFlagProc}, - {"Draw", DrawProc}, - {"Adjourn", AdjournProc}, - {"Abort", AbortProc}, - {"Resign", ResignProc}, + {N_("Call Flag"), CallFlagProc}, + {N_("Draw"), DrawProc}, + {N_("Adjourn"), AdjournProc}, + {N_("Abort"), AbortProc}, + {N_("Resign"), ResignProc}, {"----", NothingProc}, - {"Stop Observing", StopObservingProc}, - {"Stop Examining", StopExaminingProc}, + {N_("Stop Observing"), StopObservingProc}, + {N_("Stop Examining"), StopExaminingProc}, {NULL, NULL} }; MenuItem stepMenu[] = { - {"Backward", BackwardProc}, - {"Forward", ForwardProc}, - {"Back to Start", ToStartProc}, - {"Forward to End", ToEndProc}, - {"Revert", RevertProc}, - {"Truncate Game", TruncateGameProc}, + {N_("Backward"), BackwardProc}, + {N_("Forward"), ForwardProc}, + {N_("Back to Start"), ToStartProc}, + {N_("Forward to End"), ToEndProc}, + {N_("Revert"), RevertProc}, + {N_("Truncate Game"), TruncateGameProc}, {"----", NothingProc}, - {"Move Now", MoveNowProc}, - {"Retract Move", RetractMoveProc}, + {N_("Move Now"), MoveNowProc}, + {N_("Retract Move"), RetractMoveProc}, {NULL, NULL} }; MenuItem optionsMenu[] = { - {"Always Queen", AlwaysQueenProc}, - {"Animate Dragging", AnimateDraggingProc}, - {"Animate Moving", AnimateMovingProc}, - {"Auto Comment", AutocommProc}, - {"Auto Flag", AutoflagProc}, - {"Auto Flip View", AutoflipProc}, - {"Auto Observe", AutobsProc}, - {"Auto Raise Board", AutoraiseProc}, - {"Auto Save", AutosaveProc}, - {"Blindfold", BlindfoldProc}, - {"Flash Moves", FlashMovesProc}, - {"Flip View", FlipViewProc}, - {"Get Move List", GetMoveListProc}, + {N_("Always Queen"), AlwaysQueenProc}, + {N_("Animate Dragging"), AnimateDraggingProc}, + {N_("Animate Moving"), AnimateMovingProc}, + {N_("Auto Comment"), AutocommProc}, + {N_("Auto Flag"), AutoflagProc}, + {N_("Auto Flip View"), AutoflipProc}, + {N_("Auto Observe"), AutobsProc}, + {N_("Auto Raise Board"), AutoraiseProc}, + {N_("Auto Save"), AutosaveProc}, + {N_("Blindfold"), BlindfoldProc}, + {N_("Flash Moves"), FlashMovesProc}, + {N_("Flip View"), FlipViewProc}, + {N_("Get Move List"), GetMoveListProc}, #if HIGHDRAG - {"Highlight Dragging", HighlightDraggingProc}, + {N_("Highlight Dragging"), HighlightDraggingProc}, #endif - {"Highlight Last Move", HighlightLastMoveProc}, - {"Move Sound", MoveSoundProc}, - {"ICS Alarm", IcsAlarmProc}, - {"Old Save Style", OldSaveStyleProc}, - {"Periodic Updates", PeriodicUpdatesProc}, - {"Ponder Next Move", PonderNextMoveProc}, - {"Popup Exit Message", PopupExitMessageProc}, - {"Popup Move Errors", PopupMoveErrorsProc}, - {"Premove", PremoveProc}, - {"Quiet Play", QuietPlayProc}, - {"Show Coords", ShowCoordsProc}, - {"Show Thinking", ShowThinkingProc}, - {"Test Legality", TestLegalityProc}, + {N_("Highlight Last Move"), HighlightLastMoveProc}, + {N_("Move Sound"), MoveSoundProc}, + {N_("ICS Alarm"), IcsAlarmProc}, + {N_("Old Save Style"), OldSaveStyleProc}, + {N_("Periodic Updates"), PeriodicUpdatesProc}, + {N_("Ponder Next Move"), PonderNextMoveProc}, + {N_("Popup Exit Message"), PopupExitMessageProc}, + {N_("Popup Move Errors"), PopupMoveErrorsProc}, + {N_("Premove"), PremoveProc}, + {N_("Quiet Play"), QuietPlayProc}, + {N_("Show Coords"), ShowCoordsProc}, + {N_("Show Thinking"), ShowThinkingProc}, + {N_("Test Legality"), TestLegalityProc}, {NULL, NULL} }; MenuItem helpMenu[] = { - {"Info XBoard", InfoProc}, - {"Man XBoard", ManProc}, + {N_("Info XBoard"), InfoProc}, + {N_("Man XBoard"), ManProc}, {"----", NothingProc}, - {"Hint", HintProc}, - {"Book", BookProc}, + {N_("Hint"), HintProc}, + {N_("Book"), BookProc}, {"----", NothingProc}, - {"About XBoard", AboutProc}, + {N_("About XBoard"), AboutProc}, {NULL, NULL} }; Menu menuBar[] = { - {"File", fileMenu}, - {"Mode", modeMenu}, - {"Action", actionMenu}, - {"Step", stepMenu}, - {"Options", optionsMenu}, - {"Help", helpMenu}, + {N_("File"), fileMenu}, + {N_("Mode"), modeMenu}, + {N_("Action"), actionMenu}, + {N_("Step"), stepMenu}, + {N_("Options"), optionsMenu}, + {N_("Help"), helpMenu}, {NULL, NULL} }; -#define PAUSE_BUTTON "P" + +/* Label on pause button */ +#define PAUSE_BUTTON N_("P") MenuItem buttonBar[] = { {"<<", ToStartProc}, {"<", BackwardProc}, @@ -641,10 +652,10 @@ MenuItem buttonBar[] = { #define PIECE_MENU_SIZE 11 String pieceMenuStrings[2][PIECE_MENU_SIZE] = { - { "White", "----", "Pawn", "Knight", "Bishop", "Rook", "Queen", "King", - "----", "Empty square", "Clear board" }, - { "Black", "----", "Pawn", "Knight", "Bishop", "Rook", "Queen", "King", - "----", "Empty square", "Clear board" }, + { N_("White"), "----", N_("Pawn"), N_("Knight"), N_("Bishop"), N_("Rook"), + N_("Queen"), N_("King"), "----", N_("Empty square"), N_("Clear board") }, + { N_("Black"), "----", N_("Pawn"), N_("Knight"), N_("Bishop"), N_("Rook"), + N_("Queen"), N_("King"), "----", N_("Empty square"), N_("Clear board") }, }; /* must be in same order as PieceMenuStrings! */ ChessSquare pieceMenuTranslation[2][PIECE_MENU_SIZE] = { @@ -658,7 +669,7 @@ ChessSquare pieceMenuTranslation[2][PIECE_MENU_SIZE] = { #define DROP_MENU_SIZE 6 String dropMenuStrings[DROP_MENU_SIZE] = { - "----", "Pawn", "Knight", "Bishop", "Rook", "Queen" + "----", N_("Pawn"), N_("Knight"), N_("Bishop"), N_("Rook"), N_("Queen") }; /* must be in same order as PieceMenuStrings! */ ChessSquare dropMenuTranslation[DROP_MENU_SIZE] = { @@ -1649,7 +1660,7 @@ xpm_getavail(dirname, ext) dir = opendir(dirname); if (!dir) { - fprintf(stderr, "%s: Can't access XPM directory %s\n", + fprintf(stderr, _("%s: Can't access XPM directory %s\n"), programName, dirname); exit(1); } @@ -1672,7 +1683,7 @@ xpm_print_avail(fp, ext) { int i; - fprintf(fp, "Available `%s' sizes:\n", ext); + fprintf(fp, _("Available `%s' sizes:\n"), ext); for (i=1; i 1) { - fprintf(stderr, "%s: unrecognized argument %s\n", + fprintf(stderr, _("%s: unrecognized argument %s\n"), programName, argv[1]); exit(2); } @@ -1868,7 +1886,7 @@ main(argc, argv) chessDir = "."; } else { if (chdir(chessDir) != 0) { - fprintf(stderr, "%s: can't cd to CHESSDIR: ", programName); + fprintf(stderr, _("%s: can't cd to CHESSDIR: "), programName); perror(chessDir); exit(1); } @@ -1904,7 +1922,7 @@ main(argc, argv) &lineGap, &clockFontPxlSize, &coordFontPxlSize, &fontPxlSize, &smallLayout, &tinyLayout); if (i == 0) { - fprintf(stderr, "%s: bad boardSize syntax %s\n", + fprintf(stderr, _("%s: bad boardSize syntax %s\n"), programName, appData.boardSize); exit(2); } @@ -1940,7 +1958,7 @@ main(argc, argv) while (szd->name != NULL && StrCaseCmp(szd->name, appData.boardSize) != 0) szd++; if (szd->name == NULL) { - fprintf(stderr, "%s: unrecognized boardSize name %s\n", + fprintf(stderr, _("%s: unrecognized boardSize name %s\n"), programName, appData.boardSize); exit(2); } @@ -1958,17 +1976,18 @@ main(argc, argv) if (strlen(appData.pixmapDirectory) > 0) { p = ExpandPathName(appData.pixmapDirectory); if (!p) { - fprintf(stderr, "Error expanding path name \"%s\"\n", + fprintf(stderr, _("Error expanding path name \"%s\"\n"), appData.pixmapDirectory); exit(1); } if (appData.debugMode) { - fprintf(stderr, "XBoard square size (hint): %d\n", squareSize); - fprintf(stderr, "%s fulldir:%s:\n", IMAGE_EXT, p); + fprintf(stderr, _("\ +XBoard square size (hint): %d\n\ +%s fulldir:%s:\n"), squareSize, IMAGE_EXT, p); } squareSize = xpm_closest_to(p, squareSize, IMAGE_EXT); if (appData.debugMode) { - fprintf(stderr, "Closest %s size: %d\n", IMAGE_EXT, squareSize); + fprintf(stderr, _("Closest %s size: %d\n"), IMAGE_EXT, squareSize); } } @@ -2080,12 +2099,12 @@ main(argc, argv) } if (forceMono) { - fprintf(stderr, "%s: too few colors available; trying monochrome mode\n", + fprintf(stderr, _("%s: too few colors available; trying monochrome mode\n"), programName); } if (appData.monoMode && appData.debugMode) { - fprintf(stderr, "white pixel = 0x%lx, black pixel = 0x%lx\n", + fprintf(stderr, _("white pixel = 0x%lx, black pixel = 0x%lx\n"), (unsigned long) XWhitePixel(xDisplay, xScreen), (unsigned long) XBlackPixel(xDisplay, xScreen)); } @@ -2103,7 +2122,7 @@ main(argc, argv) { if (appData.colorize) { fprintf(stderr, - "%s: can't parse color names; disabling colorization\n", + _("%s: can't parse color names; disabling colorization\n"), programName); } appData.colorize = FALSE; @@ -2283,7 +2302,7 @@ main(argc, argv) gres = XtMakeResizeRequest(messageWidget, w, h, &wr, &hr); if (gres != XtGeometryYes && appData.debugMode) { - fprintf(stderr, "%s: messageWidget geometry error %d %d %d %d %d\n", + fprintf(stderr, _("%s: messageWidget geometry error %d %d %d %d %d\n"), programName, gres, w, h, wr, hr); } @@ -2293,7 +2312,7 @@ main(argc, argv) w--; gres = XtMakeResizeRequest(messageWidget, w, h, &wr, &hr); if (gres != XtGeometryYes && appData.debugMode) { - fprintf(stderr, "%s: messageWidget geometry error %d %d %d %d %d\n", + fprintf(stderr, _("%s: messageWidget geometry error %d %d %d %d %d\n"), programName, gres, w, h, wr, hr); } /* !! end hack */ @@ -2314,7 +2333,7 @@ main(argc, argv) gres = XtMakeResizeRequest(titleWidget, w, h, &wr, &hr); if (gres != XtGeometryYes && appData.debugMode) { fprintf(stderr, - "%s: titleWidget geometry error %d %d %d %d %d\n", + _("%s: titleWidget geometry error %d %d %d %d %d\n"), programName, gres, w, h, wr, hr); } } @@ -2864,12 +2883,40 @@ char *FindFont(pattern, targetPxlSize) char **fonts, *p, *best, *scalable, *scalableTail; int i, j, nfonts, minerr, err, pxlSize; +#ifdef ENABLE_NLS + char **missing_list; + int missing_count; + char *def_string, *base_fnt_lst, strInt[3]; + XFontSet fntSet; + XFontStruct **fnt_list; + + base_fnt_lst = calloc(1, strlen(pattern) + 3); + sprintf(strInt, "%d", targetPxlSize); + p = strstr(pattern, "--"); + strncpy(base_fnt_lst, pattern, p - pattern + 2); + strcat(base_fnt_lst, strInt); + strcat(base_fnt_lst, strchr(p + 2, '-')); + + if ((fntSet = XCreateFontSet(xDisplay, + base_fnt_lst, + &missing_list, + &missing_count, + &def_string)) == NULL) { + + fprintf(stderr, _("Unable to create font set.\n")); + exit (2); + } + + nfonts = XFontsOfFontSet(fntSet, &fnt_list, &fonts); +#else fonts = XListFonts(xDisplay, pattern, 999999, &nfonts); if (nfonts < 1) { - fprintf(stderr, "%s: no fonts match pattern %s\n", + fprintf(stderr, _("%s: no fonts match pattern %s\n"), programName, pattern); exit(2); } +#endif + best = fonts[0]; scalable = NULL; minerr = 999999; @@ -2907,10 +2954,16 @@ char *FindFont(pattern, targetPxlSize) strcpy(p, best); } if (appData.debugMode) { - fprintf(debugFP, "resolved %s at pixel size %d\n to %s\n", + fprintf(debugFP, _("resolved %s at pixel size %d\n to %s\n"), pattern, targetPxlSize, p); } +#ifdef ENABLE_NLS + if (missing_count > 0) + XFreeStringList(missing_list); + XFreeFontSet(xDisplay, fntSet); +#else XFreeFontNames(fonts); +#endif return p; } @@ -3025,7 +3078,7 @@ void loadXIM(xim, xmask, filename, dest, mask) fp = fopen(filename, "rb"); if (!fp) { - fprintf(stderr, "%s: error loading XIM!\n", programName); + fprintf(stderr, _("%s: error loading XIM!\n"), programName); exit(1); } @@ -3117,11 +3170,11 @@ void CreateXIMPieces() } else { useImages = 1; if (appData.monoMode) { - DisplayFatalError("XIM pieces cannot be used in monochrome mode", + DisplayFatalError(_("XIM pieces cannot be used in monochrome mode"), 0, 2); ExitEvent(2); } - fprintf(stderr, "\nLoading XIMs...\n"); + fprintf(stderr, _("\nLoading XIMs...\n")); /* Load pieces */ for (piece = (int) WhitePawn; piece <= (int) WhiteKing; piece++) { fprintf(stderr, "%d", piece+1); @@ -3135,7 +3188,7 @@ void CreateXIMPieces() XGetImage(xDisplay, DefaultRootWindow(xDisplay), 0, 0, ss, ss, AllPlanes, XYPixmap); if (appData.debugMode) - fprintf(stderr, "(File:%s:) ", buf); + fprintf(stderr, _("(File:%s:) "), buf); loadXIM(ximPieceBitmap[kind][piece], ximtemp, buf, &(xpmPieceBitmap[kind][piece]), @@ -3151,26 +3204,26 @@ void CreateXIMPieces() useImageSqs = 0; } else { useImageSqs = 1; - fprintf(stderr, "light square "); + fprintf(stderr, _("light square ")); ximLightSquare= XGetImage(xDisplay, DefaultRootWindow(xDisplay), 0, 0, ss, ss, AllPlanes, XYPixmap); if (appData.debugMode) - fprintf(stderr, "(File:%s:) ", buf); + fprintf(stderr, _("(File:%s:) "), buf); loadXIM(ximLightSquare, NULL, buf, &xpmLightSquare, NULL); - fprintf(stderr, "dark square "); + fprintf(stderr, _("dark square ")); sprintf(buf, "%s/dsq%u.xim", ExpandPathName(appData.pixmapDirectory), ss); if (appData.debugMode) - fprintf(stderr, "(File:%s:) ", buf); + fprintf(stderr, _("(File:%s:) "), buf); ximDarkSquare= XGetImage(xDisplay, DefaultRootWindow(xDisplay), 0, 0, ss, ss, AllPlanes, XYPixmap); loadXIM(ximDarkSquare, NULL, buf, &xpmDarkSquare, NULL); xpmJailSquare = xpmLightSquare; } - fprintf(stderr, "Done.\n"); + fprintf(stderr, _("Done.\n")); } XSynchronize(xDisplay, False); /* Work-around for xlib/xt buffering bug */ } @@ -3212,7 +3265,7 @@ void CreateXPMPieces() attr.numsymbols = 4; if (appData.monoMode) { - DisplayFatalError("XPM pieces cannot be used in monochrome mode", + DisplayFatalError(_("XPM pieces cannot be used in monochrome mode"), 0, 2); ExitEvent(2); } @@ -3222,7 +3275,7 @@ void CreateXPMPieces() /* Load pieces */ while (pieces->size != squareSize && pieces->size) pieces++; if (!pieces->size) { - fprintf(stderr, "No builtin XPM pieces of size %d\n", squareSize); + fprintf(stderr, _("No builtin XPM pieces of size %d\n"), squareSize); exit(1); } for (piece = (int) WhitePawn; piece <= (int) WhiteKing; piece++) { @@ -3232,7 +3285,7 @@ void CreateXPMPieces() pieces->xpm[piece][kind], &(xpmPieceBitmap[kind][piece]), NULL, &attr)) != 0) { - fprintf(stderr, "Error %d loading XPM image \"%s\"\n", + fprintf(stderr, _("Error %d loading XPM image \"%s\"\n"), r, buf); exit(1); } @@ -3243,7 +3296,7 @@ void CreateXPMPieces() } else { useImages = 1; - fprintf(stderr, "\nLoading XPMs...\n"); + fprintf(stderr, _("\nLoading XPMs...\n")); /* Load pieces */ for (piece = (int) WhitePawn; piece <= (int) WhiteKing; piece++) { @@ -3254,12 +3307,12 @@ void CreateXPMPieces() ToLower(PieceToChar((ChessSquare)piece)), xpmkind[kind], ss); if (appData.debugMode) { - fprintf(stderr, "(File:%s:) ", buf); + fprintf(stderr, _("(File:%s:) "), buf); } if ((r=XpmReadFileToPixmap(xDisplay, xBoardWindow, buf, &(xpmPieceBitmap[kind][piece]), NULL, &attr)) != 0) { - fprintf(stderr, "Error %d loading XPM file \"%s\"\n", + fprintf(stderr, _("Error %d loading XPM file \"%s\"\n"), r, buf); exit(1); } @@ -3268,34 +3321,34 @@ void CreateXPMPieces() /* Load light and dark squares */ /* If the LSQ and DSQ pieces don't exist, we will draw them with solid squares. */ - fprintf(stderr, "light square "); + fprintf(stderr, _("light square ")); sprintf(buf, "%s/lsq%u.xpm", ExpandPathName(appData.pixmapDirectory), ss); if (access(buf, 0) != 0) { useImageSqs = 0; } else { useImageSqs = 1; if (appData.debugMode) - fprintf(stderr, "(File:%s:) ", buf); + fprintf(stderr, _("(File:%s:) "), buf); if ((r=XpmReadFileToPixmap(xDisplay, xBoardWindow, buf, &xpmLightSquare, NULL, &attr)) != 0) { - fprintf(stderr, "Error %d loading XPM file \"%s\"\n", r, buf); + fprintf(stderr, _("Error %d loading XPM file \"%s\"\n"), r, buf); exit(1); } - fprintf(stderr, "dark square "); + fprintf(stderr, _("dark square ")); sprintf(buf, "%s/dsq%u.xpm", ExpandPathName(appData.pixmapDirectory), ss); if (appData.debugMode) { - fprintf(stderr, "(File:%s:) ", buf); + fprintf(stderr, _("(File:%s:) "), buf); } if ((r=XpmReadFileToPixmap(xDisplay, xBoardWindow, buf, &xpmDarkSquare, NULL, &attr)) != 0) { - fprintf(stderr, "Error %d loading XPM file \"%s\"\n", r, buf); + fprintf(stderr, _("Error %d loading XPM file \"%s\"\n"), r, buf); exit(1); } } xpmJailSquare = xpmLightSquare; - fprintf(stderr, "Done.\n"); + fprintf(stderr, _("Done.\n")); } XSynchronize(xDisplay, False); /* Work-around for xlib/xt buffering bug */ @@ -3372,32 +3425,32 @@ void ReadBitmap(pm, name, bits, wreq, hreq) if (errcode != BitmapSuccess) { switch (errcode) { case BitmapOpenFailed: - sprintf(msg, "Can't open bitmap file %s", fullname); + sprintf(msg, _("Can't open bitmap file %s"), fullname); break; case BitmapFileInvalid: - sprintf(msg, "Invalid bitmap in file %s", fullname); + sprintf(msg, _("Invalid bitmap in file %s"), fullname); break; case BitmapNoMemory: - sprintf(msg, "Ran out of memory reading bitmap file %s", + sprintf(msg, _("Ran out of memory reading bitmap file %s"), fullname); break; default: - sprintf(msg, "Unknown XReadBitmapFile error %d on file %s", + sprintf(msg, _("Unknown XReadBitmapFile error %d on file %s"), errcode, fullname); break; } - fprintf(stderr, "%s: %s...using built-in\n", + fprintf(stderr, _("%s: %s...using built-in\n"), programName, msg); } else if (w != wreq || h != hreq) { fprintf(stderr, - "%s: Bitmap %s is %dx%d, not %dx%d...using built-in\n", + _("%s: Bitmap %s is %dx%d, not %dx%d...using built-in\n"), programName, fullname, w, h, wreq, hreq); } else { return; } } if (bits == NULL) { - fprintf(stderr, "%s: No built-in bitmap for %s; giving up\n", + fprintf(stderr, _("%s: No built-in bitmap for %s; giving up\n"), programName, name); exit(1); } else { @@ -3458,8 +3511,9 @@ void CreateMenuBarPopup(parent, name, mb) entry = XtCreateManagedWidget(mi->string, smeLineObjectClass, menu, args, j); } else { + XtSetArg(args[j], XtNlabel, XtNewString(_(mi->string))); entry = XtCreateManagedWidget(mi->string, smeBSBObjectClass, - menu, args, j); + menu, args, j+1); XtAddCallback(entry, XtNcallback, (XtCallbackProc) MenuBarSelect, (caddr_t) mi->proc); @@ -3490,10 +3544,14 @@ Widget CreateMenuBar(mb) XtSetArg(args[j], XtNmenuName, XtNewString(menuName)); j++; if (tinyLayout) { char shortName[2]; - shortName[0] = mb->name[0]; + shortName[0] = _(mb->name)[0]; shortName[1] = NULLCHAR; XtSetArg(args[j], XtNlabel, XtNewString(shortName)); j++; } + else { + XtSetArg(args[j], XtNlabel, XtNewString(_(mb->name))); j++; + } + XtSetArg(args[j], XtNborderWidth, 0); j++; anchor = XtCreateManagedWidget(mb->name, menuButtonWidgetClass, menuBar, args, j); @@ -3526,6 +3584,7 @@ Widget CreateButtonBar(mi) XtSetArg(args[j], XtNinternalWidth, 2); j++; XtSetArg(args[j], XtNborderWidth, 0); j++; } + XtSetArg(args[j], XtNlabel, XtNewString(_(mi->string))); j++; button = XtCreateManagedWidget(mi->string, commandWidgetClass, buttonBar, args, j); XtAddCallback(button, XtNcallback, @@ -3556,8 +3615,9 @@ CreatePieceMenu(name, color) entry = XtCreateManagedWidget(item, smeLineObjectClass, menu, NULL, 0); } else { + XtSetArg(args[0], XtNlabel, XtNewString(_(item))); entry = XtCreateManagedWidget(item, smeBSBObjectClass, - menu, NULL, 0); + menu, args, 1); selection = pieceMenuTranslation[color][i]; XtAddCallback(entry, XtNcallback, (XtCallbackProc) PieceMenuSelect, @@ -3586,7 +3646,7 @@ CreatePieceMenus() (unsigned)(ButtonPressMask|ButtonReleaseMask), GrabModeAsync, GrabModeAsync); - XtSetArg(args[0], XtNlabel, "Drop"); + XtSetArg(args[0], XtNlabel, _("Drop")); dropMenu = XtCreatePopupShell("menuD", simpleMenuWidgetClass, boardWidget, args, 1); for (i = 0; i < DROP_MENU_SIZE; i++) { @@ -3596,8 +3656,9 @@ CreatePieceMenus() entry = XtCreateManagedWidget(item, smeLineObjectClass, dropMenu, NULL, 0); } else { + XtSetArg(args[0], XtNlabel, XtNewString(_(item))); entry = XtCreateManagedWidget(item, smeBSBObjectClass, - dropMenu, NULL, 0); + dropMenu, args, 1); selection = dropMenuTranslation[i]; XtAddCallback(entry, XtNcallback, (XtCallbackProc) DropMenuSelect, @@ -4506,7 +4567,7 @@ Widget CommentCreate(name, text, mutable, callback, lines) XtSetArg(args[j], XtNleft, XtChainLeft); j++; XtSetArg(args[j], XtNright, XtChainLeft); j++; b_ok = - XtCreateManagedWidget("ok", commandWidgetClass, form, args, j); + XtCreateManagedWidget(_("ok"), commandWidgetClass, form, args, j); XtAddCallback(b_ok, XtNcallback, callback, (XtPointer) 0); j = 0; @@ -4517,7 +4578,7 @@ Widget CommentCreate(name, text, mutable, callback, lines) XtSetArg(args[j], XtNleft, XtChainLeft); j++; XtSetArg(args[j], XtNright, XtChainLeft); j++; b_cancel = - XtCreateManagedWidget("cancel", commandWidgetClass, form, args, j); + XtCreateManagedWidget(_("cancel"), commandWidgetClass, form, args, j); XtAddCallback(b_cancel, XtNcallback, callback, (XtPointer) 0); j = 0; @@ -4528,7 +4589,7 @@ Widget CommentCreate(name, text, mutable, callback, lines) XtSetArg(args[j], XtNleft, XtChainLeft); j++; XtSetArg(args[j], XtNright, XtChainLeft); j++; b_clear = - XtCreateManagedWidget("clear", commandWidgetClass, form, args, j); + XtCreateManagedWidget(_("clear"), commandWidgetClass, form, args, j); XtAddCallback(b_clear, XtNcallback, callback, (XtPointer) 0); } else { j = 0; @@ -4538,7 +4599,7 @@ Widget CommentCreate(name, text, mutable, callback, lines) XtSetArg(args[j], XtNleft, XtChainLeft); j++; XtSetArg(args[j], XtNright, XtChainLeft); j++; b_close = - XtCreateManagedWidget("close", commandWidgetClass, form, args, j); + XtCreateManagedWidget(_("close"), commandWidgetClass, form, args, j); XtAddCallback(b_close, XtNcallback, callback, (XtPointer) 0); j = 0; @@ -4549,7 +4610,7 @@ Widget CommentCreate(name, text, mutable, callback, lines) XtSetArg(args[j], XtNleft, XtChainLeft); j++; XtSetArg(args[j], XtNright, XtChainLeft); j++; b_edit = - XtCreateManagedWidget("edit", commandWidgetClass, form, args, j); + XtCreateManagedWidget(_("edit"), commandWidgetClass, form, args, j); XtAddCallback(b_edit, XtNcallback, callback, (XtPointer) 0); } @@ -4750,16 +4811,16 @@ void EditCommentCallback(w, client_data, call_data) XtSetArg(args[j], XtNlabel, &name); j++; XtGetValues(w, args, j); - if (strcmp(name, "ok") == 0) { + if (strcmp(name, _("ok")) == 0) { edit = XtNameToWidget(editShell, "*form.text"); j = 0; XtSetArg(args[j], XtNstring, &val); j++; XtGetValues(edit, args, j); ReplaceComment(savedIndex, val); EditCommentPopDown(); - } else if (strcmp(name, "cancel") == 0) { + } else if (strcmp(name, _("cancel")) == 0) { EditCommentPopDown(); - } else if (strcmp(name, "clear") == 0) { + } else if (strcmp(name, _("clear")) == 0) { edit = XtNameToWidget(editShell, "*form.text"); XtCallActionProc(edit, "select-all", NULL, NULL, 0); XtCallActionProc(edit, "kill-selection", NULL, NULL, 0); @@ -4791,7 +4852,7 @@ void ICSInputBoxPopUp() Widget edit; Arg args[16]; int j; - char *title = "ICS Input"; + char *title = _("ICS Input"); XtTranslations tr; if (ICSInputShell == NULL) { @@ -4926,9 +4987,9 @@ void CommentCallback(w, client_data, call_data) XtSetArg(args[j], XtNlabel, &name); j++; XtGetValues(w, args, j); - if (strcmp(name, "close") == 0) { + if (strcmp(name, _("close")) == 0) { CommentPopDown(); - } else if (strcmp(name, "edit") == 0) { + } else if (strcmp(name, _("edit")) == 0) { CommentPopDown(); EditCommentEvent(); } @@ -4968,7 +5029,7 @@ void FileNamePopUp(label, def, proc, openMode) char *openMode; { Arg args[16]; - Widget popup, layout, dialog, edit; + Widget popup, layout, dialog, edit, b_ok, b_cancel; Window root, child; int x, y, i; int win_x, win_y; @@ -4980,6 +5041,7 @@ void FileNamePopUp(label, def, proc, openMode) i = 0; XtSetArg(args[i], XtNresizable, True); i++; XtSetArg(args[i], XtNwidth, DIALOG_SIZE); i++; + XtSetArg(args[i], XtNtitle, XtNewString(_("File name prompt"))); i++; fileNameShell = popup = XtCreatePopupShell("File name prompt", transientShellWidgetClass, shellWidget, args, i); @@ -4994,11 +5056,11 @@ void FileNamePopUp(label, def, proc, openMode) XtSetArg(args[i], XtNborderWidth, 0); i++; dialog = XtCreateManagedWidget("fileName", dialogWidgetClass, layout, args, i); - - XawDialogAddButton(dialog, "ok", FileNameCallback, (XtPointer) dialog); - XawDialogAddButton(dialog, "cancel", FileNameCallback, - (XtPointer) dialog); - + + XawDialogAddButton(dialog, _("ok"), FileNameCallback, (XtPointer) dialog); + XawDialogAddButton(dialog, _("cancel"), FileNameCallback, + (XtPointer) dialog); + XtRealizeWidget(popup); CatchDeleteWindow(popup, "FileNamePopDown"); @@ -5035,7 +5097,7 @@ void FileNameCallback(w, client_data, call_data) XtSetArg(args[0], XtNlabel, &name); XtGetValues(w, args, 1); - if (strcmp(name, "cancel") == 0) { + if (strcmp(name, _("cancel")) == 0) { FileNamePopDown(); return; } @@ -5072,12 +5134,12 @@ void FileNameAction(w, event, prms, nprms) } fullname = ExpandPathName(buf); if (!fullname) { - ErrorPopUp("Error", "Can't open file", FALSE); + ErrorPopUp(_("Error"), _("Can't open file"), FALSE); } else { f = fopen(fullname, fileOpenMode); if (f == NULL) { - DisplayError("Failed to open file", errno); + DisplayError(_("Failed to open file"), errno); } else { (void) (*fileProc)(f, index, buf); } @@ -5106,6 +5168,7 @@ void PromotionPopUp() j = 0; XtSetArg(args[j], XtNresizable, True); j++; + XtSetArg(args[j], XtNtitle, XtNewString(_("Promotion"))); j++; promotionShell = XtCreatePopupShell("Promotion", transientShellWidgetClass, shellWidget, args, j); @@ -5114,25 +5177,25 @@ void PromotionPopUp() layoutArgs, XtNumber(layoutArgs)); j = 0; - XtSetArg(args[j], XtNlabel, "Promote pawn to what?"); j++; + XtSetArg(args[j], XtNlabel, _("Promote pawn to what?")); j++; XtSetArg(args[j], XtNborderWidth, 0); j++; dialog = XtCreateManagedWidget("promotion", dialogWidgetClass, layout, args, j); - XawDialogAddButton(dialog, "Queen", PromotionCallback, + XawDialogAddButton(dialog, _("Queen"), PromotionCallback, (XtPointer) dialog); - XawDialogAddButton(dialog, "Rook", PromotionCallback, + XawDialogAddButton(dialog, _("Rook"), PromotionCallback, (XtPointer) dialog); - XawDialogAddButton(dialog, "Bishop", PromotionCallback, + XawDialogAddButton(dialog, _("Bishop"), PromotionCallback, (XtPointer) dialog); - XawDialogAddButton(dialog, "Knight", PromotionCallback, + XawDialogAddButton(dialog, _("Knight"), PromotionCallback, (XtPointer) dialog); if (!appData.testLegality || gameInfo.variant == VariantSuicide || gameInfo.variant == VariantGiveaway) { - XawDialogAddButton(dialog, "King", PromotionCallback, + XawDialogAddButton(dialog, _("King"), PromotionCallback, (XtPointer) dialog); } - XawDialogAddButton(dialog, "cancel", PromotionCallback, + XawDialogAddButton(dialog, _("cancel"), PromotionCallback, (XtPointer) dialog); XtRealizeWidget(promotionShell); @@ -5180,11 +5243,11 @@ void PromotionCallback(w, client_data, call_data) if (fromX == -1) return; - if (strcmp(name, "cancel") == 0) { + if (strcmp(name, _("cancel")) == 0) { fromX = fromY = -1; ClearHighlights(); return; - } else if (strcmp(name, "Knight") == 0) { + } else if (strcmp(name, _("Knight")) == 0) { promoChar = 'n'; } else { promoChar = ToLower(name[0]); @@ -5247,7 +5310,7 @@ void ErrorPopUp(title, label, modal) dialog = XtCreateManagedWidget("dialog", dialogWidgetClass, layout, args, i); - XawDialogAddButton(dialog, "ok", ErrorCallback, (XtPointer) dialog); + XawDialogAddButton(dialog, _("ok"), ErrorCallback, (XtPointer) dialog); XtRealizeWidget(errorShell); CatchDeleteWindow(errorShell, "ErrorPopDown"); @@ -5432,7 +5495,7 @@ int LoadGamePopUp(f, gameNumber, title) if (gameNumber == 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, title); @@ -5453,7 +5516,7 @@ void LoadGameProc(w, event, prms, nprms) if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) { Reset(FALSE, TRUE); } - FileNamePopUp("Load game file name?", "", LoadGamePopUp, "rb"); + FileNamePopUp(_("Load game file name?"), "", LoadGamePopUp, "rb"); } void LoadNextGameProc(w, event, prms, nprms) @@ -5519,7 +5582,7 @@ void LoadPositionProc(w, event, prms, nprms) if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) { Reset(FALSE, TRUE); } - FileNamePopUp("Load position file name?", "", LoadPosition, "rb"); + FileNamePopUp(_("Load position file name?"), "", LoadPosition, "rb"); } void SaveGameProc(w, event, prms, nprms) @@ -5528,7 +5591,7 @@ void SaveGameProc(w, event, prms, nprms) String *prms; Cardinal *nprms; { - FileNamePopUp("Save game file name?", + FileNamePopUp(_("Save game file name?"), DefaultFileName(appData.oldSaveStyle ? "game" : "pgn"), SaveGame, "a"); } @@ -5539,7 +5602,7 @@ void SavePositionProc(w, event, prms, nprms) String *prms; Cardinal *nprms; { - FileNamePopUp("Save position file name?", + FileNamePopUp(_("Save position file name?"), DefaultFileName(appData.oldSaveStyle ? "pos" : "fen"), SavePosition, "a"); } @@ -5711,7 +5774,7 @@ PasteGameCB(Widget w, XtPointer client_data, Atom *selection, } f = fopen(gamePasteFilename, "w"); if (f == NULL) { - DisplayError("Can't open temp file", errno); + DisplayError(_("Can't open temp file"), errno); return; } fwrite(value, 1, *len, f); @@ -5792,7 +5855,7 @@ void AnalyzeModeProc(w, event, prms, nprms) { 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); return; } @@ -5810,7 +5873,7 @@ void AnalyzeFileProc(w, event, prms, nprms) { 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); return; } @@ -5820,7 +5883,7 @@ void AnalyzeFileProc(w, event, prms, nprms) ShowThinkingProc(w,event,prms,nprms); AnalyzeFileEvent(); - FileNamePopUp("File to analyze", "", LoadGamePopUp, "rb"); + FileNamePopUp(_("File to analyze"), "", LoadGamePopUp, "rb"); AnalysisPeriodicEvent(1); } @@ -6653,7 +6716,7 @@ void AboutProc(w, event, prms, nprms) "Enhancements Copyright 1992-2001 Free Software Foundation", PRODUCT, " is free software and carries NO WARRANTY;", "see the file COPYING for more information."); - ErrorPopUp("About XBoard", buf, FALSE); + ErrorPopUp(_("About XBoard"), buf, FALSE); } void DebugProc(w, event, prms, nprms) @@ -6771,7 +6834,7 @@ void DisplayError(message, error) sprintf(buf, "%s: %s", message, strerror(error)); message = buf; } - ErrorPopUp("Error", message, FALSE); + ErrorPopUp(_("Error"), message, FALSE); } @@ -6785,7 +6848,7 @@ void DisplayMoveError(message) fprintf(stderr, "%s: %s\n", programName, message); } if (appData.popupMoveErrors) { - ErrorPopUp("Error", message, FALSE); + ErrorPopUp(_("Error"), message, FALSE); } else { DisplayMessage(message, ""); } @@ -6808,7 +6871,7 @@ void DisplayFatalError(message, error, status) message = buf; } if (appData.popupExitMessage && boardWidget && XtIsRealized(boardWidget)) { - ErrorPopUp(status ? "Fatal Error" : "Exiting", message, TRUE); + ErrorPopUp(status ? _("Fatal Error") : _("Exiting"), message, TRUE); } else { ExitEvent(status); } @@ -6818,14 +6881,14 @@ void DisplayInformation(message) String message; { ErrorPopDown(); - ErrorPopUp("Information", message, TRUE); + ErrorPopUp(_("Information"), message, TRUE); } void DisplayNote(message) String message; { ErrorPopDown(); - ErrorPopUp("Note", message, FALSE); + ErrorPopUp(_("Note"), message, FALSE); } static int @@ -6875,7 +6938,7 @@ void AskQuestionProc(w, event, prms, nprms) Cardinal *nprms; { if (*nprms != 4) { - fprintf(stderr, "AskQuestionProc needed 4 parameters, got %d\n", + fprintf(stderr, _("AskQuestionProc needed 4 parameters, got %d\n"), *nprms); return; } @@ -6908,7 +6971,7 @@ void AskQuestionReplyAction(w, event, prms, nprms) OutputToProcess(pendingReplyPR, buf, strlen(buf), &err); AskQuestionPopDown(); - if (err) DisplayFatalError("Error writing to chess program", err, 0); + if (err) DisplayFatalError(_("Error writing to chess program"), err, 0); } void AskQuestionCallback(w, client_data, call_data) @@ -6921,7 +6984,7 @@ void AskQuestionCallback(w, client_data, call_data) XtSetArg(args[0], XtNlabel, &name); XtGetValues(w, args, 1); - if (strcmp(name, "cancel") == 0) { + if (strcmp(name, _("cancel")) == 0) { AskQuestionPopDown(); } else { AskQuestionReplyAction(w, NULL, NULL, NULL); @@ -6960,9 +7023,9 @@ void AskQuestion(title, question, replyPrefix, pr) dialog = XtCreateManagedWidget("question", dialogWidgetClass, layout, args, i); - XawDialogAddButton(dialog, "enter", AskQuestionCallback, + XawDialogAddButton(dialog, _("enter"), AskQuestionCallback, (XtPointer) dialog); - XawDialogAddButton(dialog, "cancel", AskQuestionCallback, + XawDialogAddButton(dialog, _("cancel"), AskQuestionCallback, (XtPointer) dialog); XtRealizeWidget(popup); @@ -7073,7 +7136,7 @@ Colorize(cc, continuation) count = strlen(buf); outCount = OutputToProcess(NoProc, buf, count, &error); if (outCount < count) { - DisplayFatalError("Error writing to display", error, 1); + DisplayFatalError(_("Error writing to display"), error, 1); } if (continuation) return; @@ -7146,7 +7209,7 @@ static char *ExpandPathName(path) pwd = getpwnam(buf); if (!pwd) { - fprintf(stderr, "ERROR: Unknown user %s (in path %s)\n", + fprintf(stderr, _("ERROR: Unknown user %s (in path %s)\n"), buf, path); return NULL; } @@ -7347,7 +7410,7 @@ DisplayWhiteClock(timeRemaining, highlight) int highlight; { Arg args[16]; - DisplayTimerLabel(whiteTimerWidget, "White", timeRemaining, highlight); + DisplayTimerLabel(whiteTimerWidget, _("White"), timeRemaining, highlight); if (highlight && iconPixmap == bIconPixmap) { iconPixmap = wIconPixmap; XtSetArg(args[0], XtNiconPixmap, iconPixmap); @@ -7361,7 +7424,7 @@ DisplayBlackClock(timeRemaining, highlight) int highlight; { Arg args[16]; - DisplayTimerLabel(blackTimerWidget, "Black", timeRemaining, highlight); + DisplayTimerLabel(blackTimerWidget, _("Black"), timeRemaining, highlight); if (highlight && iconPixmap == wIconPixmap) { iconPixmap = bIconPixmap; XtSetArg(args[0], XtNiconPixmap, iconPixmap); @@ -7501,7 +7564,7 @@ int OpenTCP(host, port, pr) ProcRef *pr; { #if OMIT_SOCKETS - DisplayFatalError("Socket support is not configured in", 0, 2); + DisplayFatalError(_("Socket support is not configured in"), 0, 2); #else /* !OMIT_SOCKETS */ int s; struct sockaddr_in sa; @@ -7603,7 +7666,7 @@ int OpenRcmd(host, user, cmd, pr) char *host, *user, *cmd; ProcRef *pr; { - DisplayFatalError("internal rcmd not implemented for Unix", 0, 1); + DisplayFatalError(_("internal rcmd not implemented for Unix"), 0, 1); return -1; } @@ -8329,8 +8392,9 @@ AnimateMove(board, fromX, fromY, toX, toY) #endif if (appData.debugMode) { - printf("AnimateMove: piece %d %s from %d,%d to %d,%d \n", - piece, hop ? "hops" : "slides", fromX, fromY, toX, toY); + printf(hop ? _("AnimateMove: piece %d hops from %d,%d to %d,%d \n") : + _("AnimateMove: piece %d slides from %d,%d to %d,%d \n"), + piece, fromX, fromY, toX, toY); } ScreenSquare(fromX, fromY, &start, &startColor); diff --git a/xedittags.c b/xedittags.c index 9e07bf0..db046d8 100644 --- a/xedittags.c +++ b/xedittags.c @@ -85,6 +85,15 @@ extern char *getenv(); #include "backend.h" #include "xboard.h" #include "xedittags.h" +#include "gettext.h" + +#ifdef ENABLE_NLS +# define _(s) gettext (s) +# define N_(s) gettext_noop (s) +#else +# define _(s) (s) +# define N_(s) s +#endif extern Widget formWidget, shellWidget, boardWidget, menuBarWidget; extern Display *xDisplay; @@ -113,9 +122,9 @@ void TagsCallback(w, client_data, call_data) XtSetArg(args[j], XtNlabel, &name); j++; XtGetValues(w, args, j); - if (strcmp(name, "close") == 0) { + if (strcmp(name, _("close")) == 0) { TagsPopDown(); - } else if (strcmp(name, "edit") == 0) { + } else if (strcmp(name, _("edit")) == 0) { TagsPopDown(); EditTagsEvent(); } @@ -135,16 +144,16 @@ void EditTagsCallback(w, client_data, call_data) XtSetArg(args[j], XtNlabel, &name); j++; XtGetValues(w, args, j); - if (strcmp(name, "ok") == 0) { + if (strcmp(name, _("ok")) == 0) { textw = XtNameToWidget(editTagsShell, "*form.text"); j = 0; XtSetArg(args[j], XtNstring, &val); j++; XtGetValues(textw, args, j); ReplaceTags(val, &gameInfo); TagsPopDown(); - } else if (strcmp(name, "cancel") == 0) { + } else if (strcmp(name, _("cancel")) == 0) { TagsPopDown(); - } else if (strcmp(name, "clear") == 0) { + } else if (strcmp(name, _("clear")) == 0) { textw = XtNameToWidget(editTagsShell, "*form.text"); XtCallActionProc(textw, "select-all", NULL, NULL, 0); XtCallActionProc(textw, "kill-selection", NULL, NULL, 0); @@ -233,7 +242,7 @@ Widget TagsCreate(name, text, msg, mutable, callback) XtSetArg(args[j], XtNleft, XtChainLeft); j++; XtSetArg(args[j], XtNright, XtChainLeft); j++; b_ok = b = - XtCreateManagedWidget("ok", commandWidgetClass, form, args, j); + XtCreateManagedWidget(_("ok"), commandWidgetClass, form, args, j); XtAddCallback(b_ok, XtNcallback, callback, (XtPointer) 0); j = 0; @@ -244,7 +253,7 @@ Widget TagsCreate(name, text, msg, mutable, callback) XtSetArg(args[j], XtNleft, XtChainLeft); j++; XtSetArg(args[j], XtNright, XtChainLeft); j++; b_cancel = b = - XtCreateManagedWidget("cancel", commandWidgetClass, form, args, j); + XtCreateManagedWidget(_("cancel"), commandWidgetClass, form, args, j); XtAddCallback(b_cancel, XtNcallback, callback, (XtPointer) 0); #if 0 @@ -267,7 +276,7 @@ Widget TagsCreate(name, text, msg, mutable, callback) XtSetArg(args[j], XtNleft, XtChainLeft); j++; XtSetArg(args[j], XtNright, XtChainLeft); j++; b_close = b = - XtCreateManagedWidget("close", commandWidgetClass, form, args, j); + XtCreateManagedWidget(_("close"), commandWidgetClass, form, args, j); XtAddCallback(b_close, XtNcallback, callback, (XtPointer) 0); j = 0; @@ -278,7 +287,7 @@ Widget TagsCreate(name, text, msg, mutable, callback) XtSetArg(args[j], XtNleft, XtChainLeft); j++; XtSetArg(args[j], XtNright, XtChainLeft); j++; b_edit = b = - XtCreateManagedWidget("edit", commandWidgetClass, form, args, j); + XtCreateManagedWidget(_("edit"), commandWidgetClass, form, args, j); XtAddCallback(b_edit, XtNcallback, callback, (XtPointer) 0); } @@ -331,7 +340,7 @@ void TagsPopUp(tags, msg) if (editTagsUp) TagsPopDown(); if (tagsShell == NULL) { tagsShell = - TagsCreate("Tags", tags, msg, False, TagsCallback); + TagsCreate(_("Tags"), tags, msg, False, TagsCallback); } else { textw = XtNameToWidget(tagsShell, "*form.text"); j = 0; @@ -339,7 +348,7 @@ void TagsPopUp(tags, msg) XtSetValues(textw, args, j); j = 0; XtSetArg(args[j], XtNiconName, (XtArgVal) "Tags"); j++; - XtSetArg(args[j], XtNtitle, (XtArgVal) "Tags"); j++; + XtSetArg(args[j], XtNtitle, (XtArgVal) _("Tags")); j++; XtSetValues(tagsShell, args, j); msgw = XtNameToWidget(tagsShell, "*form.msg"); if (msgw) { @@ -370,7 +379,7 @@ void EditTagsPopUp(tags) if (tagsUp) TagsPopDown(); if (editTagsShell == NULL) { editTagsShell = - TagsCreate("Edit tags", tags, NULL, True, EditTagsCallback); + TagsCreate(_("Edit tags"), tags, NULL, True, EditTagsCallback); } else { textw = XtNameToWidget(editTagsShell, "*form.text"); j = 0; @@ -378,7 +387,7 @@ void EditTagsPopUp(tags) XtSetValues(textw, args, j); j = 0; XtSetArg(args[j], XtNiconName, (XtArgVal) "Edit Tags"); j++; - XtSetArg(args[j], XtNtitle, (XtArgVal) "Edit Tags"); j++; + XtSetArg(args[j], XtNtitle, (XtArgVal) _("Edit Tags")); j++; XtSetValues(editTagsShell, args, j); } diff --git a/xgamelist.c b/xgamelist.c index 403db04..9ce424b 100644 --- a/xgamelist.c +++ b/xgamelist.c @@ -85,6 +85,16 @@ extern char *getenv(); #include "backend.h" #include "xboard.h" #include "xgamelist.h" +#include "gettext.h" + +#ifdef ENABLE_NLS +# define _(s) gettext (s) +# define N_(s) gettext_noop (s) +#else +# define _(s) (s) +# define N_(s) s +#endif + extern Widget formWidget, shellWidget, boardWidget, menuBarWidget; extern Display *xDisplay; @@ -177,7 +187,7 @@ GameListCreate(name, callback, client_data) XtSetArg(args[j], XtNleft, XtChainLeft); j++; XtSetArg(args[j], XtNright, XtChainLeft); j++; b_load = - XtCreateManagedWidget("load", commandWidgetClass, form, args, j); + XtCreateManagedWidget(_("load"), commandWidgetClass, form, args, j); XtAddCallback(b_load, XtNcallback, callback, client_data); j = 0; @@ -188,7 +198,7 @@ GameListCreate(name, callback, client_data) XtSetArg(args[j], XtNleft, XtChainLeft); j++; XtSetArg(args[j], XtNright, XtChainLeft); j++; b_loadprev = - XtCreateManagedWidget("prev", commandWidgetClass, form, args, j); + XtCreateManagedWidget(_("prev"), commandWidgetClass, form, args, j); XtAddCallback(b_loadprev, XtNcallback, callback, client_data); j = 0; @@ -199,7 +209,7 @@ GameListCreate(name, callback, client_data) XtSetArg(args[j], XtNleft, XtChainLeft); j++; XtSetArg(args[j], XtNright, XtChainLeft); j++; b_loadnext = - XtCreateManagedWidget("next", commandWidgetClass, form, args, j); + XtCreateManagedWidget(_("next"), commandWidgetClass, form, args, j); XtAddCallback(b_loadnext, XtNcallback, callback, client_data); j = 0; @@ -210,7 +220,7 @@ GameListCreate(name, callback, client_data) XtSetArg(args[j], XtNleft, XtChainLeft); j++; XtSetArg(args[j], XtNright, XtChainLeft); j++; b_close = - XtCreateManagedWidget("close", commandWidgetClass, form, args, j); + XtCreateManagedWidget(_("close"), commandWidgetClass, form, args, j); XtAddCallback(b_close, XtNcallback, callback, client_data); if (glc->x == -1) { @@ -276,29 +286,29 @@ GameListCallback(w, client_data, call_data) XtSetArg(args[j], XtNlabel, &name); j++; XtGetValues(w, args, j); - if (strcmp(name, "close") == 0) { + if (strcmp(name, _("close")) == 0) { GameListPopDown(); return; } listwidg = XtNameToWidget(glc->shell, "*form.viewport.list"); rs = XawListShowCurrent(listwidg); - if (strcmp(name, "load") == 0) { + if (strcmp(name, _("load")) == 0) { index = rs->list_index; if (index < 0) { - DisplayError("No game selected", 0); + DisplayError(_("No game selected"), 0); return; } - } else if (strcmp(name, "next") == 0) { + } else if (strcmp(name, _("next")) == 0) { index = rs->list_index + 1; if (index >= ((ListGame *) gameList.tailPred)->number) { - DisplayError("Can't go forward any further", 0); + DisplayError(_("Can't go forward any further"), 0); return; } XawListHighlight(listwidg, index); - } else if (strcmp(name, "prev") == 0) { + } else if (strcmp(name, _("prev")) == 0) { index = rs->list_index - 1; if (index < 0) { - DisplayError("Can't back up any further", 0); + DisplayError(_("Can't back up any further"), 0); return; } XawListHighlight(listwidg, index); @@ -399,7 +409,7 @@ ShowGameListProc(w, event, prms, nprms) int j; if (glc == NULL) { - DisplayError("There is no game list", 0); + DisplayError(_("There is no game list"), 0); return; } if (glc->up) { diff --git a/xhistory.c b/xhistory.c index bcb71e9..bbdc0bf 100644 --- a/xhistory.c +++ b/xhistory.c @@ -71,7 +71,15 @@ extern char *getenv(); #include "backend.h" #include "xboard.h" #include "xhistory.h" +#include "gettext.h" +#ifdef ENABLE_NLS +# define _(s) gettext (s) +# define N_(s) gettext_noop (s) +#else +# define _(s) (s) +# define N_(s) s +#endif #define _LL_ 100 @@ -142,8 +150,8 @@ void HistoryAlloc(int len){ hist->black[0]=(String)malloc(hist->aNr*MOVE_LEN); sprintf(hist->Nr[0]," "); - sprintf(hist->white[0],"White "); - sprintf(hist->black[0],"Black "); + sprintf(hist->white[0],_("White ")); + sprintf(hist->black[0],_("Black ")); for(i=1;iaNr;i++){ hist->Nr[i]= hist->Nr[i-1]+6; hist->white[i]= hist->white[i-1]+MOVE_LEN; @@ -333,11 +341,11 @@ Widget HistoryCreate() XtSetArg(args[j], XtNallowShellResize, True); j++; #if TOPLEVEL hist->sh = - XtCreatePopupShell("Move list", topLevelShellWidgetClass, + XtCreatePopupShell(_("Move list"), topLevelShellWidgetClass, shellWidget, args, j); #else hist->sh = - XtCreatePopupShell("Move list", transientShellWidgetClass, + XtCreatePopupShell(_("Move list"), transientShellWidgetClass, shellWidget, args, j); #endif j = 0; @@ -431,7 +439,7 @@ Widget HistoryCreate() XtSetArg(args[j], XtNleft, XtChainLeft); j++; XtSetArg(args[j], XtNright, XtChainLeft); j++; XtSetArg(args[j], XtNfromVert, hist->viewport); j++; - b_close= XtCreateManagedWidget("Close", commandWidgetClass, + b_close= XtCreateManagedWidget(_("Close"), commandWidgetClass, form, args, j); XtAddCallback(b_close, XtNcallback, HistoryPopDown, (XtPointer) 0);