[2/2] cmd: Fix an internationalization issue in WCMD_ask_confirm().
Francois Gouget
fgouget at free.fr
Mon Jan 23 10:37:47 CST 2012
Don't break the strings to translate in little chunks: this makes it hard or even impossible to translate them correctly. For instance it must be possible to insert an unbreakable space before question marks for French.
---
programs/cmd/builtins.c | 40 +++++++++++++++++-----------------------
programs/cmd/cmd.rc | 8 +++++---
programs/cmd/wcmd.h | 2 ++
3 files changed, 24 insertions(+), 26 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index ca486b4..ad5fee0 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -118,15 +118,20 @@ static BOOL verify_mode = FALSE;
static BOOL WCMD_ask_confirm (const WCHAR *message, BOOL showSureText,
BOOL *optionAll) {
- WCHAR msgbuffer[MAXSTRING];
- WCHAR Ybuffer[MAXSTRING];
- WCHAR Nbuffer[MAXSTRING];
- WCHAR Abuffer[MAXSTRING];
- WCHAR answer[MAX_PATH] = {'\0'};
+ UINT msgid;
+ WCHAR confirm[MAXSTRING];
+ WCHAR options[MAXSTRING];
+ WCHAR Ybuffer[MAXSTRING];
+ WCHAR Nbuffer[MAXSTRING];
+ WCHAR Abuffer[MAXSTRING];
+ WCHAR answer[MAX_PATH] = {'\0'};
DWORD count = 0;
- /* Load the translated 'Are you sure', plus valid answers */
- LoadStringW(hinst, WCMD_CONFIRM, msgbuffer, sizeof(msgbuffer)/sizeof(WCHAR));
+ /* Load the translated valid answers */
+ if (showSureText)
+ LoadStringW(hinst, WCMD_CONFIRM, confirm, sizeof(confirm)/sizeof(WCHAR));
+ msgid = optionAll ? WCMD_YESNOALL : WCMD_YESNO;
+ LoadStringW(hinst, msgid, options, sizeof(options)/sizeof(WCHAR));
LoadStringW(hinst, WCMD_YES, Ybuffer, sizeof(Ybuffer)/sizeof(WCHAR));
LoadStringW(hinst, WCMD_NO, Nbuffer, sizeof(Nbuffer)/sizeof(WCHAR));
LoadStringW(hinst, WCMD_ALL, Abuffer, sizeof(Abuffer)/sizeof(WCHAR));
@@ -134,23 +139,12 @@ static BOOL WCMD_ask_confirm (const WCHAR *message, BOOL showSureText,
/* Loop waiting on a valid answer */
if (optionAll)
*optionAll = FALSE;
- while (1) {
- static const WCHAR startBkt[] = {' ','(','\0'};
- static const WCHAR endBkt[] = {')','?','\0'};
-
+ while (1)
+ {
WCMD_output_asis (message);
- if (showSureText) {
- WCMD_output_asis (msgbuffer);
- }
- WCMD_output_asis (startBkt);
- WCMD_output_asis (Ybuffer);
- WCMD_output_asis (fslashW);
- WCMD_output_asis (Nbuffer);
- if (optionAll) {
- WCMD_output_asis (fslashW);
- WCMD_output_asis (Abuffer);
- }
- WCMD_output_asis (endBkt);
+ if (showSureText)
+ WCMD_output_asis (confirm);
+ WCMD_output_asis (options);
WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), answer, sizeof(answer)/sizeof(WCHAR), &count);
answer[0] = toupperW(answer[0]);
if (answer[0] == Ybuffer[0])
diff --git a/programs/cmd/cmd.rc b/programs/cmd/cmd.rc
index 89db961..8018398 100644
--- a/programs/cmd/cmd.rc
+++ b/programs/cmd/cmd.rc
@@ -287,12 +287,12 @@ XCOPY\t\tCopy source files or directory trees to a destination\n\
EXIT\t\tClose down CMD\n\n\
Enter HELP <command> for further information on any of the above commands.\n"
- WCMD_CONFIRM, "Are you sure"
+ WCMD_CONFIRM, "Are you sure?"
WCMD_YES, "#msgctxt#Yes key#Y"
WCMD_NO, "#msgctxt#No key#N"
WCMD_NOASSOC, "File association missing for extension %1\n"
WCMD_NOFTYPE, "No open command associated with file type '%1'\n"
- WCMD_OVERWRITE, "Overwrite %1"
+ WCMD_OVERWRITE, "Overwrite %1?"
WCMD_MORESTR, "More..."
WCMD_TRUNCATEDLINE, "Line in Batch processing possibly truncated. Using:\n"
WCMD_NYI, "Not Yet Implemented\n\n"
@@ -309,7 +309,7 @@ Enter HELP <command> for further information on any of the above commands.\n"
WCMD_READFAIL, "Failed to open '%1'\n"
WCMD_CALLINSCRIPT, "Cannot call batch label outside of a batch script\n"
WCMD_ALL, "#msgctxt#All key#A"
- WCMD_DELPROMPT, "%1, Delete"
+ WCMD_DELPROMPT, "Delete %1?"
WCMD_ECHOPROMPT, "Echo is %1\n"
WCMD_VERIFYPROMPT, "Verify is %1\n"
WCMD_VERIFYERR, "Verify must be ON or OFF\n"
@@ -324,4 +324,6 @@ Enter HELP <command> for further information on any of the above commands.\n"
WCMD_LINETOOLONG, "The input line is too long.\n"
WCMD_VOLUMELABEL, "Volume in drive %1!c! is %2\n"
WCMD_VOLUMENOLABEL, "Volume in drive %1!c! has no label.\n"
+ WCMD_YESNO, " (Yes|No)"
+ WCMD_YESNOALL, " (Yes|No|All)"
}
diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h
index 7ffa522..d83d738 100644
--- a/programs/cmd/wcmd.h
+++ b/programs/cmd/wcmd.h
@@ -279,3 +279,5 @@ extern WCHAR version_string[];
#define WCMD_LINETOOLONG 1035
#define WCMD_VOLUMELABEL 1036
#define WCMD_VOLUMENOLABEL 1037
+#define WCMD_YESNO 1038
+#define WCMD_YESNOALL 1039
--
1.7.7.3
More information about the wine-patches
mailing list