1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2006,2009-2011 - 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 typedef std::basic_string
<TCHAR
> tstring
;
28 int _tmain(int argc
, _TCHAR
* argv
[])
30 bool bShowHelp
= true;
32 bool bNoUpdate
= false;
34 bool bUseHeader
= false;
35 bool bAdjustEOLs
= false;
36 //parse the command line
37 std::vector
<tstring
> arguments
;
38 std::vector
<tstring
> switches
;
39 for (int i
=1; i
<argc
; ++i
)
41 if ((argv
[i
][0] == '-')||(argv
[i
][0] == '/'))
43 tstring str
= tstring(&argv
[i
][1]);
44 switches
.push_back(str
);
48 tstring str
= tstring(&argv
[i
][0]);
49 arguments
.push_back(str
);
53 for (std::vector
<tstring
>::iterator I
= switches
.begin(); I
!= switches
.end(); ++I
)
55 if (_tcscmp(I
->c_str(), _T("?"))==0)
57 if (_tcscmp(I
->c_str(), _T("help"))==0)
59 if (_tcscmp(I
->c_str(), _T("quiet"))==0)
61 if (_tcscmp(I
->c_str(), _T("noupdate"))==0)
63 if (_tcscmp(I
->c_str(), _T("rtl"))==0)
65 if (_tcscmp(I
->c_str(), _T("useheaderfile"))==0)
67 if (_tcscmp(I
->c_str(), _T("adjusteols"))==0)
70 std::vector
<tstring
>::iterator arg
= arguments
.begin();
72 if (arg
!= arguments
.end())
74 if (_tcscmp(arg
->c_str(), _T("extract"))==0)
81 std::vector
<std::wstring
> filelist
= arguments
;
82 filelist
.erase(filelist
.begin());
83 sPoFile
= tstring((--filelist
.end())->c_str());
84 filelist
.erase(--filelist
.end());
87 sHeaderFile
= tstring((--filelist
.end())->c_str());
88 filelist
.erase(--filelist
.end());
92 module
.SetQuiet(bQuiet
);
93 if (!module
.ExtractResources(filelist
, sPoFile
.c_str(), bNoUpdate
, sHeaderFile
.c_str()))
97 else if (_tcscmp(arg
->c_str(), _T("apply"))==0)
104 if (!PathFileExists(arg
->c_str()))
106 _ftprintf(stderr
, _T("the resource dll <%s> does not exist!\n"), arg
->c_str());
109 sSrcDllFile
= tstring(arg
->c_str());
111 sDstDllFile
= tstring(arg
->c_str());
113 if (!PathFileExists(arg
->c_str()))
115 _ftprintf(stderr
, _T("the po-file <%s> does not exist!\n"), arg
->c_str());
118 sPoFile
= tstring(arg
->c_str());
120 if (arg
!= arguments
.end())
122 wLang
= (WORD
)_ttoi(arg
->c_str());
125 module
.SetQuiet(bQuiet
);
126 module
.SetLanguage(wLang
);
128 module
.SetAdjustEOLs(bAdjustEOLs
);
129 if (!module
.CreateTranslatedResources(sSrcDllFile
.c_str(), sDstDllFile
.c_str(), sPoFile
.c_str()))
137 _ftprintf(stdout
, _T("usage:\n"));
138 _ftprintf(stdout
, _T("\n"));
139 _ftprintf(stdout
, _T("ResText extract <resource.dll> [<resource.dll> ...] [-useheaderfile <headerfile>] <po-file> [-quiet] [-noupdate]\n"));
140 _ftprintf(stdout
, _T("Extracts all strings from the resource dll and writes them to the po-file\n"));
141 _ftprintf(stdout
, _T("-useheaderfile: the content of the header file instead of a default header\n"));
142 _ftprintf(stdout
, _T("-quiet: don't print progress messages\n"));
143 _ftprintf(stdout
, _T("-noupdate: overwrite the po-file\n"));
144 _ftprintf(stdout
, _T("\n"));
145 _ftprintf(stdout
, _T("ResText apply <src resource.dll> <dst resource.dll> <po-file> [langID] [-quiet][-rtl]\n"));
146 _ftprintf(stdout
, _T("Replaces all strings in the dst resource.dll with the po-file translations\n"));
147 _ftprintf(stdout
, _T("-quiet: don't print progress messages\n"));
148 _ftprintf(stdout
, _T("-rtl : change the controls to RTL reading\n"));
149 _ftprintf(stdout
, _T("-adjusteols : if the msgid string has \\r\\n eols, enforce those for the translation too.\n"));
150 _ftprintf(stdout
, _T("\n"));