dropped unused TSVN settings
[TortoiseGit.git] / src / ResText / ResText.cpp
blobb1ebb930b9664443a11a4202f02b5aeebe8abf36
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2006 - Stefan Kueng
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.
18 #include "stdafx.h"
19 #include "ResModule.h"
21 #include <string>
22 #include <vector>
23 #include "shlwapi.h"
24 #pragma comment(lib, "shlwapi.lib")
26 typedef std::basic_string<wchar_t> wstring;
27 #ifdef UNICODE
28 # define stdstring wstring
29 #else
30 # define stdstring std::string
31 #endif
33 int _tmain(int argc, _TCHAR* argv[])
35 bool bShowHelp = true;
36 bool bQuiet = false;
37 bool bNoUpdate = false;
38 bool bRTL = false;
39 //parse the command line
40 std::vector<stdstring> arguments;
41 std::vector<stdstring> switches;
42 for (int i=1; i<argc; ++i)
44 if ((argv[i][0] == '-')||(argv[i][0] == '/'))
46 stdstring str = stdstring(&argv[i][1]);
47 switches.push_back(str);
49 else
51 stdstring str = stdstring(&argv[i][0]);
52 arguments.push_back(str);
56 for (std::vector<stdstring>::iterator I = switches.begin(); I != switches.end(); ++I)
58 if (_tcscmp(I->c_str(), _T("?"))==0)
59 bShowHelp = true;
60 if (_tcscmp(I->c_str(), _T("help"))==0)
61 bShowHelp = true;
62 if (_tcscmp(I->c_str(), _T("quiet"))==0)
63 bQuiet = true;
64 if (_tcscmp(I->c_str(), _T("noupdate"))==0)
65 bNoUpdate = true;
66 if (_tcscmp(I->c_str(), _T("rtl"))==0)
67 bRTL = true;
69 std::vector<stdstring>::iterator arg = arguments.begin();
71 if (arg != arguments.end())
73 if (_tcscmp(arg->c_str(), _T("extract"))==0)
75 stdstring sDllFile;
76 stdstring sPoFile;
77 ++arg;
79 std::vector<std::wstring> filelist = arguments;
80 filelist.erase(filelist.begin());
81 sPoFile = stdstring((--filelist.end())->c_str());
82 filelist.erase(--filelist.end());
84 CResModule module;
85 module.SetQuiet(bQuiet);
86 if (!module.ExtractResources(filelist, sPoFile.c_str(), bNoUpdate))
87 return -1;
88 bShowHelp = false;
90 else if (_tcscmp(arg->c_str(), _T("apply"))==0)
92 stdstring sSrcDllFile;
93 stdstring sDstDllFile;
94 stdstring sPoFile;
95 WORD wLang = 0;
96 ++arg;
97 if (!PathFileExists(arg->c_str()))
99 _ftprintf(stderr, _T("the resource dll <%s> does not exist!\n"), arg->c_str());
100 return -1;
102 sSrcDllFile = stdstring(arg->c_str());
103 ++arg;
104 sDstDllFile = stdstring(arg->c_str());
105 ++arg;
106 if (!PathFileExists(arg->c_str()))
108 _ftprintf(stderr, _T("the po-file <%s> does not exist!\n"), arg->c_str());
109 return -1;
111 sPoFile = stdstring(arg->c_str());
112 ++arg;
113 if (arg != arguments.end())
115 wLang = (WORD)_ttoi(arg->c_str());
117 CResModule module;
118 module.SetQuiet(bQuiet);
119 module.SetLanguage(wLang);
120 module.SetRTL(bRTL);
121 if (!module.CreateTranslatedResources(sSrcDllFile.c_str(), sDstDllFile.c_str(), sPoFile.c_str()))
122 return -1;
123 bShowHelp = false;
127 if (bShowHelp)
129 _ftprintf(stdout, _T("usage:\n"));
130 _ftprintf(stdout, _T("\n"));
131 _ftprintf(stdout, _T("ResText extract <resource.dll> [<resource.dll> ...] <po-file> [-quiet] [-noupdate]\n"));
132 _ftprintf(stdout, _T("Extracts all strings from the resource dll and writes them to the po-file\n"));
133 _ftprintf(stdout, _T("-quiet: don't print progress messages\n"));
134 _ftprintf(stdout, _T("-noupdate: overwrite the po-file\n"));
135 _ftprintf(stdout, _T("\n"));
136 _ftprintf(stdout, _T("ResText apply <src resource.dll> <dst resource.dll> <po-file> [langID] [-quiet][-rtl]\n"));
137 _ftprintf(stdout, _T("Replaces all strings in the dst resource.dll with the po-file translations\n"));
138 _ftprintf(stdout, _T("-quiet: don't print progress messages\n"));
139 _ftprintf(stdout, _T("-rtl : change the controls to RTL reading\n"));
140 _ftprintf(stdout, _T("\n"));
143 return 0;