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