From 13f80b1452ccc1dfceab9bbd5899d3e1427d5d8d Mon Sep 17 00:00:00 2001 From: Colin Finck Date: Wed, 18 Jul 2007 18:40:07 +0000 Subject: [PATCH] - Localize the Usage message of "shutdown" and add a german localization - Also add a version resource Translators, feel free to make translations for this tool :-) svn path=/trunk/; revision=27721 --- .../base/applications/shutdown/lang/de-DE.rc | 19 ++++++ .../base/applications/shutdown/lang/en-US.rc | 14 +++++ reactos/base/applications/shutdown/misc.c | 63 +++++++++++++++++++ reactos/base/applications/shutdown/precomp.h | 16 +++++ reactos/base/applications/shutdown/resource.h | 1 + reactos/base/applications/shutdown/rsrc.rc | 5 ++ reactos/base/applications/shutdown/shutdown.c | 23 +++---- .../applications/shutdown/shutdown.rbuild | 3 + .../base/applications/shutdown/shutdown.rc | 9 +++ 9 files changed, 139 insertions(+), 14 deletions(-) create mode 100644 reactos/base/applications/shutdown/lang/de-DE.rc create mode 100644 reactos/base/applications/shutdown/lang/en-US.rc create mode 100644 reactos/base/applications/shutdown/misc.c create mode 100644 reactos/base/applications/shutdown/precomp.h create mode 100644 reactos/base/applications/shutdown/resource.h create mode 100644 reactos/base/applications/shutdown/rsrc.rc create mode 100644 reactos/base/applications/shutdown/shutdown.rc diff --git a/reactos/base/applications/shutdown/lang/de-DE.rc b/reactos/base/applications/shutdown/lang/de-DE.rc new file mode 100644 index 00000000000..6aff736bb72 --- /dev/null +++ b/reactos/base/applications/shutdown/lang/de-DE.rc @@ -0,0 +1,19 @@ +/* + * German language file by Colin Finck <2007-07-18> + */ + +LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL + +STRINGTABLE DISCARDABLE +{ + +IDS_USAGE, "Syntax: shutdown [-?] [-l | -s | -r] [-f]\n\n\ + Keine Argumente\tDiese Meldung anzeigen\n\ + -?\t\t\tDiese Meldung anzeigen\n\ + -l\t\t\tBenutzer abmelden\n\ + -s\t\t\tComputer herunterfahren\n\ + -r\t\t\tComputer herunterfahren und neu starten\n\ + -f\t\t\tLaufende Anwendungen ohne Warnung schlieáen\n\ + \t\t\tWenn Sie keine weiteren Parameter angegeben haben,\n\ + \t\t\tmeldet Sie diese Option auch ab" +} diff --git a/reactos/base/applications/shutdown/lang/en-US.rc b/reactos/base/applications/shutdown/lang/en-US.rc new file mode 100644 index 00000000000..c4855dd2d27 --- /dev/null +++ b/reactos/base/applications/shutdown/lang/en-US.rc @@ -0,0 +1,14 @@ +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +STRINGTABLE DISCARDABLE +{ + +IDS_USAGE, "Usage: shutdown [-?] [-l | -s | -r] [-f]\n\n\ + No arguments or -?\tDisplay this message\n\ + -l\t\t\tLog off\n\ + -s\t\t\tShutdown the computer\n\ + -r\t\t\tShutdown and restart the computer\n\ + -f\t\t\tForces running applications to close without warnings\n\ + \t\t\tIf you did not specify any other parameter, this option\n\ + \t\t\twill also log off" +} diff --git a/reactos/base/applications/shutdown/misc.c b/reactos/base/applications/shutdown/misc.c new file mode 100644 index 00000000000..23da81a692f --- /dev/null +++ b/reactos/base/applications/shutdown/misc.c @@ -0,0 +1,63 @@ +#include "precomp.h" + +static INT +LengthOfStrResource(IN HINSTANCE hInst, + IN UINT uID) +{ + HRSRC hrSrc; + HGLOBAL hRes; + LPWSTR lpName, lpStr; + + if (hInst == NULL) + { + return -1; + } + + /* There are always blocks of 16 strings */ + lpName = (LPWSTR)MAKEINTRESOURCE((uID >> 4) + 1); + + /* Find the string table block */ + if ((hrSrc = FindResourceW(hInst, lpName, (LPWSTR)RT_STRING)) && + (hRes = LoadResource(hInst, hrSrc)) && + (lpStr = (WCHAR*) LockResource(hRes))) + { + UINT x; + + /* Find the string we're looking for */ + uID &= 0xF; /* position in the block, same as % 16 */ + for (x = 0; x < uID; x++) + { + lpStr += (*lpStr) + 1; + } + + /* Found the string */ + return (int)(*lpStr); + } + return -1; +} + +INT +AllocAndLoadString(OUT LPTSTR *lpTarget, + IN HINSTANCE hInst, + IN UINT uID) +{ + INT ln; + + ln = LengthOfStrResource(hInst, + uID); + if (ln++ > 0) + { + (*lpTarget) = (LPTSTR)LocalAlloc(LMEM_FIXED, + ln * sizeof(TCHAR)); + if ((*lpTarget) != NULL) + { + INT Ret; + if (!(Ret = LoadString(hInst, uID, *lpTarget, ln))) + { + LocalFree((HLOCAL)(*lpTarget)); + } + return Ret; + } + } + return 0; +} diff --git a/reactos/base/applications/shutdown/precomp.h b/reactos/base/applications/shutdown/precomp.h new file mode 100644 index 00000000000..1936ea4b6ba --- /dev/null +++ b/reactos/base/applications/shutdown/precomp.h @@ -0,0 +1,16 @@ +#ifndef __SHUTDOWN_PRECOMP_H +#define __SHUTDOWN_PRECOMP_H + +#include +#include +#include +#include +#include //shutdown codes +#include "resource.h" + +// misc.c +INT AllocAndLoadString(OUT LPTSTR *lpTarget, + IN HINSTANCE hInst, + IN UINT uID); + +#endif diff --git a/reactos/base/applications/shutdown/resource.h b/reactos/base/applications/shutdown/resource.h new file mode 100644 index 00000000000..3b39d1caf24 --- /dev/null +++ b/reactos/base/applications/shutdown/resource.h @@ -0,0 +1 @@ +#define IDS_USAGE 1000 diff --git a/reactos/base/applications/shutdown/rsrc.rc b/reactos/base/applications/shutdown/rsrc.rc new file mode 100644 index 00000000000..aeb65216fef --- /dev/null +++ b/reactos/base/applications/shutdown/rsrc.rc @@ -0,0 +1,5 @@ +#include +#include "resource.h" + +#include "lang/de-DE.rc" +#include "lang/en-US.rc" diff --git a/reactos/base/applications/shutdown/shutdown.c b/reactos/base/applications/shutdown/shutdown.c index 730c050bdec..423b7f88816 100644 --- a/reactos/base/applications/shutdown/shutdown.c +++ b/reactos/base/applications/shutdown/shutdown.c @@ -5,23 +5,18 @@ * PURPOSE: Initiate logoff, shutdown or reboot of the system */ -#include -#include -#include -#include -#include //shutdown codes +#include "precomp.h" // Print information about which commandline arguments the program accepts. static void PrintUsage() { - _tprintf(_T("Usage: shutdown [-?] [-l | -s | -r] [-f]\n")); - _tprintf(_T("\n No args or -?\t\tDisplay this message")); - _tprintf(_T("\n -l\t\t\tLog off")); - _tprintf(_T("\n -s\t\t\tShutdown the computer")); - _tprintf(_T("\n -r\t\t\tShutdown and restart the computer")); - _tprintf(_T("\n -f\t\t\tForces running applications to close without warnings")); - _tprintf(_T("\n \t\t\tIf you did not specify any other parameter, this option")); - _tprintf(_T("\n \t\t\twill also log off")); - _tprintf(_T("\n")); + LPTSTR lpUsage = NULL; + + if( AllocAndLoadString( &lpUsage, + GetModuleHandle(NULL), + IDS_USAGE ) ) + { + _putts( lpUsage ); + } } struct CommandLineOptions { diff --git a/reactos/base/applications/shutdown/shutdown.rbuild b/reactos/base/applications/shutdown/shutdown.rbuild index c398f3cb852..386f552ddbf 100644 --- a/reactos/base/applications/shutdown/shutdown.rbuild +++ b/reactos/base/applications/shutdown/shutdown.rbuild @@ -7,5 +7,8 @@ advapi32 user32 kernel32 + misc.c shutdown.c + shutdown.rc + precomp.h diff --git a/reactos/base/applications/shutdown/shutdown.rc b/reactos/base/applications/shutdown/shutdown.rc new file mode 100644 index 00000000000..c9bb11d2805 --- /dev/null +++ b/reactos/base/applications/shutdown/shutdown.rc @@ -0,0 +1,9 @@ +#include +#include "resource.h" + +#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Shutdown Utility\0" +#define REACTOS_STR_INTERNAL_NAME "shutdown\0" +#define REACTOS_STR_ORIGINAL_FILENAME "shutdown.exe\0" +#include + +#include "rsrc.rc"