Index: src/ictranslate/ICTranslateDlg.cpp =================================================================== diff -u -r50fea83cc4ee863edac0fd3960e2249f99c33b03 -r2ffaff594233ce671e00b842c718cca32f9498c5 --- src/ictranslate/ICTranslateDlg.cpp (.../ICTranslateDlg.cpp) (revision 50fea83cc4ee863edac0fd3960e2249f99c33b03) +++ src/ictranslate/ICTranslateDlg.cpp (.../ICTranslateDlg.cpp) (revision 2ffaff594233ce671e00b842c718cca32f9498c5) @@ -5,11 +5,16 @@ #include "ictranslate.h" #include "ICTranslateDlg.h" #include +#include #ifdef _DEBUG #define new DEBUG_NEW #endif +#define IMAGE_INVALID 0 +#define IMAGE_NONEXISTENT 1 +#define IMAGE_OVERFLUOUS 2 +#define IMAGE_VALID 3 // CAboutDlg dialog used for App About @@ -60,6 +65,18 @@ DDX_Control(pDX, IDC_DSTDATA_LIST, m_ctlCustomLanguageList); DDX_Control(pDX, IDC_SRCDATA_EDIT, m_ctlSrcText); DDX_Control(pDX, IDC_DSTDATA_EDIT, m_ctlDstText); + DDX_Control(pDX, IDC_SRC_FILENAME_EDIT, m_ctlSrcFilename); + DDX_Control(pDX, IDC_SRC_AUTHOR_EDIT, m_ctlSrcAuthor); + DDX_Control(pDX, IDC_SRC_LANGUAGE_NAME_EDIT, m_ctlSrcLanguageName); + DDX_Control(pDX, IDC_SRC_HELP_FILENAME_EDIT, m_ctlSrcHelpFilename); + DDX_Control(pDX, IDC_SRC_FONT_EDIT, m_ctlSrcFont); + DDX_Control(pDX, IDC_SRC_RTL_CHECK, m_ctlSrcRTL); + DDX_Control(pDX, IDC_DST_FILENAME_EDIT, m_ctlDstFilename); + DDX_Control(pDX, IDC_DST_AUTHOR_EDIT, m_ctlDstAuthor); + DDX_Control(pDX, IDC_DST_LANGUAGE_NAME_EDIT, m_ctlDstLanguageName); + DDX_Control(pDX, IDC_DST_HELP_FILENAME_EDIT, m_ctlDstHelpFilename); + DDX_Control(pDX, IDC_DST_FONT_EDIT, m_ctlDstFont); + DDX_Control(pDX, IDC_DST_RTL_CHECK, m_ctlDstRTL); } BEGIN_MESSAGE_MAP(CICTranslateDlg, CDialog) @@ -71,6 +88,10 @@ ON_COMMAND(ID_FILE_OPENYOURTRANSLATION, &CICTranslateDlg::OnFileOpenYourTranslation) ON_NOTIFY(LVN_ITEMCHANGED, IDC_SRCDATA_LIST, &CICTranslateDlg::OnItemChangedSrcDataList) ON_NOTIFY(LVN_ITEMCHANGED, IDC_DSTDATA_LIST, &CICTranslateDlg::OnItemChangedDstDataList) + ON_BN_CLICKED(IDC_COPY_BUTTON, &CICTranslateDlg::OnBnClickedCopyButton) + ON_BN_CLICKED(IDAPPLY, &CICTranslateDlg::OnBnClickedApply) + ON_BN_CLICKED(IDC_CHOOSE_FONT_BUTTON, &CICTranslateDlg::OnBnClickedChooseFontButton) + ON_COMMAND(ID_EDIT_CLEANUP_TRANSLATION, &CICTranslateDlg::OnEditCleanupTranslation) END_MESSAGE_MAP() @@ -102,6 +123,14 @@ SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon + m_ilImages.Create(16, 16, ILC_COLOR4 | ILC_MASK, 0, 4); + m_ilImages.Add(AfxGetApp()->LoadIcon(IDI_INVALID_ICON)); + m_ilImages.Add(AfxGetApp()->LoadIcon(IDI_NONEXISTENT_ICON)); + m_ilImages.Add(AfxGetApp()->LoadIcon(IDI_OVERFLUOUS_ICON)); + m_ilImages.Add(AfxGetApp()->LoadIcon(IDI_VALID_ICON)); + + m_ctlCustomLanguageList.SetImageList(&m_ilImages, LVSIL_SMALL); + m_ctlBaseLanguageList.SetExtendedStyle(LVS_EX_FULLROWSELECT); m_ctlCustomLanguageList.SetExtendedStyle(LVS_EX_FULLROWSELECT); @@ -178,10 +207,12 @@ if(fd.DoModal() == IDOK) { if(!m_ldBase.ReadTranslation(fd.GetPathName())) + { AfxMessageBox(_T("Reading file failed")); + return; + } - // add texts to the list - m_ldBase.EnumStrings(&EnumLngStrings, &m_ctlBaseLanguageList); + UpdateBaseLanguageList(); } } @@ -191,11 +222,12 @@ if(fd.DoModal() == IDOK) { if(!m_ldCustom.ReadTranslation(fd.GetPathName())) + { AfxMessageBox(_T("Reading file failed")); + return; + } - // add texts to the list - m_ctlCustomLanguageList.DeleteAllItems(); - m_ldCustom.EnumStrings(&EnumLngStrings, &m_ctlCustomLanguageList); + UpdateCustomLanguageList(); } } @@ -310,9 +342,245 @@ m_ctlSrcText.SetWindowText(_T("")); } } +void CICTranslateDlg::UpdateBaseLanguageList() +{ + // fill the informations about the translation + m_ctlSrcFilename.SetWindowText(m_ldBase.GetFilename(true)); + m_ctlSrcAuthor.SetWindowText(m_ldBase.GetAuthor()); + m_ctlSrcLanguageName.SetWindowText(m_ldBase.GetLangName()); + m_ctlSrcHelpFilename.SetWindowText(m_ldBase.GetHelpName()); + CString strFont; + if(m_ldBase.GetFontFace()) + strFont.Format(TSTRFMT _T(", ") UIFMT, m_ldBase.GetFontFace(), m_ldBase.GetPointSize()); + m_ctlSrcFont.SetWindowText(strFont); + m_ctlSrcRTL.SetCheck(m_ldBase.GetDirection() ? BST_CHECKED : BST_UNCHECKED); + // add texts to the list + m_ctlBaseLanguageList.DeleteAllItems(); + m_ldBase.EnumStrings(&EnumLngStrings, &m_ctlBaseLanguageList); + m_ctlBaseLanguageList.SortItems(&ListSortFunc, NULL); + + UpdateCustomListImages(); +} + +void CICTranslateDlg::UpdateCustomLanguageList() +{ + // fill the informations about the translation + m_ctlDstFilename.SetWindowText(m_ldCustom.GetFilename(true)); + m_ctlDstAuthor.SetWindowText(m_ldCustom.GetAuthor()); + m_ctlDstLanguageName.SetWindowText(m_ldCustom.GetLangName()); + m_ctlDstHelpFilename.SetWindowText(m_ldCustom.GetHelpName()); + m_ctlDstRTL.SetCheck(m_ldCustom.GetDirection() ? BST_CHECKED : BST_UNCHECKED); + CString strFont; + if(m_ldCustom.GetFontFace()) + strFont.Format(TSTRFMT _T(", ") UIFMT, m_ldCustom.GetFontFace(), m_ldCustom.GetPointSize()); + m_ctlDstFont.SetWindowText(strFont); + + // add texts to the list + m_ctlCustomLanguageList.DeleteAllItems(); + m_ldCustom.EnumStrings(&EnumLngStrings, &m_ctlCustomLanguageList); + + // now add the items that exists in the base language and does not exist in the custom one + std::set setCustomKeys; + + // enum items from custom list + int iCount = m_ctlCustomLanguageList.GetItemCount(); + for(int i = 0; i < iCount; i++) + { + setCustomKeys.insert(m_ctlCustomLanguageList.GetItemData(i)); + } + + // add to custom list values from base that does not exist + iCount = m_ctlBaseLanguageList.GetItemCount(); + for(int i = 0; i < iCount; i++) + { + uint_t uiID = m_ctlBaseLanguageList.GetItemData(i); + if(setCustomKeys.find(uiID) == setCustomKeys.end()) + { + // string does not exist in the custom list - add + CString strID; + strID.Format(UIFMT, uiID); + + LVITEM lvi; + lvi.mask = LVIF_TEXT | LVIF_PARAM; + lvi.pszText = (PTSTR)(PCTSTR)strID; + lvi.iItem = 0; + lvi.iSubItem = 0; + lvi.lParam = uiID; + + m_ctlCustomLanguageList.InsertItem(&lvi); + + lvi.mask = LVIF_TEXT; + lvi.pszText = _T(""); + lvi.iItem = 0; + lvi.iSubItem = 1; + + m_ctlCustomLanguageList.SetItem(&lvi); + } + } + m_ctlCustomLanguageList.SortItems(&ListSortFunc, NULL); + + UpdateCustomListImages(); +} + void CICTranslateDlg::UpdateCustomListImages() { int iCount = m_ctlCustomLanguageList.GetItemCount(); + for(int i = 0; i < iCount; i++) + { + UpdateCustomListImage(i, false); + } +} +void CICTranslateDlg::UpdateCustomListImage(int iItem, bool bUpdateText) +{ + uint_t uiID = m_ctlCustomLanguageList.GetItemData(iItem); + ictranslate::CTranslationItem* pBaseItem = m_ldBase.GetTranslationItem(uiID, false); + ictranslate::CTranslationItem* pCustomItem = m_ldCustom.GetTranslationItem(uiID, false); + LVITEM lvi; + if(pCustomItem) + { + if(pBaseItem) + { + if(pCustomItem->GetChecksum() != pBaseItem->GetChecksum()) + lvi.iImage = IMAGE_INVALID; + else + lvi.iImage = IMAGE_VALID; + } + else + lvi.iImage = IMAGE_OVERFLUOUS; + } + else + { + if(pBaseItem) + lvi.iImage = IMAGE_NONEXISTENT; + else + assert(false); + } + lvi.mask = LVIF_IMAGE; + lvi.iItem = iItem; + lvi.iSubItem = 0; + m_ctlCustomLanguageList.SetItem(&lvi); + + if(bUpdateText) + { + lvi.iItem = iItem; + lvi.iSubItem = 1; + lvi.mask = LVIF_TEXT; + if(pCustomItem) + lvi.pszText = (PTSTR)pCustomItem->GetText(); + else + lvi.pszText = _T(""); + + m_ctlCustomLanguageList.SetItem(&lvi); + } } + +int CALLBACK CICTranslateDlg::ListSortFunc(LPARAM lParam1, LPARAM lParam2, LPARAM /*lParamSort*/) +{ + uint_t uiID1 = (uint_t)lParam1; + uint_t uiID2 = (uint_t)lParam2; + + if(uiID1 < uiID2) + return -1; + else if(uiID1 == uiID2) + return 0; + else + return 1; +} + +void CICTranslateDlg::OnBnClickedCopyButton() +{ + CString strText; + m_ctlSrcText.GetWindowText(strText); + m_ctlDstText.SetWindowText(strText); +} + +void CICTranslateDlg::OnBnClickedApply() +{ + // set the current text as the properly translated one + CString strText; + m_ctlDstText.GetWindowText(strText); + + // locate base entry for the current text + POSITION pos = m_ctlCustomLanguageList.GetFirstSelectedItemPosition(); + if(!pos) + { + AfxMessageBox(_T("No text selected.")); + return; + } + + int iPos = m_ctlCustomLanguageList.GetNextSelectedItem(pos); + uint_t uiID = m_ctlCustomLanguageList.GetItemData(iPos); + + ictranslate::CTranslationItem* pBaseItem = m_ldBase.GetTranslationItem(uiID, false); + if(!pBaseItem) + { + AfxMessageBox(_T("No base translation available for the item. Perform translation cleanup.")); + return; + } + + // retrieve item for custom translation if exists, else create new + ictranslate::CTranslationItem* pCustomItem = m_ldCustom.GetTranslationItem(uiID, true); + if(pCustomItem) + { + pCustomItem->SetText(strText); + pCustomItem->SetChecksum(pBaseItem->GetChecksum()); + } + + UpdateCustomListImage(iPos, true); +} + +void CICTranslateDlg::OnBnClickedChooseFontButton() +{ + CClientDC dc(this); + + LOGFONT lf; + lf.lfCharSet = DEFAULT_CHARSET; + lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; + lf.lfEscapement = 0; + lf.lfItalic = 0; + lf.lfOrientation = 0; + lf.lfOutPrecision = OUT_DEFAULT_PRECIS; + lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; + lf.lfQuality = DEFAULT_QUALITY; + lf.lfStrikeOut = 0; + lf.lfUnderline = 0; + lf.lfWeight = FW_NORMAL; + lf.lfWidth = 0; + const tchar_t* pszFontFace = m_ldCustom.GetFontFace(); + if(pszFontFace) + { + lf.lfHeight = -MulDiv(m_ldCustom.GetPointSize(), GetDeviceCaps(dc.m_hDC, LOGPIXELSY), 72); + size_t stLen = _tcslen(pszFontFace); + if(stLen >= LF_FACESIZE) + stLen = LF_FACESIZE - 1; + _tcsncpy(lf.lfFaceName, pszFontFace, stLen); + lf.lfFaceName[stLen] = _T('\0'); + } + else + { + lf.lfHeight = 0; + lf.lfFaceName[0] = _T('\0'); + } + + CFontDialog dlg(&lf); + if(dlg.DoModal()) + { + // set font info + dlg.GetCurrentFont(&lf); + WORD uiPointSize = (WORD)-MulDiv(lf.lfHeight, 72, GetDeviceCaps(dc.m_hDC, LOGPIXELSY)); + m_ldCustom.SetFontFace(lf.lfFaceName); + m_ldCustom.SetPointSize(uiPointSize); + + CString strFont; + strFont.Format(TSTRFMT _T(", ") UIFMT, m_ldCustom.GetFontFace(), m_ldCustom.GetPointSize()); + m_ctlDstFont.SetWindowText(strFont); + } +} + +void CICTranslateDlg::OnEditCleanupTranslation() +{ + m_ldCustom.CleanupTranslation(m_ldBase); + UpdateCustomLanguageList(); +} Index: src/ictranslate/ICTranslateDlg.h =================================================================== diff -u -r50fea83cc4ee863edac0fd3960e2249f99c33b03 -r2ffaff594233ce671e00b842c718cca32f9498c5 --- src/ictranslate/ICTranslateDlg.h (.../ICTranslateDlg.h) (revision 50fea83cc4ee863edac0fd3960e2249f99c33b03) +++ src/ictranslate/ICTranslateDlg.h (.../ICTranslateDlg.h) (revision 2ffaff594233ce671e00b842c718cca32f9498c5) @@ -21,11 +21,19 @@ protected: static void EnumLngStrings(uint_t uiID, const ictranslate::CTranslationItem* pTranslationItem, ptr_t pData); + + void UpdateBaseLanguageList(); + void UpdateCustomLanguageList(); + void UpdateCustomListImages(); + void UpdateCustomListImage(int iItem, bool bUpdateText); + static int CALLBACK ListSortFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort); + // Implementation protected: HICON m_hIcon; + CImageList m_ilImages; ictranslate::CLangData m_ldBase; ictranslate::CLangData m_ldCustom; @@ -36,12 +44,28 @@ afx_msg HCURSOR OnQueryDragIcon(); DECLARE_MESSAGE_MAP() CListCtrl m_ctlBaseLanguageList; -public: CListCtrl m_ctlCustomLanguageList; +public: CEdit m_ctlSrcText; CEdit m_ctlDstText; afx_msg void OnFileOpenBaseTranslation(); afx_msg void OnFileOpenYourTranslation(); afx_msg void OnItemChangedSrcDataList(NMHDR *pNMHDR, LRESULT *pResult); afx_msg void OnItemChangedDstDataList(NMHDR *pNMHDR, LRESULT *pResult); + afx_msg void OnBnClickedCopyButton(); + afx_msg void OnBnClickedApply(); + CEdit m_ctlSrcFilename; + CEdit m_ctlSrcAuthor; + CEdit m_ctlSrcLanguageName; + CEdit m_ctlSrcHelpFilename; + CEdit m_ctlSrcFont; + CButton m_ctlSrcRTL; + CEdit m_ctlDstFilename; + CEdit m_ctlDstAuthor; + CEdit m_ctlDstLanguageName; + CEdit m_ctlDstHelpFilename; + CEdit m_ctlDstFont; + CButton m_ctlDstRTL; + afx_msg void OnBnClickedChooseFontButton(); + afx_msg void OnEditCleanupTranslation(); }; Index: src/ictranslate/ictranslate.rc =================================================================== diff -u -r50fea83cc4ee863edac0fd3960e2249f99c33b03 -r2ffaff594233ce671e00b842c718cca32f9498c5 --- src/ictranslate/ictranslate.rc (.../ictranslate.rc) (revision 50fea83cc4ee863edac0fd3960e2249f99c33b03) +++ src/ictranslate/ictranslate.rc (.../ictranslate.rc) (revision 2ffaff594233ce671e00b842c718cca32f9498c5) @@ -71,6 +71,10 @@ // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. IDR_MAINFRAME ICON "res\\ictranslate.ico" +IDI_NONEXISTENT_ICON ICON "res\\icon_nonexistent.ico" +IDI_VALID_ICON ICON "res\\icon_valid.ico" +IDI_INVALID_ICON ICON "res\\icon_invalid.ico" +IDI_OVERFLUOUS_ICON ICON "res\\icon_overfluous.ico" ///////////////////////////////////////////////////////////////////////////// // @@ -87,6 +91,10 @@ MENUITEM "&Save translation", ID_FILE_SAVETRANSLATION MENUITEM "S&ave translation as...", ID_FILE_SAVETRANSLATIONAS END + POPUP "&Edit" + BEGIN + MENUITEM "&Cleanup translation", ID_EDIT_CLEANUP_TRANSLATION + END END #endif // Polish resources @@ -118,19 +126,44 @@ DEFPUSHBUTTON "OK",IDOK,113,41,50,14,WS_GROUP END -IDD_ICTRANSLATE_DIALOG DIALOGEX 0, 0, 419, 223 +IDD_ICTRANSLATE_DIALOG DIALOGEX 0, 0, 547, 335 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW CAPTION "ICTranslate" MENU IDR_MAIN_MENU FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - CONTROL "",IDC_DSTDATA_LIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_EDITLABELS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,212,18,200,151 - CONTROL "",IDC_SRCDATA_LIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,18,197,153 - LTEXT "Base translation:",IDC_STATIC,7,7,196,8 - LTEXT "Your translation:",IDC_STATIC,212,7,200,8 - EDITTEXT IDC_SRCDATA_EDIT,7,179,198,37,ES_AUTOHSCROLL | ES_READONLY - EDITTEXT IDC_DSTDATA_EDIT,213,179,199,37,ES_AUTOHSCROLL + CONTROL "",IDC_DSTDATA_LIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_EDITLABELS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,277,114,263,151 + CONTROL "",IDC_SRCDATA_LIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,114,263,153 + LTEXT "Base translation:",IDC_STATIC,7,103,262,8 + LTEXT "Your translation:",IDC_STATIC,277,104,263,8 + EDITTEXT IDC_SRCDATA_EDIT,7,274,263,37,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY + EDITTEXT IDC_DSTDATA_EDIT,298,273,242,37,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL + PUSHBUTTON "&Apply change",IDAPPLY,471,314,69,14 + PUSHBUTTON "&>\n>",IDC_COPY_BUTTON,277,273,15,37,BS_MULTILINE + LTEXT "Author:",IDC_STATIC,7,25,58,8 + EDITTEXT IDC_SRC_AUTHOR_EDIT,69,22,201,14,ES_AUTOHSCROLL | ES_READONLY + LTEXT "File:",IDC_STATIC,7,10,58,8 + CONTROL "Right-to-left reading order",IDC_SRC_RTL_CHECK,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,7,84,263,10 + EDITTEXT IDC_SRC_FILENAME_EDIT,69,7,201,14,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Language name:",IDC_STATIC,7,40,58,8 + EDITTEXT IDC_SRC_LANGUAGE_NAME_EDIT,69,37,201,14,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Font:",IDC_STATIC,7,70,58,8 + EDITTEXT IDC_SRC_FONT_EDIT,69,67,201,14,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Help file name:",IDC_STATIC,7,55,58,8 + EDITTEXT IDC_SRC_HELP_FILENAME_EDIT,69,52,201,14,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Author:",IDC_STATIC,277,25,58,8 + EDITTEXT IDC_DST_AUTHOR_EDIT,339,22,201,14,ES_AUTOHSCROLL + LTEXT "File:",IDC_STATIC,277,10,58,8 + CONTROL "Right-to-left reading order",IDC_DST_RTL_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,277,84,263,10 + EDITTEXT IDC_DST_FILENAME_EDIT,339,7,201,14,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Language name:",IDC_STATIC,277,40,58,8 + EDITTEXT IDC_DST_LANGUAGE_NAME_EDIT,339,37,201,14,ES_AUTOHSCROLL + LTEXT "Font:",IDC_STATIC,277,70,58,8 + EDITTEXT IDC_DST_FONT_EDIT,339,67,184,14,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Help file name:",IDC_STATIC,277,55,58,8 + EDITTEXT IDC_DST_HELP_FILENAME_EDIT,339,52,201,14,ES_AUTOHSCROLL + PUSHBUTTON "&...",IDC_CHOOSE_FONT_BUTTON,524,67,16,14 END @@ -192,9 +225,9 @@ IDD_ICTRANSLATE_DIALOG, DIALOG BEGIN LEFTMARGIN, 7 - RIGHTMARGIN, 412 + RIGHTMARGIN, 540 TOPMARGIN, 7 - BOTTOMMARGIN, 216 + BOTTOMMARGIN, 328 END END #endif // APSTUDIO_INVOKED Index: src/ictranslate/ictranslate.vc90.vcproj =================================================================== diff -u -r50fea83cc4ee863edac0fd3960e2249f99c33b03 -r2ffaff594233ce671e00b842c718cca32f9498c5 --- src/ictranslate/ictranslate.vc90.vcproj (.../ictranslate.vc90.vcproj) (revision 50fea83cc4ee863edac0fd3960e2249f99c33b03) +++ src/ictranslate/ictranslate.vc90.vcproj (.../ictranslate.vc90.vcproj) (revision 2ffaff594233ce671e00b842c718cca32f9498c5) @@ -49,7 +49,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/analyze" Optimization="0" - PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG" + PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG;_CRT_SECURE_NO_DEPRECATE" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -128,7 +128,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/analyze" Optimization="0" - PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG" + PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG;_CRT_SECURE_NO_DEPRECATE" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -208,7 +208,7 @@ Name="VCCLCompilerTool" Optimization="2" EnableIntrinsicFunctions="true" - PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG" + PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_CRT_SECURE_NO_DEPRECATE" MinimalRebuild="false" RuntimeLibrary="2" EnableFunctionLevelLinking="true" @@ -290,7 +290,7 @@ Name="VCCLCompilerTool" Optimization="2" EnableIntrinsicFunctions="true" - PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG" + PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_CRT_SECURE_NO_DEPRECATE" MinimalRebuild="false" RuntimeLibrary="2" EnableFunctionLevelLinking="true" @@ -427,6 +427,22 @@ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" > + + + + + + + + Index: src/ictranslate/res/icon_invalid.ico =================================================================== diff -u Binary files differ Index: src/ictranslate/res/icon_nonexistent.ico =================================================================== diff -u Binary files differ Index: src/ictranslate/res/icon_overfluous.ico =================================================================== diff -u Binary files differ Index: src/ictranslate/res/icon_valid.ico =================================================================== diff -u Binary files differ Index: src/ictranslate/resource.h =================================================================== diff -u -r50fea83cc4ee863edac0fd3960e2249f99c33b03 -r2ffaff594233ce671e00b842c718cca32f9498c5 --- src/ictranslate/resource.h (.../resource.h) (revision 50fea83cc4ee863edac0fd3960e2249f99c33b03) +++ src/ictranslate/resource.h (.../resource.h) (revision 2ffaff594233ce671e00b842c718cca32f9498c5) @@ -8,24 +8,45 @@ #define IDD_ICTRANSLATE_DIALOG 102 #define IDR_MAINFRAME 128 #define IDR_MAIN_MENU 129 +#define IDI_NONEXISTENT_ICON 130 +#define IDI_VALID_ICON 131 +#define IDI_INVALID_ICON 132 +#define IDI_OVERFLUOUS_ICON 133 #define IDC_DSTDATA_LIST 1000 #define IDC_SRCDATA_LIST 1001 #define IDC_SRCDATA_EDIT 1002 #define IDC_DSTDATA_EDIT 1003 +#define IDAPPLY 1010 +#define IDC_COPY_BUTTON 1012 +#define IDC_SRC_AUTHOR_EDIT 1013 +#define IDC_SRC_RTL_CHECK 1014 +#define IDC_SRC_FILENAME_EDIT 1015 +#define IDC_SRC_LANGUAGE_NAME_EDIT 1016 +#define IDC_SRC_FONT_EDIT 1017 +#define IDC_SRC_HELP_FILENAME_EDIT 1018 +#define IDC_DST_AUTHOR_EDIT 1019 +#define IDC_DST_RTL_CHECK 1020 +#define IDC_DST_FILENAME_EDIT 1021 +#define IDC_DST_LANGUAGE_NAME_EDIT 1022 +#define IDC_DST_FONT_EDIT 1023 +#define IDC_DST_HELP_FILENAME_EDIT 1024 +#define IDC_CHOOSE_FONT_BUTTON 1025 #define ID_FILE_NEWTRANSLATION 32771 #define ID_FILE_OPENTRANSLATION 32772 #define ID_FILE_SAVETRANSLATION 32773 #define ID_FILE_SAVETRANSLATIONAS 32774 #define ID_FILE_OPENYOURTRANSLATION 32775 #define ID_FILE_OPENBASETRANSLATION 32776 +#define ID_EDIT_CLEANUPTRANSLATION 32777 +#define ID_EDIT_CLEANUP_TRANSLATION 32778 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 130 -#define _APS_NEXT_COMMAND_VALUE 32777 -#define _APS_NEXT_CONTROL_VALUE 1010 +#define _APS_NEXT_RESOURCE_VALUE 134 +#define _APS_NEXT_COMMAND_VALUE 32779 +#define _APS_NEXT_CONTROL_VALUE 1026 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif Index: src/libictranslate/ResourceManager.cpp =================================================================== diff -u -r50fea83cc4ee863edac0fd3960e2249f99c33b03 -r2ffaff594233ce671e00b842c718cca32f9498c5 --- src/libictranslate/ResourceManager.cpp (.../ResourceManager.cpp) (revision 50fea83cc4ee863edac0fd3960e2249f99c33b03) +++ src/libictranslate/ResourceManager.cpp (.../ResourceManager.cpp) (revision 2ffaff594233ce671e00b842c718cca32f9498c5) @@ -154,10 +154,15 @@ m_pszLngName(NULL), m_pszBaseFile(NULL), m_pszFontFace(NULL), + m_wLangCode(0), + m_wPointSize(0), m_pszHelpName(NULL), m_pszAuthor(NULL), m_pszVersion(NULL), - m_uiSectionID(0) + m_byCharset(0), + m_bRTL(false), + m_uiSectionID(0), + m_bUpdating(false) { } @@ -513,6 +518,44 @@ } } +CTranslationItem* CLangData::GetTranslationItem(uint_t uiTranslationKey, bool bCreate) +{ + translation_map::iterator iterTranslation = m_mapTranslation.find(uiTranslationKey); + if(iterTranslation != m_mapTranslation.end()) + return &(*iterTranslation).second; + else + { + if(bCreate) + { + std::pair pairTranslation = m_mapTranslation.insert(std::make_pair(uiTranslationKey, CTranslationItem())); + if(pairTranslation.second) + return &(*pairTranslation.first).second; + } + } + + return NULL; +} + +bool CLangData::Exists(uint_t uiTranslationKey) const +{ + return m_mapTranslation.find(uiTranslationKey) != m_mapTranslation.end(); +} + +// removes strings that does not exist in the reference translation +void CLangData::CleanupTranslation(const CLangData& rReferenceTranslation) +{ + translation_map::iterator iterTranslation = m_mapTranslation.begin(); + while(iterTranslation != m_mapTranslation.end()) + { + if(!rReferenceTranslation.Exists((*iterTranslation).first)) + { + m_mapTranslation.erase(iterTranslation++); + } + else + ++iterTranslation; + } +} + void CLangData::SetFilename(PCTSTR psz) { if (m_pszFilename) Index: src/libictranslate/ResourceManager.h =================================================================== diff -u -r50fea83cc4ee863edac0fd3960e2249f99c33b03 -r2ffaff594233ce671e00b842c718cca32f9498c5 --- src/libictranslate/ResourceManager.h (.../ResourceManager.h) (revision 50fea83cc4ee863edac0fd3960e2249f99c33b03) +++ src/libictranslate/ResourceManager.h (.../ResourceManager.h) (revision 2ffaff594233ce671e00b842c718cca32f9498c5) @@ -41,7 +41,7 @@ /////////////////////////////////////////////////////////// // language description structure -class CTranslationItem +class LIBICTRANSLATE_API CTranslationItem { public: CTranslationItem(); @@ -84,9 +84,13 @@ bool ReadInfo(PCTSTR pszFile); bool ReadTranslation(PCTSTR pszFile, bool bReadBase = false); - PCTSTR GetString(WORD wHiID, WORD wLoID); +// translation retrieving/setting + const tchar_t* GetString(WORD wHiID, WORD wLoID); // retrieves string using group id and string id + void EnumStrings(PFNENUMCALLBACK pfnCallback, ptr_t pData); // retrieves all translation items - void EnumStrings(PFNENUMCALLBACK pfnCallback, ptr_t pData); + CTranslationItem* GetTranslationItem(uint_t uiTranslationKey, bool bCreate); // retrieves pointer to the single translation item + bool Exists(uint_t uiTranslationKey) const; + void CleanupTranslation(const CLangData& rReferenceTranslation); // attributes void SetFilename(PCTSTR psz);