1
// TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2006, 2009-2012, 2014-2015 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "ResModule.h"
24 #pragma comment(lib, "shlwapi.lib")
26 int wmain(int argc
, wchar_t* argv
[])
28 bool bShowHelp
= true;
30 bool bNoUpdate
= false;
32 bool bUseHeader
= false;
33 bool bAdjustEOLs
= false;
34 //parse the command line
35 std::vector
<std::wstring
> arguments
;
36 std::vector
<std::wstring
> switches
;
37 for (int i
=1; i
<argc
; ++i
)
39 if ((argv
[i
][0] == '-')||(argv
[i
][0] == '/'))
41 std::wstring str
= std::wstring(&argv
[i
][1]);
42 switches
.push_back(str
);
46 std::wstring str
= std::wstring(&argv
[i
][0]);
47 arguments
.push_back(str
);
51 for (auto I
= switches
.cbegin(); I
!= switches
.cend(); ++I
)
53 if (wcscmp(I
->c_str(), L
"?")==0)
55 if (wcscmp(I
->c_str(), L
"help")==0)
57 if (wcscmp(I
->c_str(), L
"quiet")==0)
59 if (wcscmp(I
->c_str(), L
"noupdate")==0)
61 if (wcscmp(I
->c_str(), L
"rtl")==0)
63 if (wcscmp(I
->c_str(), L
"useheaderfile")==0)
65 if (wcscmp(I
->c_str(), L
"adjusteols")==0)
68 auto arg
= arguments
.cbegin();
70 if (arg
!= arguments
.cend())
72 if (wcscmp(arg
->c_str(), L
"extract")==0)
75 std::wstring sHeaderFile
;
78 std::vector
<std::wstring
> filelist
= arguments
;
79 filelist
.erase(filelist
.begin());
80 sPoFile
= std::wstring((--filelist
.end())->c_str());
81 filelist
.erase(--filelist
.end());
84 sHeaderFile
= std::wstring((--filelist
.end())->c_str());
85 filelist
.erase(--filelist
.end());
89 module
.SetQuiet(bQuiet
);
90 if (!module
.ExtractResources(filelist
, sPoFile
.c_str(), bNoUpdate
, sHeaderFile
.c_str()))
94 else if (wcscmp(arg
->c_str(), L
"apply")==0)
96 std::wstring sSrcDllFile
;
97 std::wstring sDstDllFile
;
101 if (!PathFileExists(arg
->c_str()))
103 fwprintf(stderr
, L
"the resource dll <%s> does not exist!\n", arg
->c_str());
106 sSrcDllFile
= std::wstring(arg
->c_str());
108 sDstDllFile
= std::wstring(arg
->c_str());
110 if (!PathFileExists(arg
->c_str()))
112 fwprintf(stderr
, L
"the po-file <%s> does not exist!\n", arg
->c_str());
115 sPoFile
= std::wstring(arg
->c_str());
117 if (arg
!= arguments
.end())
119 wLang
= static_cast<WORD
>(_wtoi(arg
->c_str()));
122 module
.SetQuiet(bQuiet
);
123 module
.SetLanguage(wLang
);
125 module
.SetAdjustEOLs(bAdjustEOLs
);
126 if (!module
.CreateTranslatedResources(sSrcDllFile
.c_str(), sDstDllFile
.c_str(), sPoFile
.c_str()))
134 fwprintf(stdout
, L
"usage:\n");
135 fwprintf(stdout
, L
"\n");
136 fwprintf(stdout
, L
"ResText extract <resource.dll> [<resource.dll> ...] [-useheaderfile <headerfile>] <po-file> [-quiet] [-noupdate]\n");
137 fwprintf(stdout
, L
"Extracts all strings from the resource dll and writes them to the po-file\n");
138 fwprintf(stdout
, L
"-useheaderfile: the content of the header file instead of a default header\n");
139 fwprintf(stdout
, L
"-quiet: don't print progress messages\n");
140 fwprintf(stdout
, L
"-noupdate: overwrite the po-file\n");
141 fwprintf(stdout
, L
"\n");
142 fwprintf(stdout
, L
"ResText apply <src resource.dll> <dst resource.dll> <po-file> [langID] [-quiet][-rtl]\n");
143 fwprintf(stdout
, L
"Replaces all strings in the dst resource.dll with the po-file translations\n");
144 fwprintf(stdout
, L
"-quiet: don't print progress messages\n");
145 fwprintf(stdout
, L
"-rtl : change the controls to RTL reading\n");
146 fwprintf(stdout
, L
"-adjusteols : if the msgid string has \\r\\n eols, enforce those for the translation too.\n");
147 fwprintf(stdout
, L
"\n");
148 fwprintf(stdout
, L
"Note: when extracting resources, C-resource header files can be specified\n");
149 fwprintf(stdout
, L
"like this: <resource.dll>*<resource.h>*<resource.h>*...\n");
150 fwprintf(stdout
, L
"If a resource header file is specified, the defines are used in the po file\n");
151 fwprintf(stdout
, L
"as hints instead of the plain control ID number.\n");