1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2007 - TortoiseSVN
\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
24 #define GET_WORD(ptr) (*(WORD *)(ptr))
\r
25 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
\r
26 #define ALIGN_DWORD(type, p) ((type)(((DWORD)p + 3) & ~3))
\r
28 #define MAX_STRING_LENGTH (32*1024)
\r
30 // DIALOG CONTROL INFORMATION
\r
31 typedef struct tagDlgItemInfo
\r
44 } DLGITEMINFO, * LPDLGITEMINFO;
\r
47 typedef struct tagDialogInfo
\r
65 } DIALOGINFO, * LPDIALOGINFO;
\r
67 typedef struct tagMenuEntry
\r
70 std::wstring reference;
\r
71 std::wstring msgstr;
\r
72 } MENUENTRY, * LPMENUENTRY;
\r
76 * Class to handle a resource module (*.exe or *.dll file).
\r
78 * Provides methods to extract and apply resource strings.
\r
86 BOOL ExtractResources(LPCTSTR lpszSrcLangDllPath, LPCTSTR lpszPOFilePath, BOOL bNoUpdate);
\r
87 BOOL ExtractResources(std::vector<std::wstring> filelist, LPCTSTR lpszPOFilePath, BOOL bNoUpdate);
\r
88 BOOL CreateTranslatedResources(LPCTSTR lpszSrcLangDllPath, LPCTSTR lpszDestLangDllPath, LPCTSTR lpszPOFilePath);
\r
89 void SetQuiet(BOOL bQuiet = TRUE) {m_bQuiet = bQuiet; m_StringEntries.SetQuiet(bQuiet);}
\r
90 void SetLanguage(WORD wLangID) {m_wTargetLang = wLangID;}
\r
91 void SetRTL(bool bRTL = true) {m_bRTL = bRTL;}
\r
94 static BOOL CALLBACK EnumResNameCallback(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG_PTR lParam);
\r
95 static BOOL CALLBACK EnumResNameWriteCallback(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG_PTR lParam);
\r
96 static BOOL CALLBACK EnumResWriteLangCallback(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, WORD wLanguage, LONG_PTR lParam);
\r
97 BOOL ExtractString(UINT nID);
\r
98 BOOL ExtractDialog(UINT nID);
\r
99 BOOL ExtractMenu(UINT nID);
\r
100 BOOL ReplaceString(UINT nID, WORD wLanguage);
\r
101 BOOL ReplaceDialog(UINT nID, WORD wLanguage);
\r
102 BOOL ReplaceMenu(UINT nID, WORD wLanguage);
\r
103 BOOL ExtractAccelerator(UINT nID);
\r
104 BOOL ReplaceAccelerator(UINT nID, WORD wLanguage);
\r
106 const WORD* ParseMenuResource(const WORD * res);
\r
107 const WORD* CountMemReplaceMenuResource(const WORD * res, size_t * wordcount, WORD * newMenu);
\r
108 const WORD* ParseMenuExResource(const WORD * res);
\r
109 const WORD* CountMemReplaceMenuExResource(const WORD * res, size_t * wordcount, WORD * newMenu);
\r
110 const WORD* GetControlInfo(const WORD* p, LPDLGITEMINFO lpDlgItemInfo, BOOL dialogEx, LPBOOL bIsID);
\r
111 const WORD* GetDialogInfo(const WORD * pTemplate, LPDIALOGINFO lpDlgInfo);
\r
112 const WORD* CountMemReplaceDialogResource(const WORD * res, size_t * wordcount, WORD * newMenu);
\r
113 const WORD* ReplaceControlInfo(const WORD * res, size_t * wordcount, WORD * newDialog, BOOL bEx);
\r
115 void ReplaceStr(LPCWSTR src, WORD * dest, size_t * count, int * translated, int * def);
\r
118 HANDLE m_hUpdateRes;
\r
119 CPOFile m_StringEntries;
\r
120 std::map<WORD, MENUENTRY> m_MenuEntries;
\r
121 std::map<WORD, MENUENTRY>::iterator pME_iter;
\r
122 std::wstring sDestFile;
\r
127 int m_bTranslatedStrings;
\r
128 int m_bDefaultStrings;
\r
129 int m_bTranslatedDialogStrings;
\r
130 int m_bDefaultDialogStrings;
\r
131 int m_bTranslatedMenuStrings;
\r
132 int m_bDefaultMenuStrings;
\r
133 int m_bTranslatedAcceleratorStrings;
\r
134 int m_bDefaultAcceleratorStrings;
\r
136 WORD m_wTargetLang;
\r