1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2006 - Stefan Kueng
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
19 #include "ResModule.h"
\r
23 #include "shlwapi.h"
\r
24 #pragma comment(lib, "shlwapi.lib")
\r
26 typedef std::basic_string<wchar_t> wstring;
\r
28 # define stdstring wstring
\r
30 # define stdstring std::string
\r
33 int _tmain(int argc, _TCHAR* argv[])
\r
35 bool bShowHelp = true;
\r
36 bool bQuiet = false;
\r
37 bool bNoUpdate = false;
\r
39 //parse the command line
\r
40 std::vector<stdstring> arguments;
\r
41 std::vector<stdstring> switches;
\r
42 for (int i=1; i<argc; ++i)
\r
44 if ((argv[i][0] == '-')||(argv[i][0] == '/'))
\r
46 stdstring str = stdstring(&argv[i][1]);
\r
47 switches.push_back(str);
\r
51 stdstring str = stdstring(&argv[i][0]);
\r
52 arguments.push_back(str);
\r
56 for (std::vector<stdstring>::iterator I = switches.begin(); I != switches.end(); ++I)
\r
58 if (_tcscmp(I->c_str(), _T("?"))==0)
\r
60 if (_tcscmp(I->c_str(), _T("help"))==0)
\r
62 if (_tcscmp(I->c_str(), _T("quiet"))==0)
\r
64 if (_tcscmp(I->c_str(), _T("noupdate"))==0)
\r
66 if (_tcscmp(I->c_str(), _T("rtl"))==0)
\r
69 std::vector<stdstring>::iterator arg = arguments.begin();
\r
71 if (arg != arguments.end())
\r
73 if (_tcscmp(arg->c_str(), _T("extract"))==0)
\r
79 std::vector<std::wstring> filelist = arguments;
\r
80 filelist.erase(filelist.begin());
\r
81 sPoFile = stdstring((--filelist.end())->c_str());
\r
82 filelist.erase(--filelist.end());
\r
85 module.SetQuiet(bQuiet);
\r
86 if (!module.ExtractResources(filelist, sPoFile.c_str(), bNoUpdate))
\r
90 else if (_tcscmp(arg->c_str(), _T("apply"))==0)
\r
92 stdstring sSrcDllFile;
\r
93 stdstring sDstDllFile;
\r
97 if (!PathFileExists(arg->c_str()))
\r
99 _ftprintf(stderr, _T("the resource dll <%s> does not exist!\n"), arg->c_str());
\r
102 sSrcDllFile = stdstring(arg->c_str());
\r
104 sDstDllFile = stdstring(arg->c_str());
\r
106 if (!PathFileExists(arg->c_str()))
\r
108 _ftprintf(stderr, _T("the po-file <%s> does not exist!\n"), arg->c_str());
\r
111 sPoFile = stdstring(arg->c_str());
\r
113 if (arg != arguments.end())
\r
115 wLang = (WORD)_ttoi(arg->c_str());
\r
118 module.SetQuiet(bQuiet);
\r
119 module.SetLanguage(wLang);
\r
120 module.SetRTL(bRTL);
\r
121 if (!module.CreateTranslatedResources(sSrcDllFile.c_str(), sDstDllFile.c_str(), sPoFile.c_str()))
\r
129 _ftprintf(stdout, _T("usage:\n"));
\r
130 _ftprintf(stdout, _T("\n"));
\r
131 _ftprintf(stdout, _T("ResText extract <resource.dll> [<resource.dll> ...] <po-file> [-quiet] [-noupdate]\n"));
\r
132 _ftprintf(stdout, _T("Extracts all strings from the resource dll and writes them to the po-file\n"));
\r
133 _ftprintf(stdout, _T("-quiet: don't print progress messages\n"));
\r
134 _ftprintf(stdout, _T("-noupdate: overwrite the po-file\n"));
\r
135 _ftprintf(stdout, _T("\n"));
\r
136 _ftprintf(stdout, _T("ResText apply <src resource.dll> <dst resource.dll> <po-file> [langID] [-quiet][-rtl]\n"));
\r
137 _ftprintf(stdout, _T("Replaces all strings in the dst resource.dll with the po-file translations\n"));
\r
138 _ftprintf(stdout, _T("-quiet: don't print progress messages\n"));
\r
139 _ftprintf(stdout, _T("-rtl : change the controls to RTL reading\n"));
\r
140 _ftprintf(stdout, _T("\n"));
\r