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(LPCTSTR lpszType
);
99 BOOL
ExtractDialog(LPCTSTR lpszType
);
100 BOOL
ExtractMenu(LPCTSTR lpszType
);
101 BOOL
ExtractRibbon(LPCTSTR lpszType
);
102 BOOL
ReplaceString(LPCTSTR lpszType
, WORD wLanguage
);
103 BOOL
ReplaceDialog(LPCTSTR lpszType
, WORD wLanguage
);
104 BOOL
ReplaceMenu(LPCTSTR lpszType
, WORD wLanguage
);
105 BOOL
ExtractAccelerator(LPCTSTR lpszType
);
106 BOOL
ReplaceAccelerator(LPCTSTR lpszType
, WORD wLanguage
);
107 BOOL
ReplaceRibbon(LPCTSTR lpszType
, WORD wLanguage
);
109 const WORD
* ParseMenuResource(const WORD
* res
);
110 const WORD
* CountMemReplaceMenuResource(const WORD
* res
, size_t * wordcount
, WORD
* newMenu
);
111 const WORD
* ParseMenuExResource(const WORD
* res
);
112 const WORD
* CountMemReplaceMenuExResource(const WORD
* res
, size_t * wordcount
, WORD
* newMenu
);
113 const WORD
* GetControlInfo(const WORD
* p
, LPDLGITEMINFO lpDlgItemInfo
, BOOL dialogEx
, LPBOOL bIsID
);
114 const WORD
* GetDialogInfo(const WORD
* pTemplate
, LPDIALOGINFO lpDlgInfo
);
115 const WORD
* CountMemReplaceDialogResource(const WORD
* res
, size_t * wordcount
, WORD
* newMenu
);
116 const WORD
* ReplaceControlInfo(const WORD
* res
, size_t * wordcount
, WORD
* newDialog
, BOOL bEx
);
118 void ReplaceStr(LPCWSTR src
, WORD
* dest
, size_t * count
, int * translated
, int * def
);
122 CPOFile m_StringEntries
;
123 std::map
<WORD
, MENUENTRY
> m_MenuEntries
;
124 std::map
<WORD
, MENUENTRY
>::iterator pME_iter
;
125 std::wstring sDestFile
;
131 int m_bTranslatedStrings
;
132 int m_bDefaultStrings
;
133 int m_bTranslatedDialogStrings
;
134 int m_bDefaultDialogStrings
;
135 int m_bTranslatedMenuStrings
;
136 int m_bDefaultMenuStrings
;
137 int m_bTranslatedAcceleratorStrings
;
138 int m_bDefaultAcceleratorStrings
;
139 int m_bTranslatedRibbonTexts
;
140 int m_bDefaultRibbonTexts
;