Index: src/ictranslate/ICTranslateDlg.cpp =================================================================== diff -u -raa9c75acee79827e5a305ab76af0b121fcbf860d -rf6fe924675e9de6120b6c1eac2430fa5b2946251 --- src/ictranslate/ICTranslateDlg.cpp (.../ICTranslateDlg.cpp) (revision aa9c75acee79827e5a305ab76af0b121fcbf860d) +++ src/ictranslate/ICTranslateDlg.cpp (.../ICTranslateDlg.cpp) (revision f6fe924675e9de6120b6c1eac2430fa5b2946251) @@ -15,6 +15,7 @@ #define IMAGE_NONEXISTENT 1 #define IMAGE_OVERFLUOUS 2 #define IMAGE_VALID 3 +#define IMAGE_WARNING 4 // CAboutDlg dialog used for App About @@ -136,6 +137,7 @@ 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_ilImages.Add(AfxGetApp()->LoadIcon(IDI_WARNING_ICON)); m_ctlCustomLanguageList.SetImageList(&m_ilImages, LVSIL_SMALL); @@ -462,10 +464,22 @@ { if(pBaseItem) { - if(pCustomItem->GetChecksum() != pBaseItem->GetChecksum()) - lvi.iImage = IMAGE_INVALID; - else + ictranslate::CTranslationItem::ECompareResult eResult = pCustomItem->Compare(*pBaseItem); + switch(eResult) + { + case ictranslate::CTranslationItem::eResult_Valid: lvi.iImage = IMAGE_VALID; + break; + case ictranslate::CTranslationItem::eResult_Invalid: + lvi.iImage = IMAGE_INVALID; + break; + case ictranslate::CTranslationItem::eResult_ContentWarning: + lvi.iImage = IMAGE_WARNING; + break; + default: + assert(false); + lvi.iImage = IMAGE_INVALID; + } } else lvi.iImage = IMAGE_OVERFLUOUS; Index: src/ictranslate/ictranslate.rc =================================================================== diff -u -r5f47ed98830ad078df4e4b685af13c86a6213678 -rf6fe924675e9de6120b6c1eac2430fa5b2946251 --- src/ictranslate/ictranslate.rc (.../ictranslate.rc) (revision 5f47ed98830ad078df4e4b685af13c86a6213678) +++ src/ictranslate/ictranslate.rc (.../ictranslate.rc) (revision f6fe924675e9de6120b6c1eac2430fa5b2946251) @@ -75,6 +75,7 @@ IDI_VALID_ICON ICON "res\\icon_valid.ico" IDI_INVALID_ICON ICON "res\\icon_invalid.ico" IDI_OVERFLUOUS_ICON ICON "res\\icon_overfluous.ico" +IDI_WARNING_ICON ICON "res\\icon_warning.ico" ///////////////////////////////////////////////////////////////////////////// // Index: src/ictranslate/ictranslate.vc90.vcproj =================================================================== diff -u -r2ffaff594233ce671e00b842c718cca32f9498c5 -rf6fe924675e9de6120b6c1eac2430fa5b2946251 --- src/ictranslate/ictranslate.vc90.vcproj (.../ictranslate.vc90.vcproj) (revision 2ffaff594233ce671e00b842c718cca32f9498c5) +++ src/ictranslate/ictranslate.vc90.vcproj (.../ictranslate.vc90.vcproj) (revision f6fe924675e9de6120b6c1eac2430fa5b2946251) @@ -427,6 +427,10 @@ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" > + + @@ -443,6 +447,10 @@ > + + Index: src/ictranslate/res/icon_warning.ico =================================================================== diff -u Binary files differ Index: src/ictranslate/resource.h =================================================================== diff -u -r2ffaff594233ce671e00b842c718cca32f9498c5 -rf6fe924675e9de6120b6c1eac2430fa5b2946251 --- src/ictranslate/resource.h (.../resource.h) (revision 2ffaff594233ce671e00b842c718cca32f9498c5) +++ src/ictranslate/resource.h (.../resource.h) (revision f6fe924675e9de6120b6c1eac2430fa5b2946251) @@ -12,6 +12,7 @@ #define IDI_VALID_ICON 131 #define IDI_INVALID_ICON 132 #define IDI_OVERFLUOUS_ICON 133 +#define IDI_WARNING_ICON 134 #define IDC_DSTDATA_LIST 1000 #define IDC_SRCDATA_LIST 1001 #define IDC_SRCDATA_EDIT 1002 @@ -44,7 +45,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 134 +#define _APS_NEXT_RESOURCE_VALUE 135 #define _APS_NEXT_COMMAND_VALUE 32779 #define _APS_NEXT_CONTROL_VALUE 1026 #define _APS_NEXT_SYMED_VALUE 101 Index: src/libictranslate/ResourceManager.cpp =================================================================== diff -u -rc72f797f7e7795e3ff15dc2ed832032ee6bafd0a -rf6fe924675e9de6120b6c1eac2430fa5b2946251 --- src/libictranslate/ResourceManager.cpp (.../ResourceManager.cpp) (revision c72f797f7e7795e3ff15dc2ed832032ee6bafd0a) +++ src/libictranslate/ResourceManager.cpp (.../ResourceManager.cpp) (revision f6fe924675e9de6120b6c1eac2430fa5b2946251) @@ -150,6 +150,62 @@ *pszOut = _T('\0'); } +CTranslationItem::ECompareResult CTranslationItem::Compare(const CTranslationItem& rReferenceItem) +{ + if(!m_pszText || !rReferenceItem.m_pszText) + return eResult_Invalid; + + if(rReferenceItem.m_uiChecksum != rReferenceItem.m_uiChecksum) + return eResult_Invalid; + + // space check + if(rReferenceItem.m_pszText[0] == _t(' ') && m_pszText[0] != _t(' ')) + return eResult_ContentWarning; + + size_t stReferenceLen = _tcslen(rReferenceItem.m_pszText); + size_t stOwnLen = _tcslen(m_pszText); + if(stReferenceLen > 0 && stOwnLen > 0 && rReferenceItem.m_pszText[stReferenceLen - 1] == _t(' ') && m_pszText[stOwnLen - 1] != _t(' ')) + return eResult_ContentWarning; + + // formatting strings check + tstring_t strRefFmt; + const tchar_t* pszData = rReferenceItem.m_pszText; + while((pszData = _tcschr(pszData, _t('%'))) != NULL) + { + pszData++; // it works assuming the string is null-terminated + switch(*pszData) + { + case _t('%'): + pszData++; + break; // it's a %% - skip it + default: + strRefFmt += *pszData; + } + } + + tstring_t strOwnFmt; + pszData = m_pszText; + while((pszData = _tcschr(pszData, _t('%'))) != NULL) + { + pszData++; // it works assuming the string is null-terminated + if(*pszData) + { + switch(*pszData) + { + case _t('%'): + pszData++; + break; // it's a %% - skip it + default: + strOwnFmt += *pszData; + } + } + } + if(strRefFmt != strOwnFmt) + return eResult_ContentWarning; + + return eResult_Valid; +} + CLangData::CLangData() : m_pszFilename(NULL), m_pszLngName(NULL), Index: src/libictranslate/ResourceManager.h =================================================================== diff -u -r1329b4d4f99ceb1f91f7feb915d58434721f4da7 -rf6fe924675e9de6120b6c1eac2430fa5b2946251 --- src/libictranslate/ResourceManager.h (.../ResourceManager.h) (revision 1329b4d4f99ceb1f91f7feb915d58434721f4da7) +++ src/libictranslate/ResourceManager.h (.../ResourceManager.h) (revision f6fe924675e9de6120b6c1eac2430fa5b2946251) @@ -44,6 +44,13 @@ class LIBICTRANSLATE_API CTranslationItem { public: + enum ECompareResult + { + eResult_Valid, // valid translation + eResult_Invalid, // Invalid checksum or translation + eResult_ContentWarning // the translation is suspicious + }; +public: CTranslationItem(); CTranslationItem(const tchar_t* pszText, uint_t uiChecksum); ~CTranslationItem(); @@ -60,6 +67,8 @@ void UnescapeString(); + ECompareResult Compare(const CTranslationItem& rReferenceItem); + protected: tchar_t* m_pszText; size_t m_stTextLength;