Index: src/ictranslate/ICTranslateDlg.cpp
===================================================================
diff -u -r03683cd01b2390903a45d475268d8af03004eff0 -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/ictranslate/ICTranslateDlg.cpp	(.../ICTranslateDlg.cpp)	(revision 03683cd01b2390903a45d475268d8af03004eff0)
+++ src/ictranslate/ICTranslateDlg.cpp	(.../ICTranslateDlg.cpp)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,914 +1,914 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-// ICTranslateDlg.cpp : implementation file
-//
-
-#include "stdafx.h"
-#include "ictranslate.h"
-#include "ICTranslateDlg.h"
-#include <assert.h>
-#include <set>
-#include "../libicpf/exception.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
-#define IMAGE_INVALID 0
-#define IMAGE_NONEXISTENT 1
-#define IMAGE_OVERFLUOUS 2
-#define IMAGE_VALID 3
-#define IMAGE_WARNING 4
-
-// CAboutDlg dialog used for App About
-
-class CAboutDlg : public CDialog
-{
-public:
-	CAboutDlg();
-
-// Dialog Data
-	enum { IDD = IDD_ABOUTBOX };
-
-	protected:
-	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
-
-// Implementation
-protected:
-	DECLARE_MESSAGE_MAP()
-};
-
-CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
-{
-}
-
-void CAboutDlg::DoDataExchange(CDataExchange* pDX)
-{
-	CDialog::DoDataExchange(pDX);
-}
-
-BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
-END_MESSAGE_MAP()
-
-
-// CICTranslateDlg dialog
-
-
-
-
-CICTranslateDlg::CICTranslateDlg(CWnd* pParent /*=NULL*/)
-	: CDialog(CICTranslateDlg::IDD, pParent),
-	m_hAccel(NULL)
-{
-	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
-}
-
-void CICTranslateDlg::DoDataExchange(CDataExchange* pDX)
-{
-	CDialog::DoDataExchange(pDX);
-	DDX_Control(pDX, IDC_SRCDATA_LIST, m_ctlBaseLanguageList);
-	DDX_Control(pDX, IDC_DSTDATA_LIST, m_ctlCustomLanguageList);
-	DDX_Control(pDX, IDC_SRCDATA_RICHEDIT, m_ctlSrcText);
-	DDX_Control(pDX, IDC_DSTDATA_RICHEDIT, 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)
-	ON_WM_SYSCOMMAND()
-	ON_WM_PAINT()
-	ON_WM_QUERYDRAGICON()
-	//}}AFX_MSG_MAP
-	ON_COMMAND(ID_FILE_OPENBASETRANSLATION, &CICTranslateDlg::OnFileOpenBaseTranslation)
-	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)
-	ON_COMMAND(ID_FILE_NEWTRANSLATION, &CICTranslateDlg::OnFileNewTranslation)
-	ON_COMMAND(ID_FILE_SAVETRANSLATIONAS, &CICTranslateDlg::OnFileSaveTranslationAs)
-	ON_COMMAND(ID_FILE_SAVETRANSLATION, &CICTranslateDlg::OnFileSaveTranslation)
-	ON_EN_KILLFOCUS(IDC_DST_AUTHOR_EDIT, &CICTranslateDlg::OnEnKillFocusDstAuthorEdit)
-	ON_EN_KILLFOCUS(IDC_DST_LANGUAGE_NAME_EDIT, &CICTranslateDlg::OnEnKillFocusDstLanguageNameEdit)
-	ON_EN_KILLFOCUS(IDC_DST_HELP_FILENAME_EDIT, &CICTranslateDlg::OnEnKillFocusDstHelpFilenameEdit)
-	ON_BN_CLICKED(IDC_DST_RTL_CHECK, &CICTranslateDlg::OnBnClickedDstRtlCheck)
-	ON_COMMAND(ID_EDIT_PREVIOUS_TO_TRANSLATE, &CICTranslateDlg::OnEditPreviousToTranslate)
-	ON_COMMAND(ID_EDIT_NEXT_TO_TRANSLATE, &CICTranslateDlg::OnEditNextToTranslate)
-	ON_COMMAND(ID_EDIT_APPLY_CHANGE, &CICTranslateDlg::OnEditApplyChange)
-	ON_COMMAND(ID_EDIT_APPLY_AND_NEXT, &CICTranslateDlg::OnEditApplyAndNext)
-END_MESSAGE_MAP()
-
-
-// CICTranslateDlg message handlers
-
-BOOL CICTranslateDlg::OnInitDialog()
-{
-	CDialog::OnInitDialog();
-
-	// Add "About..." menu item to system menu.
-
-	// IDM_ABOUTBOX must be in the system command range.
-	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
-	ASSERT(IDM_ABOUTBOX < 0xF000);
-
-	CMenu* pSysMenu = GetSystemMenu(FALSE);
-	if (pSysMenu != NULL)
-	{
-		CString strAboutMenu;
-		if(strAboutMenu.LoadString(IDS_ABOUTBOX))
-		{
-			pSysMenu->AppendMenu(MF_SEPARATOR);
-			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
-		}
-	}
-
-	// Set the icon for this dialog.  The framework does this automatically
-	//  when the application's main window is not a dialog
-	SetIcon(m_hIcon, TRUE);			// Set big icon
-	SetIcon(m_hIcon, FALSE);		// Set small icon
-
-	// use image list
-	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_ilImages.Add(AfxGetApp()->LoadIcon(IDI_WARNING_ICON));
-
-	m_ctlCustomLanguageList.SetImageList(&m_ilImages, LVSIL_SMALL);
-
-	// full row selection
-	m_ctlBaseLanguageList.SetExtendedStyle(LVS_EX_FULLROWSELECT);
-	m_ctlCustomLanguageList.SetExtendedStyle(LVS_EX_FULLROWSELECT);
-
-	// setup the lists' headers
-	// first the width of list (assuming both have the same width)
-	CRect rcList;
-	m_ctlBaseLanguageList.GetWindowRect(&rcList);
-	uint_t uiWidth = rcList.Width();
-
-	LVCOLUMN lvc;
-	lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
-	lvc.fmt = LVCFMT_LEFT;
-	lvc.cx = uiWidth / 5;
-	lvc.pszText = _T("ID");
-
-	m_ctlBaseLanguageList.InsertColumn(0, &lvc);
-	m_ctlCustomLanguageList.InsertColumn(0, &lvc);
-
-	lvc.cx = 4 * uiWidth / 5;
-	lvc.pszText = _T("Text");
-
-	m_ctlBaseLanguageList.InsertColumn(1, &lvc);
-	m_ctlCustomLanguageList.InsertColumn(1, &lvc);
-
-	m_hAccel = LoadAccelerators(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_ACCELERATOR));
-
-	// load the languages specified on the command line
-	PCTSTR pszCmdLine = AfxGetApp()->m_lpCmdLine;
-	if(pszCmdLine && pszCmdLine[0] != _T('\0'))
-	{
-		int iCount = 0;
-		PWSTR* pszArgs = CommandLineToArgvW(pszCmdLine, &iCount);
-
-		if(iCount > 0)
-		{
-			if(!m_ldBase.ReadTranslation(pszArgs[0]))
-			{
-				AfxMessageBox(_T("Reading base translation file failed"));
-				LocalFree(pszArgs);
-				return TRUE;
-			}
-
-			UpdateBaseLanguageList();
-			UpdateCustomLanguageList();
-		}
-		if(iCount > 1)
-		{
-			if(!m_ldCustom.ReadTranslation(pszArgs[1]))
-			{
-				AfxMessageBox(_T("Reading your language file failed"));
-				LocalFree(pszArgs);
-				return TRUE;
-			}
-
-			UpdateCustomLanguageList();
-		}
-
-		LocalFree(pszArgs);
-	}
-
-	return TRUE;  // return TRUE  unless you set the focus to a control
-}
-
-void CICTranslateDlg::OnSysCommand(UINT nID, LPARAM lParam)
-{
-	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
-	{
-		CAboutDlg dlgAbout;
-		dlgAbout.DoModal();
-	}
-	else
-	{
-		CDialog::OnSysCommand(nID, lParam);
-	}
-}
-
-// If you add a minimize button to your dialog, you will need the code below
-//  to draw the icon.  For MFC applications using the document/view model,
-//  this is automatically done for you by the framework.
-
-void CICTranslateDlg::OnPaint()
-{
-	if (IsIconic())
-	{
-		CPaintDC dc(this); // device context for painting
-
-		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
-
-		// Center icon in client rectangle
-		int cxIcon = GetSystemMetrics(SM_CXICON);
-		int cyIcon = GetSystemMetrics(SM_CYICON);
-		CRect rect;
-		GetClientRect(&rect);
-		int x = (rect.Width() - cxIcon + 1) / 2;
-		int y = (rect.Height() - cyIcon + 1) / 2;
-
-		// Draw the icon
-		dc.DrawIcon(x, y, m_hIcon);
-	}
-	else
-	{
-		CDialog::OnPaint();
-	}
-}
-
-// The system calls this function to obtain the cursor to display while the user drags
-//  the minimized window.
-HCURSOR CICTranslateDlg::OnQueryDragIcon()
-{
-	return static_cast<HCURSOR>(m_hIcon);
-}
-
-void CICTranslateDlg::OnFileOpenBaseTranslation()
-{
-	CFileDialog fd(TRUE, _T(".lng"), _T(""), OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST, _T("Language files (*.lng)|*.lng|All files(*.*)|*.*||"), this);
-	if(fd.DoModal() == IDOK)
-	{
-		if(!m_ldBase.ReadTranslation(fd.GetPathName()))
-		{
-			AfxMessageBox(_T("Reading file failed"));
-			return;
-		}
-
-		UpdateBaseLanguageList();
-		UpdateCustomLanguageList();
-	}
-}
-
-void CICTranslateDlg::OnFileOpenYourTranslation()
-{
-	// check for modification flag
-	if(!WarnModified())
-		return;
-
-	CFileDialog fd(TRUE, _T(".lng"), _T(""), OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST, _T("Language files (*.lng)|*.lng|All files(*.*)|*.*||"), this);
-	if(fd.DoModal() == IDOK)
-	{
-		if(!m_ldCustom.ReadTranslation(fd.GetPathName()))
-		{
-			AfxMessageBox(_T("Reading file failed"));
-			return;
-		}
-
-		UpdateCustomLanguageList();
-	}
-}
-
-void CICTranslateDlg::EnumLngStrings(uint_t uiID, const ictranslate::CTranslationItem* pTranslationItem, ptr_t pData)
-{
-	CListCtrl* pList = (CListCtrl*)pData;
-	assert(pTranslationItem);
-	if(!pTranslationItem)
-		return;
-	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;
-	
-	pList->InsertItem(&lvi);
-
-	lvi.mask = LVIF_TEXT;
-	lvi.pszText = (PTSTR)pTranslationItem->GetText();
-	lvi.iItem = 0;
-	lvi.iSubItem = 1;
-
-	pList->SetItem(&lvi);
-}
-
-void CICTranslateDlg::OnItemChangedSrcDataList(NMHDR *pNMHDR, LRESULT *pResult)
-{
-	LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
-	*pResult = 0;
-
-	if(pNMLV->uNewState & LVIS_SELECTED)
-	{
-		// set the text to the edit box
-		ictranslate::CTranslationItem* pTranslationItem = m_ldBase.GetTranslationItem(pNMLV->lParam, false);
-		if(pTranslationItem && pTranslationItem->GetText())
-			m_ctlSrcText.SetWindowText(pTranslationItem->GetText());
-		else
-			m_ctlSrcText.SetWindowText(m_ctlBaseLanguageList.GetItemText(pNMLV->iItem, 1));
-
-		uint_t uiID = pNMLV->lParam;
-
-		// to avoid infinite loop of selections, check if the current selection is already valid
-		POSITION pos = m_ctlCustomLanguageList.GetFirstSelectedItemPosition();
-		if(pos)
-		{
-			int iPos = m_ctlCustomLanguageList.GetNextSelectedItem(pos);
-			uint_t uiCurrentID = m_ctlCustomLanguageList.GetItemData(iPos);
-			if(uiID == uiCurrentID)
-				return;
-		}
-//		m_ctlCustomLanguageList.SetItemState(-1, 0, LVIS_SELECTED);
-
-		// search in the second list for the specified id
-		int iCount = m_ctlCustomLanguageList.GetItemCount();
-		for(int i = 0; i < iCount; i++)
-		{
-			uint_t uiCustomID = m_ctlCustomLanguageList.GetItemData(i);
-			if(uiCustomID == uiID)
-			{
-				m_ctlCustomLanguageList.EnsureVisible(i, FALSE);
-				m_ctlCustomLanguageList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
-				break;
-			}
-		}
-	}
-	else if(pNMLV->uOldState & LVIS_SELECTED)
-	{
-		m_ctlCustomLanguageList.SetItemState(-1, 0, LVIS_SELECTED);
-		m_ctlDstText.SetWindowText(_T(""));
-	}
-}
-
-void CICTranslateDlg::OnItemChangedDstDataList(NMHDR *pNMHDR, LRESULT *pResult)
-{
-	LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
-	*pResult = 0;
-
-	if(pNMLV->uNewState & LVIS_SELECTED)
-	{
-		// set the text to the edit box
-		ictranslate::CTranslationItem* pTranslationItem = m_ldCustom.GetTranslationItem(pNMLV->lParam, false);
-		if(pTranslationItem && pTranslationItem->GetText())
-			m_ctlDstText.SetWindowText(pTranslationItem->GetText());
-		else
-			m_ctlDstText.SetWindowText(m_ctlCustomLanguageList.GetItemText(pNMLV->iItem, 1));
-
-		uint_t uiID = pNMLV->lParam;
-
-		// to avoid infinite loop of selections, check if the current selection is already valid
-		POSITION pos = m_ctlBaseLanguageList.GetFirstSelectedItemPosition();
-		if(pos)
-		{
-			int iPos = m_ctlBaseLanguageList.GetNextSelectedItem(pos);
-			uint_t uiCurrentID = m_ctlBaseLanguageList.GetItemData(iPos);
-			if(uiID == uiCurrentID)
-				return;
-		}
-
-		// search in the second list for the specified id
-		int iCount = m_ctlBaseLanguageList.GetItemCount();
-		for(int i = 0; i < iCount; i++)
-		{
-			uint_t uiCustomID = m_ctlBaseLanguageList.GetItemData(i);
-			if(uiCustomID == uiID)
-			{
-				m_ctlBaseLanguageList.EnsureVisible(i, FALSE);
-				m_ctlBaseLanguageList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
-				break;
-			}
-		}
-	}
-	else if(pNMLV->uOldState & LVIS_SELECTED)
-	{
-		m_ctlBaseLanguageList.SetItemState(-1, 0, LVIS_SELECTED);
-		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();
-}
-
-// updated the custom language list - bFullUpdate means re-reading also language information (default)
-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<uint_t> 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)
-		{
-			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;
-	}
-	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, false);
-		pCustomItem->SetChecksum(pBaseItem->GetChecksum());
-		m_ldCustom.SetModified();
-	}
-
-	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() == IDOK)
-	{
-		// 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();
-}
-
-void CICTranslateDlg::OnFileNewTranslation()
-{
-	// check for modification flag
-	if(!WarnModified())
-		return;
-
-	// clear the custom translation
-	m_ldCustom.Clear();
-	UpdateCustomLanguageList();
-}
-
-void CICTranslateDlg::OnFileSaveTranslationAs()
-{
-	if(!m_ldCustom.IsValidDescription())
-	{
-		AfxMessageBox(_T("Please fill the Author, Language name and font with correct values before saving."));
-		return;
-	}
-
-	CString strFilename = m_ldCustom.GetFilename(false);
-	CString strPath = m_ldCustom.GetFilename(true);
-	
-	CFileDialog dlg(FALSE, _T(".lng"), strFilename, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("Language files (*.lng)|*.lng|All files (*.*)|*.*||"), this);
-	if(dlg.DoModal() == IDOK)
-	{
-		// store additional informations from the dialog box
-		CString str;
-		m_ctlDstAuthor.GetWindowText(str);
-		m_ldCustom.SetAuthor(str);
-		m_ctlDstLanguageName.GetWindowText(str);
-		m_ldCustom.SetLangName(str);
-		m_ctlDstHelpFilename.GetWindowText(str);
-		m_ldCustom.SetHelpName(str);
-		bool bRTL = (m_ctlDstRTL.GetCheck() == BST_CHECKED);
-		m_ldCustom.SetDirection(bRTL);
-
-		// store translation with new name
-		try
-		{
-			m_ldCustom.WriteTranslation(dlg.GetPathName());
-		}
-		catch(icpf::exception& e)
-		{
-			CString strInfo;
-			strInfo.Format(_T("Cannot write translation file.\nReason: %s"), e.get_desc());
-			AfxMessageBox(strInfo);
-			return;
-		}
-		m_ctlDstFilename.SetWindowText(m_ldCustom.GetFilename(true));
-	}
-}
-
-void CICTranslateDlg::OnFileSaveTranslation()
-{
-	// sanity checks
-	if(!m_ldCustom.IsValidDescription())
-	{
-		AfxMessageBox(_T("Please fill the Author, Language name and font with correct values before saving."));
-		return;
-	}
-
-	CString strPath = m_ldCustom.GetFilename(true);
-	if(strPath.IsEmpty())
-	{
-		OnFileSaveTranslationAs();
-	}
-	else
-	{
-		// store additional informations from the dialog box
-		CString str;
-		m_ctlDstAuthor.GetWindowText(str);
-		m_ldCustom.SetAuthor(str);
-		m_ctlDstLanguageName.GetWindowText(str);
-		m_ldCustom.SetLangName(str);
-		m_ctlDstHelpFilename.GetWindowText(str);
-		m_ldCustom.SetHelpName(str);
-		bool bRTL = (m_ctlDstRTL.GetCheck() == BST_CHECKED);
-		m_ldCustom.SetDirection(bRTL);
-
-		try
-		{
-			m_ldCustom.WriteTranslation(NULL);
-		}
-		catch(icpf::exception& e)
-		{
-			CString strInfo;
-			strInfo.Format(_T("Cannot write translation file.\nReason: %s"), e.get_desc());
-			AfxMessageBox(strInfo);
-			return;
-		}
-		m_ctlDstFilename.SetWindowText(m_ldCustom.GetFilename(true));
-	}
-}
-
-bool CICTranslateDlg::WarnModified() const
-{
-	// check the modification flag
-	if(m_ldCustom.IsModified())
-	{
-		int iRes = AfxMessageBox(_T("You have modified the translation file. If you continue, the changes might be lost. Do you want to continue ?"), MB_YESNO | MB_ICONQUESTION);
-		return iRes == IDYES;
-	}
-	else
-		return true;
-}
-
-void CICTranslateDlg::OnCancel()
-{
-	if(WarnModified())
-		CDialog::OnCancel();
-}
-
-void CICTranslateDlg::OnEnKillFocusDstAuthorEdit()
-{
-	CString str;
-	m_ctlDstAuthor.GetWindowText(str);
-	const tchar_t* psz = m_ldCustom.GetAuthor();
-	if(!psz || psz != str)
-		m_ldCustom.SetAuthor(str);
-}
-
-void CICTranslateDlg::OnEnKillFocusDstLanguageNameEdit()
-{
-	CString str;
-	m_ctlDstLanguageName.GetWindowText(str);
-	const tchar_t* psz = m_ldCustom.GetLangName();
-	if(!psz || psz != str)
-		m_ldCustom.SetLangName(str);
-}
-
-void CICTranslateDlg::OnEnKillFocusDstHelpFilenameEdit()
-{
-	CString str;
-	m_ctlDstHelpFilename.GetWindowText(str);
-	const tchar_t* psz = m_ldCustom.GetHelpName();
-	if(!psz || psz != str)
-		m_ldCustom.SetHelpName(str);
-}
-
-void CICTranslateDlg::OnBnClickedDstRtlCheck()
-{
-	bool bRTL = (m_ctlDstRTL.GetCheck() == BST_CHECKED);
-	m_ldCustom.SetDirection(bRTL);
-}
-
-void CICTranslateDlg::OnEditPreviousToTranslate()
-{
-	// find selection
-	int iItem = 0;
-	POSITION pos = m_ctlCustomLanguageList.GetFirstSelectedItemPosition();
-	if(pos)
-		iItem = m_ctlCustomLanguageList.GetNextSelectedItem(pos);
-
-	// find previous element to translate
-	LVITEM lvi;
-	for(int i = iItem - 1; i >= 0; i--)
-	{
-		lvi.iItem = i;
-		lvi.iSubItem = 0;
-		lvi.mask = LVIF_IMAGE;
-
-		BOOL bRes = m_ctlCustomLanguageList.GetItem(&lvi);
-		if(bRes && lvi.iImage != IMAGE_OVERFLUOUS && lvi.iImage != IMAGE_VALID)
-		{
-			m_ctlDstText.SetWindowText(_T(""));
-			m_ctlCustomLanguageList.SetItemState(i, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
-			m_ctlCustomLanguageList.EnsureVisible(i, FALSE);
-			m_ctlDstText.SetFocus();
-			break;
-		}
-	}
-}
-
-void CICTranslateDlg::OnEditNextToTranslate()
-{
-	// find selection
-	int iItem = 0;
-	POSITION pos = m_ctlCustomLanguageList.GetFirstSelectedItemPosition();
-	if(pos)
-		iItem = m_ctlCustomLanguageList.GetNextSelectedItem(pos);
-
-	// find previous element to translate
-	LVITEM lvi;
-	int iCount = m_ctlCustomLanguageList.GetItemCount();
-	for(int i = iItem + 1; i < iCount; i++)
-	{
-		lvi.iItem = i;
-		lvi.iSubItem = 0;
-		lvi.mask = LVIF_IMAGE;
-
-		BOOL bRes = m_ctlCustomLanguageList.GetItem(&lvi);
-		if(bRes && lvi.iImage != IMAGE_OVERFLUOUS && lvi.iImage != IMAGE_VALID)
-		{
-			m_ctlDstText.SetWindowText(_T(""));
-			m_ctlCustomLanguageList.SetItemState(i, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
-			m_ctlCustomLanguageList.EnsureVisible(i, FALSE);
-			m_ctlDstText.SetFocus();
-			break;
-		}
-	}
-}
-
-void CICTranslateDlg::OnEditApplyChange()
-{
-	// apply change
-	OnBnClickedApply();
-}
-
-void CICTranslateDlg::OnEditApplyAndNext()
-{
-	OnBnClickedApply();
-	OnEditNextToTranslate();
-}
-
-BOOL CICTranslateDlg::PreTranslateMessage(MSG* pMsg)
-{
-	if(m_hAccel)
-	{
-		if(TranslateAccelerator(m_hWnd, m_hAccel, pMsg) != 0)
-			return TRUE;
-	}
-
-	return CDialog::PreTranslateMessage(pMsg);
-}
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+// ICTranslateDlg.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "ictranslate.h"
+#include "ICTranslateDlg.h"
+#include <assert.h>
+#include <set>
+#include "../libicpf/exception.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+#define IMAGE_INVALID 0
+#define IMAGE_NONEXISTENT 1
+#define IMAGE_OVERFLUOUS 2
+#define IMAGE_VALID 3
+#define IMAGE_WARNING 4
+
+// CAboutDlg dialog used for App About
+
+class CAboutDlg : public CDialog
+{
+public:
+	CAboutDlg();
+
+// Dialog Data
+	enum { IDD = IDD_ABOUTBOX };
+
+	protected:
+	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+
+// Implementation
+protected:
+	DECLARE_MESSAGE_MAP()
+};
+
+CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
+{
+}
+
+void CAboutDlg::DoDataExchange(CDataExchange* pDX)
+{
+	CDialog::DoDataExchange(pDX);
+}
+
+BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
+END_MESSAGE_MAP()
+
+
+// CICTranslateDlg dialog
+
+
+
+
+CICTranslateDlg::CICTranslateDlg(CWnd* pParent /*=NULL*/)
+	: CDialog(CICTranslateDlg::IDD, pParent),
+	m_hAccel(NULL)
+{
+	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
+}
+
+void CICTranslateDlg::DoDataExchange(CDataExchange* pDX)
+{
+	CDialog::DoDataExchange(pDX);
+	DDX_Control(pDX, IDC_SRCDATA_LIST, m_ctlBaseLanguageList);
+	DDX_Control(pDX, IDC_DSTDATA_LIST, m_ctlCustomLanguageList);
+	DDX_Control(pDX, IDC_SRCDATA_RICHEDIT, m_ctlSrcText);
+	DDX_Control(pDX, IDC_DSTDATA_RICHEDIT, 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)
+	ON_WM_SYSCOMMAND()
+	ON_WM_PAINT()
+	ON_WM_QUERYDRAGICON()
+	//}}AFX_MSG_MAP
+	ON_COMMAND(ID_FILE_OPENBASETRANSLATION, &CICTranslateDlg::OnFileOpenBaseTranslation)
+	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)
+	ON_COMMAND(ID_FILE_NEWTRANSLATION, &CICTranslateDlg::OnFileNewTranslation)
+	ON_COMMAND(ID_FILE_SAVETRANSLATIONAS, &CICTranslateDlg::OnFileSaveTranslationAs)
+	ON_COMMAND(ID_FILE_SAVETRANSLATION, &CICTranslateDlg::OnFileSaveTranslation)
+	ON_EN_KILLFOCUS(IDC_DST_AUTHOR_EDIT, &CICTranslateDlg::OnEnKillFocusDstAuthorEdit)
+	ON_EN_KILLFOCUS(IDC_DST_LANGUAGE_NAME_EDIT, &CICTranslateDlg::OnEnKillFocusDstLanguageNameEdit)
+	ON_EN_KILLFOCUS(IDC_DST_HELP_FILENAME_EDIT, &CICTranslateDlg::OnEnKillFocusDstHelpFilenameEdit)
+	ON_BN_CLICKED(IDC_DST_RTL_CHECK, &CICTranslateDlg::OnBnClickedDstRtlCheck)
+	ON_COMMAND(ID_EDIT_PREVIOUS_TO_TRANSLATE, &CICTranslateDlg::OnEditPreviousToTranslate)
+	ON_COMMAND(ID_EDIT_NEXT_TO_TRANSLATE, &CICTranslateDlg::OnEditNextToTranslate)
+	ON_COMMAND(ID_EDIT_APPLY_CHANGE, &CICTranslateDlg::OnEditApplyChange)
+	ON_COMMAND(ID_EDIT_APPLY_AND_NEXT, &CICTranslateDlg::OnEditApplyAndNext)
+END_MESSAGE_MAP()
+
+
+// CICTranslateDlg message handlers
+
+BOOL CICTranslateDlg::OnInitDialog()
+{
+	CDialog::OnInitDialog();
+
+	// Add "About..." menu item to system menu.
+
+	// IDM_ABOUTBOX must be in the system command range.
+	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
+	ASSERT(IDM_ABOUTBOX < 0xF000);
+
+	CMenu* pSysMenu = GetSystemMenu(FALSE);
+	if (pSysMenu != NULL)
+	{
+		CString strAboutMenu;
+		if(strAboutMenu.LoadString(IDS_ABOUTBOX))
+		{
+			pSysMenu->AppendMenu(MF_SEPARATOR);
+			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
+		}
+	}
+
+	// Set the icon for this dialog.  The framework does this automatically
+	//  when the application's main window is not a dialog
+	SetIcon(m_hIcon, TRUE);			// Set big icon
+	SetIcon(m_hIcon, FALSE);		// Set small icon
+
+	// use image list
+	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_ilImages.Add(AfxGetApp()->LoadIcon(IDI_WARNING_ICON));
+
+	m_ctlCustomLanguageList.SetImageList(&m_ilImages, LVSIL_SMALL);
+
+	// full row selection
+	m_ctlBaseLanguageList.SetExtendedStyle(LVS_EX_FULLROWSELECT);
+	m_ctlCustomLanguageList.SetExtendedStyle(LVS_EX_FULLROWSELECT);
+
+	// setup the lists' headers
+	// first the width of list (assuming both have the same width)
+	CRect rcList;
+	m_ctlBaseLanguageList.GetWindowRect(&rcList);
+	uint_t uiWidth = rcList.Width();
+
+	LVCOLUMN lvc;
+	lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT;
+	lvc.fmt = LVCFMT_LEFT;
+	lvc.cx = uiWidth / 5;
+	lvc.pszText = _T("ID");
+
+	m_ctlBaseLanguageList.InsertColumn(0, &lvc);
+	m_ctlCustomLanguageList.InsertColumn(0, &lvc);
+
+	lvc.cx = 4 * uiWidth / 5;
+	lvc.pszText = _T("Text");
+
+	m_ctlBaseLanguageList.InsertColumn(1, &lvc);
+	m_ctlCustomLanguageList.InsertColumn(1, &lvc);
+
+	m_hAccel = LoadAccelerators(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_ACCELERATOR));
+
+	// load the languages specified on the command line
+	PCTSTR pszCmdLine = AfxGetApp()->m_lpCmdLine;
+	if(pszCmdLine && pszCmdLine[0] != _T('\0'))
+	{
+		int iCount = 0;
+		PWSTR* pszArgs = CommandLineToArgvW(pszCmdLine, &iCount);
+
+		if(iCount > 0)
+		{
+			if(!m_ldBase.ReadTranslation(pszArgs[0]))
+			{
+				AfxMessageBox(_T("Reading base translation file failed"));
+				LocalFree(pszArgs);
+				return TRUE;
+			}
+
+			UpdateBaseLanguageList();
+			UpdateCustomLanguageList();
+		}
+		if(iCount > 1)
+		{
+			if(!m_ldCustom.ReadTranslation(pszArgs[1]))
+			{
+				AfxMessageBox(_T("Reading your language file failed"));
+				LocalFree(pszArgs);
+				return TRUE;
+			}
+
+			UpdateCustomLanguageList();
+		}
+
+		LocalFree(pszArgs);
+	}
+
+	return TRUE;  // return TRUE  unless you set the focus to a control
+}
+
+void CICTranslateDlg::OnSysCommand(UINT nID, LPARAM lParam)
+{
+	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
+	{
+		CAboutDlg dlgAbout;
+		dlgAbout.DoModal();
+	}
+	else
+	{
+		CDialog::OnSysCommand(nID, lParam);
+	}
+}
+
+// If you add a minimize button to your dialog, you will need the code below
+//  to draw the icon.  For MFC applications using the document/view model,
+//  this is automatically done for you by the framework.
+
+void CICTranslateDlg::OnPaint()
+{
+	if (IsIconic())
+	{
+		CPaintDC dc(this); // device context for painting
+
+		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
+
+		// Center icon in client rectangle
+		int cxIcon = GetSystemMetrics(SM_CXICON);
+		int cyIcon = GetSystemMetrics(SM_CYICON);
+		CRect rect;
+		GetClientRect(&rect);
+		int x = (rect.Width() - cxIcon + 1) / 2;
+		int y = (rect.Height() - cyIcon + 1) / 2;
+
+		// Draw the icon
+		dc.DrawIcon(x, y, m_hIcon);
+	}
+	else
+	{
+		CDialog::OnPaint();
+	}
+}
+
+// The system calls this function to obtain the cursor to display while the user drags
+//  the minimized window.
+HCURSOR CICTranslateDlg::OnQueryDragIcon()
+{
+	return static_cast<HCURSOR>(m_hIcon);
+}
+
+void CICTranslateDlg::OnFileOpenBaseTranslation()
+{
+	CFileDialog fd(TRUE, _T(".lng"), _T(""), OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST, _T("Language files (*.lng)|*.lng|All files(*.*)|*.*||"), this);
+	if(fd.DoModal() == IDOK)
+	{
+		if(!m_ldBase.ReadTranslation(fd.GetPathName()))
+		{
+			AfxMessageBox(_T("Reading file failed"));
+			return;
+		}
+
+		UpdateBaseLanguageList();
+		UpdateCustomLanguageList();
+	}
+}
+
+void CICTranslateDlg::OnFileOpenYourTranslation()
+{
+	// check for modification flag
+	if(!WarnModified())
+		return;
+
+	CFileDialog fd(TRUE, _T(".lng"), _T(""), OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST, _T("Language files (*.lng)|*.lng|All files(*.*)|*.*||"), this);
+	if(fd.DoModal() == IDOK)
+	{
+		if(!m_ldCustom.ReadTranslation(fd.GetPathName()))
+		{
+			AfxMessageBox(_T("Reading file failed"));
+			return;
+		}
+
+		UpdateCustomLanguageList();
+	}
+}
+
+void CICTranslateDlg::EnumLngStrings(uint_t uiID, const ictranslate::CTranslationItem* pTranslationItem, ptr_t pData)
+{
+	CListCtrl* pList = (CListCtrl*)pData;
+	assert(pTranslationItem);
+	if(!pTranslationItem)
+		return;
+	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;
+	
+	pList->InsertItem(&lvi);
+
+	lvi.mask = LVIF_TEXT;
+	lvi.pszText = (PTSTR)pTranslationItem->GetText();
+	lvi.iItem = 0;
+	lvi.iSubItem = 1;
+
+	pList->SetItem(&lvi);
+}
+
+void CICTranslateDlg::OnItemChangedSrcDataList(NMHDR *pNMHDR, LRESULT *pResult)
+{
+	LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
+	*pResult = 0;
+
+	if(pNMLV->uNewState & LVIS_SELECTED)
+	{
+		// set the text to the edit box
+		ictranslate::CTranslationItem* pTranslationItem = m_ldBase.GetTranslationItem(pNMLV->lParam, false);
+		if(pTranslationItem && pTranslationItem->GetText())
+			m_ctlSrcText.SetWindowText(pTranslationItem->GetText());
+		else
+			m_ctlSrcText.SetWindowText(m_ctlBaseLanguageList.GetItemText(pNMLV->iItem, 1));
+
+		uint_t uiID = pNMLV->lParam;
+
+		// to avoid infinite loop of selections, check if the current selection is already valid
+		POSITION pos = m_ctlCustomLanguageList.GetFirstSelectedItemPosition();
+		if(pos)
+		{
+			int iPos = m_ctlCustomLanguageList.GetNextSelectedItem(pos);
+			uint_t uiCurrentID = m_ctlCustomLanguageList.GetItemData(iPos);
+			if(uiID == uiCurrentID)
+				return;
+		}
+//		m_ctlCustomLanguageList.SetItemState(-1, 0, LVIS_SELECTED);
+
+		// search in the second list for the specified id
+		int iCount = m_ctlCustomLanguageList.GetItemCount();
+		for(int i = 0; i < iCount; i++)
+		{
+			uint_t uiCustomID = m_ctlCustomLanguageList.GetItemData(i);
+			if(uiCustomID == uiID)
+			{
+				m_ctlCustomLanguageList.EnsureVisible(i, FALSE);
+				m_ctlCustomLanguageList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
+				break;
+			}
+		}
+	}
+	else if(pNMLV->uOldState & LVIS_SELECTED)
+	{
+		m_ctlCustomLanguageList.SetItemState(-1, 0, LVIS_SELECTED);
+		m_ctlDstText.SetWindowText(_T(""));
+	}
+}
+
+void CICTranslateDlg::OnItemChangedDstDataList(NMHDR *pNMHDR, LRESULT *pResult)
+{
+	LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
+	*pResult = 0;
+
+	if(pNMLV->uNewState & LVIS_SELECTED)
+	{
+		// set the text to the edit box
+		ictranslate::CTranslationItem* pTranslationItem = m_ldCustom.GetTranslationItem(pNMLV->lParam, false);
+		if(pTranslationItem && pTranslationItem->GetText())
+			m_ctlDstText.SetWindowText(pTranslationItem->GetText());
+		else
+			m_ctlDstText.SetWindowText(m_ctlCustomLanguageList.GetItemText(pNMLV->iItem, 1));
+
+		uint_t uiID = pNMLV->lParam;
+
+		// to avoid infinite loop of selections, check if the current selection is already valid
+		POSITION pos = m_ctlBaseLanguageList.GetFirstSelectedItemPosition();
+		if(pos)
+		{
+			int iPos = m_ctlBaseLanguageList.GetNextSelectedItem(pos);
+			uint_t uiCurrentID = m_ctlBaseLanguageList.GetItemData(iPos);
+			if(uiID == uiCurrentID)
+				return;
+		}
+
+		// search in the second list for the specified id
+		int iCount = m_ctlBaseLanguageList.GetItemCount();
+		for(int i = 0; i < iCount; i++)
+		{
+			uint_t uiCustomID = m_ctlBaseLanguageList.GetItemData(i);
+			if(uiCustomID == uiID)
+			{
+				m_ctlBaseLanguageList.EnsureVisible(i, FALSE);
+				m_ctlBaseLanguageList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
+				break;
+			}
+		}
+	}
+	else if(pNMLV->uOldState & LVIS_SELECTED)
+	{
+		m_ctlBaseLanguageList.SetItemState(-1, 0, LVIS_SELECTED);
+		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();
+}
+
+// updated the custom language list - bFullUpdate means re-reading also language information (default)
+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<uint_t> 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)
+		{
+			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;
+	}
+	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, false);
+		pCustomItem->SetChecksum(pBaseItem->GetChecksum());
+		m_ldCustom.SetModified();
+	}
+
+	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() == IDOK)
+	{
+		// 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();
+}
+
+void CICTranslateDlg::OnFileNewTranslation()
+{
+	// check for modification flag
+	if(!WarnModified())
+		return;
+
+	// clear the custom translation
+	m_ldCustom.Clear();
+	UpdateCustomLanguageList();
+}
+
+void CICTranslateDlg::OnFileSaveTranslationAs()
+{
+	if(!m_ldCustom.IsValidDescription())
+	{
+		AfxMessageBox(_T("Please fill the Author, Language name and font with correct values before saving."));
+		return;
+	}
+
+	CString strFilename = m_ldCustom.GetFilename(false);
+	CString strPath = m_ldCustom.GetFilename(true);
+	
+	CFileDialog dlg(FALSE, _T(".lng"), strFilename, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, _T("Language files (*.lng)|*.lng|All files (*.*)|*.*||"), this);
+	if(dlg.DoModal() == IDOK)
+	{
+		// store additional informations from the dialog box
+		CString str;
+		m_ctlDstAuthor.GetWindowText(str);
+		m_ldCustom.SetAuthor(str);
+		m_ctlDstLanguageName.GetWindowText(str);
+		m_ldCustom.SetLangName(str);
+		m_ctlDstHelpFilename.GetWindowText(str);
+		m_ldCustom.SetHelpName(str);
+		bool bRTL = (m_ctlDstRTL.GetCheck() == BST_CHECKED);
+		m_ldCustom.SetDirection(bRTL);
+
+		// store translation with new name
+		try
+		{
+			m_ldCustom.WriteTranslation(dlg.GetPathName());
+		}
+		catch(icpf::exception& e)
+		{
+			CString strInfo;
+			strInfo.Format(_T("Cannot write translation file.\nReason: %s"), e.get_desc());
+			AfxMessageBox(strInfo);
+			return;
+		}
+		m_ctlDstFilename.SetWindowText(m_ldCustom.GetFilename(true));
+	}
+}
+
+void CICTranslateDlg::OnFileSaveTranslation()
+{
+	// sanity checks
+	if(!m_ldCustom.IsValidDescription())
+	{
+		AfxMessageBox(_T("Please fill the Author, Language name and font with correct values before saving."));
+		return;
+	}
+
+	CString strPath = m_ldCustom.GetFilename(true);
+	if(strPath.IsEmpty())
+	{
+		OnFileSaveTranslationAs();
+	}
+	else
+	{
+		// store additional informations from the dialog box
+		CString str;
+		m_ctlDstAuthor.GetWindowText(str);
+		m_ldCustom.SetAuthor(str);
+		m_ctlDstLanguageName.GetWindowText(str);
+		m_ldCustom.SetLangName(str);
+		m_ctlDstHelpFilename.GetWindowText(str);
+		m_ldCustom.SetHelpName(str);
+		bool bRTL = (m_ctlDstRTL.GetCheck() == BST_CHECKED);
+		m_ldCustom.SetDirection(bRTL);
+
+		try
+		{
+			m_ldCustom.WriteTranslation(NULL);
+		}
+		catch(icpf::exception& e)
+		{
+			CString strInfo;
+			strInfo.Format(_T("Cannot write translation file.\nReason: %s"), e.get_desc());
+			AfxMessageBox(strInfo);
+			return;
+		}
+		m_ctlDstFilename.SetWindowText(m_ldCustom.GetFilename(true));
+	}
+}
+
+bool CICTranslateDlg::WarnModified() const
+{
+	// check the modification flag
+	if(m_ldCustom.IsModified())
+	{
+		int iRes = AfxMessageBox(_T("You have modified the translation file. If you continue, the changes might be lost. Do you want to continue ?"), MB_YESNO | MB_ICONQUESTION);
+		return iRes == IDYES;
+	}
+	else
+		return true;
+}
+
+void CICTranslateDlg::OnCancel()
+{
+	if(WarnModified())
+		CDialog::OnCancel();
+}
+
+void CICTranslateDlg::OnEnKillFocusDstAuthorEdit()
+{
+	CString str;
+	m_ctlDstAuthor.GetWindowText(str);
+	const tchar_t* psz = m_ldCustom.GetAuthor();
+	if(!psz || psz != str)
+		m_ldCustom.SetAuthor(str);
+}
+
+void CICTranslateDlg::OnEnKillFocusDstLanguageNameEdit()
+{
+	CString str;
+	m_ctlDstLanguageName.GetWindowText(str);
+	const tchar_t* psz = m_ldCustom.GetLangName();
+	if(!psz || psz != str)
+		m_ldCustom.SetLangName(str);
+}
+
+void CICTranslateDlg::OnEnKillFocusDstHelpFilenameEdit()
+{
+	CString str;
+	m_ctlDstHelpFilename.GetWindowText(str);
+	const tchar_t* psz = m_ldCustom.GetHelpName();
+	if(!psz || psz != str)
+		m_ldCustom.SetHelpName(str);
+}
+
+void CICTranslateDlg::OnBnClickedDstRtlCheck()
+{
+	bool bRTL = (m_ctlDstRTL.GetCheck() == BST_CHECKED);
+	m_ldCustom.SetDirection(bRTL);
+}
+
+void CICTranslateDlg::OnEditPreviousToTranslate()
+{
+	// find selection
+	int iItem = 0;
+	POSITION pos = m_ctlCustomLanguageList.GetFirstSelectedItemPosition();
+	if(pos)
+		iItem = m_ctlCustomLanguageList.GetNextSelectedItem(pos);
+
+	// find previous element to translate
+	LVITEM lvi;
+	for(int i = iItem - 1; i >= 0; i--)
+	{
+		lvi.iItem = i;
+		lvi.iSubItem = 0;
+		lvi.mask = LVIF_IMAGE;
+
+		BOOL bRes = m_ctlCustomLanguageList.GetItem(&lvi);
+		if(bRes && lvi.iImage != IMAGE_OVERFLUOUS && lvi.iImage != IMAGE_VALID)
+		{
+			m_ctlDstText.SetWindowText(_T(""));
+			m_ctlCustomLanguageList.SetItemState(i, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
+			m_ctlCustomLanguageList.EnsureVisible(i, FALSE);
+			m_ctlDstText.SetFocus();
+			break;
+		}
+	}
+}
+
+void CICTranslateDlg::OnEditNextToTranslate()
+{
+	// find selection
+	int iItem = 0;
+	POSITION pos = m_ctlCustomLanguageList.GetFirstSelectedItemPosition();
+	if(pos)
+		iItem = m_ctlCustomLanguageList.GetNextSelectedItem(pos);
+
+	// find previous element to translate
+	LVITEM lvi;
+	int iCount = m_ctlCustomLanguageList.GetItemCount();
+	for(int i = iItem + 1; i < iCount; i++)
+	{
+		lvi.iItem = i;
+		lvi.iSubItem = 0;
+		lvi.mask = LVIF_IMAGE;
+
+		BOOL bRes = m_ctlCustomLanguageList.GetItem(&lvi);
+		if(bRes && lvi.iImage != IMAGE_OVERFLUOUS && lvi.iImage != IMAGE_VALID)
+		{
+			m_ctlDstText.SetWindowText(_T(""));
+			m_ctlCustomLanguageList.SetItemState(i, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
+			m_ctlCustomLanguageList.EnsureVisible(i, FALSE);
+			m_ctlDstText.SetFocus();
+			break;
+		}
+	}
+}
+
+void CICTranslateDlg::OnEditApplyChange()
+{
+	// apply change
+	OnBnClickedApply();
+}
+
+void CICTranslateDlg::OnEditApplyAndNext()
+{
+	OnBnClickedApply();
+	OnEditNextToTranslate();
+}
+
+BOOL CICTranslateDlg::PreTranslateMessage(MSG* pMsg)
+{
+	if(m_hAccel)
+	{
+		if(TranslateAccelerator(m_hWnd, m_hAccel, pMsg) != 0)
+			return TRUE;
+	}
+
+	return CDialog::PreTranslateMessage(pMsg);
+}
Index: src/ictranslate/ICTranslateDlg.h
===================================================================
diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/ictranslate/ICTranslateDlg.h	(.../ICTranslateDlg.h)	(revision 4eceec553f29c0ba93452ffeb52a647204dc9fce)
+++ src/ictranslate/ICTranslateDlg.h	(.../ICTranslateDlg.h)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,105 +1,105 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-// ICTranslateDlg.h : header file
-//
-
-#pragma once
-#include "../libictranslate/ResourceManager.h"
-#include "afxcmn.h"
-#include "afxwin.h"
-
-// CICTranslateDlg dialog
-class CICTranslateDlg : public CDialog
-{
-// Construction
-public:
-	CICTranslateDlg(CWnd* pParent = NULL);	// standard constructor
-
-// Dialog Data
-	enum { IDD = IDD_ICTRANSLATE_DIALOG };
-
-	virtual BOOL PreTranslateMessage(MSG* pMsg);
-	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();
-	afx_msg void OnEnKillFocusDstAuthorEdit();
-	afx_msg void OnEnKillFocusDstLanguageNameEdit();
-	afx_msg void OnEnKillFocusDstHelpFilenameEdit();
-	afx_msg void OnBnClickedDstRtlCheck();
-	afx_msg void OnEditPreviousToTranslate();
-	afx_msg void OnEditNextToTranslate();
-	afx_msg void OnEditApplyChange();
-	afx_msg void OnEditApplyAndNext();
-	afx_msg void OnBnClickedChooseFontButton();
-	afx_msg void OnEditCleanupTranslation();
-	afx_msg void OnFileNewTranslation();
-	afx_msg void OnFileSaveTranslationAs();
-	afx_msg void OnFileSaveTranslation();
-
-protected:
-	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
-	virtual BOOL OnInitDialog();
-	virtual void OnCancel();
-	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
-	afx_msg void OnPaint();
-	afx_msg HCURSOR OnQueryDragIcon();
-	DECLARE_MESSAGE_MAP()
-
-	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);
-
-	bool WarnModified() const;
-
-// Implementation
-protected:
-	HICON m_hIcon;
-	CImageList m_ilImages;
-	ictranslate::CLangData m_ldBase;
-	ictranslate::CLangData m_ldCustom;
-
-	HACCEL m_hAccel;
-
-	// Controls
-	CListCtrl m_ctlBaseLanguageList;
-	CListCtrl m_ctlCustomLanguageList;
-	CRichEditCtrl m_ctlSrcText;
-	CRichEditCtrl m_ctlDstText;
-	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;
-};
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+// ICTranslateDlg.h : header file
+//
+
+#pragma once
+#include "../libictranslate/ResourceManager.h"
+#include "afxcmn.h"
+#include "afxwin.h"
+
+// CICTranslateDlg dialog
+class CICTranslateDlg : public CDialog
+{
+// Construction
+public:
+	CICTranslateDlg(CWnd* pParent = NULL);	// standard constructor
+
+// Dialog Data
+	enum { IDD = IDD_ICTRANSLATE_DIALOG };
+
+	virtual BOOL PreTranslateMessage(MSG* pMsg);
+	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();
+	afx_msg void OnEnKillFocusDstAuthorEdit();
+	afx_msg void OnEnKillFocusDstLanguageNameEdit();
+	afx_msg void OnEnKillFocusDstHelpFilenameEdit();
+	afx_msg void OnBnClickedDstRtlCheck();
+	afx_msg void OnEditPreviousToTranslate();
+	afx_msg void OnEditNextToTranslate();
+	afx_msg void OnEditApplyChange();
+	afx_msg void OnEditApplyAndNext();
+	afx_msg void OnBnClickedChooseFontButton();
+	afx_msg void OnEditCleanupTranslation();
+	afx_msg void OnFileNewTranslation();
+	afx_msg void OnFileSaveTranslationAs();
+	afx_msg void OnFileSaveTranslation();
+
+protected:
+	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
+	virtual BOOL OnInitDialog();
+	virtual void OnCancel();
+	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
+	afx_msg void OnPaint();
+	afx_msg HCURSOR OnQueryDragIcon();
+	DECLARE_MESSAGE_MAP()
+
+	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);
+
+	bool WarnModified() const;
+
+// Implementation
+protected:
+	HICON m_hIcon;
+	CImageList m_ilImages;
+	ictranslate::CLangData m_ldBase;
+	ictranslate::CLangData m_ldCustom;
+
+	HACCEL m_hAccel;
+
+	// Controls
+	CListCtrl m_ctlBaseLanguageList;
+	CListCtrl m_ctlCustomLanguageList;
+	CRichEditCtrl m_ctlSrcText;
+	CRichEditCtrl m_ctlDstText;
+	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;
+};
Index: src/ictranslate/ictranslate.cpp
===================================================================
diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/ictranslate/ictranslate.cpp	(.../ictranslate.cpp)	(revision 4eceec553f29c0ba93452ffeb52a647204dc9fce)
+++ src/ictranslate/ictranslate.cpp	(.../ictranslate.cpp)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,97 +1,97 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-// ictranslate.cpp : Defines the class behaviors for the application.
-//
-
-#include "stdafx.h"
-#include "ictranslate.h"
-#include "ICTranslateDlg.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
-
-// CICTranslateApp
-
-BEGIN_MESSAGE_MAP(CICTranslateApp, CWinApp)
-	ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
-END_MESSAGE_MAP()
-
-
-// CICTranslateApp construction
-
-CICTranslateApp::CICTranslateApp()
-{
-	// TODO: add construction code here,
-	// Place all significant initialization in InitInstance
-}
-
-
-// The one and only CICTranslateApp object
-
-CICTranslateApp theApp;
-
-
-// CICTranslateApp initialization
-
-BOOL CICTranslateApp::InitInstance()
-{
-	// InitCommonControlsEx() is required on Windows XP if an application
-	// manifest specifies use of ComCtl32.dll version 6 or later to enable
-	// visual styles.  Otherwise, any window creation will fail.
-	INITCOMMONCONTROLSEX InitCtrls;
-	InitCtrls.dwSize = sizeof(InitCtrls);
-	// Set this to include all the common control classes you want to use
-	// in your application.
-	InitCtrls.dwICC = ICC_WIN95_CLASSES;
-	InitCommonControlsEx(&InitCtrls);
-	
-	AfxInitRichEdit2();
-	CWinApp::InitInstance();
-
-	AfxEnableControlContainer();
-
-	// Standard initialization
-	// If you are not using these features and wish to reduce the size
-	// of your final executable, you should remove from the following
-	// the specific initialization routines you do not need
-	// Change the registry key under which our settings are stored
-	// TODO: You should modify this string to be something appropriate
-	// such as the name of your company or organization
-//	SetRegistryKey(_T("Local AppWizard-Generated Applications"));
-
-	CICTranslateDlg dlg;
-	m_pMainWnd = &dlg;
-	INT_PTR nResponse = dlg.DoModal();
-	if (nResponse == IDOK)
-	{
-		// TODO: Place code here to handle when the dialog is
-		//  dismissed with OK
-	}
-	else if (nResponse == IDCANCEL)
-	{
-		// TODO: Place code here to handle when the dialog is
-		//  dismissed with Cancel
-	}
-
-	// Since the dialog has been closed, return FALSE so that we exit the
-	//  application, rather than start the application's message pump.
-	return FALSE;
-}
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+// ictranslate.cpp : Defines the class behaviors for the application.
+//
+
+#include "stdafx.h"
+#include "ictranslate.h"
+#include "ICTranslateDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+
+// CICTranslateApp
+
+BEGIN_MESSAGE_MAP(CICTranslateApp, CWinApp)
+	ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
+END_MESSAGE_MAP()
+
+
+// CICTranslateApp construction
+
+CICTranslateApp::CICTranslateApp()
+{
+	// TODO: add construction code here,
+	// Place all significant initialization in InitInstance
+}
+
+
+// The one and only CICTranslateApp object
+
+CICTranslateApp theApp;
+
+
+// CICTranslateApp initialization
+
+BOOL CICTranslateApp::InitInstance()
+{
+	// InitCommonControlsEx() is required on Windows XP if an application
+	// manifest specifies use of ComCtl32.dll version 6 or later to enable
+	// visual styles.  Otherwise, any window creation will fail.
+	INITCOMMONCONTROLSEX InitCtrls;
+	InitCtrls.dwSize = sizeof(InitCtrls);
+	// Set this to include all the common control classes you want to use
+	// in your application.
+	InitCtrls.dwICC = ICC_WIN95_CLASSES;
+	InitCommonControlsEx(&InitCtrls);
+	
+	AfxInitRichEdit2();
+	CWinApp::InitInstance();
+
+	AfxEnableControlContainer();
+
+	// Standard initialization
+	// If you are not using these features and wish to reduce the size
+	// of your final executable, you should remove from the following
+	// the specific initialization routines you do not need
+	// Change the registry key under which our settings are stored
+	// TODO: You should modify this string to be something appropriate
+	// such as the name of your company or organization
+//	SetRegistryKey(_T("Local AppWizard-Generated Applications"));
+
+	CICTranslateDlg dlg;
+	m_pMainWnd = &dlg;
+	INT_PTR nResponse = dlg.DoModal();
+	if (nResponse == IDOK)
+	{
+		// TODO: Place code here to handle when the dialog is
+		//  dismissed with OK
+	}
+	else if (nResponse == IDCANCEL)
+	{
+		// TODO: Place code here to handle when the dialog is
+		//  dismissed with Cancel
+	}
+
+	// Since the dialog has been closed, return FALSE so that we exit the
+	//  application, rather than start the application's message pump.
+	return FALSE;
+}
Index: src/ictranslate/ictranslate.h
===================================================================
diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/ictranslate/ictranslate.h	(.../ictranslate.h)	(revision 4eceec553f29c0ba93452ffeb52a647204dc9fce)
+++ src/ictranslate/ictranslate.h	(.../ictranslate.h)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,49 +1,49 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-// ictranslate.h : main header file for the PROJECT_NAME application
-//
-
-#pragma once
-
-#ifndef __AFXWIN_H__
-	#error "include 'stdafx.h' before including this file for PCH"
-#endif
-
-#include "resource.h"		// main symbols
-
-
-// CICTranslateApp:
-// See ictranslate.cpp for the implementation of this class
-//
-
-class CICTranslateApp : public CWinApp
-{
-public:
-	CICTranslateApp();
-
-// Overrides
-	public:
-	virtual BOOL InitInstance();
-
-// Implementation
-
-	DECLARE_MESSAGE_MAP()
-};
-
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+// ictranslate.h : main header file for the PROJECT_NAME application
+//
+
+#pragma once
+
+#ifndef __AFXWIN_H__
+	#error "include 'stdafx.h' before including this file for PCH"
+#endif
+
+#include "resource.h"		// main symbols
+
+
+// CICTranslateApp:
+// See ictranslate.cpp for the implementation of this class
+//
+
+class CICTranslateApp : public CWinApp
+{
+public:
+	CICTranslateApp();
+
+// Overrides
+	public:
+	virtual BOOL InitInstance();
+
+// Implementation
+
+	DECLARE_MESSAGE_MAP()
+};
+
 extern CICTranslateApp theApp;
\ No newline at end of file
Index: src/ictranslate/resource.h
===================================================================
diff -u -r4df7577e1530bd356e87f0cc5ccb74f73b6c8bf8 -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/ictranslate/resource.h	(.../resource.h)	(revision 4df7577e1530bd356e87f0cc5ccb74f73b6c8bf8)
+++ src/ictranslate/resource.h	(.../resource.h)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,64 +1,64 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by ictranslate.rc
-//
-#define IDM_ABOUTBOX                    0x0010
-#define IDD_ABOUTBOX                    100
-#define IDS_ABOUTBOX                    101
-#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 IDI_WARNING_ICON                134
-#define IDR_ACCELERATOR                 135
-#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 IDC_SRCDATA_RICHEDIT            1026
-#define IDC_DSTDATA_RICHEDIT            1027
-#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
-#define ID_EDIT_APLLYCHANGE             32779
-#define ID_EDIT_NEXTTOTRANSLATE         32780
-#define ID_EDIT_PREVIOUSTOTRANSLATE     32781
-#define ID_EDIT_APPLYNEXTTOTRANSLATE    32782
-#define ID_EDIT_PREVIOUS_TO_TRANSLATE   32783
-#define ID_EDIT_NEXT_TO_TRANSLATE       32784
-#define ID_EDIT_APPLY_CHANGE            32785
-#define ID_EDIT_APPLY_AND_NEXT          32786
-
-// Next default values for new objects
-// 
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE        136
-#define _APS_NEXT_COMMAND_VALUE         32796
-#define _APS_NEXT_CONTROL_VALUE         1028
-#define _APS_NEXT_SYMED_VALUE           101
-#endif
-#endif
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by ictranslate.rc
+//
+#define IDM_ABOUTBOX                    0x0010
+#define IDD_ABOUTBOX                    100
+#define IDS_ABOUTBOX                    101
+#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 IDI_WARNING_ICON                134
+#define IDR_ACCELERATOR                 135
+#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 IDC_SRCDATA_RICHEDIT            1026
+#define IDC_DSTDATA_RICHEDIT            1027
+#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
+#define ID_EDIT_APLLYCHANGE             32779
+#define ID_EDIT_NEXTTOTRANSLATE         32780
+#define ID_EDIT_PREVIOUSTOTRANSLATE     32781
+#define ID_EDIT_APPLYNEXTTOTRANSLATE    32782
+#define ID_EDIT_PREVIOUS_TO_TRANSLATE   32783
+#define ID_EDIT_NEXT_TO_TRANSLATE       32784
+#define ID_EDIT_APPLY_CHANGE            32785
+#define ID_EDIT_APPLY_AND_NEXT          32786
+
+// Next default values for new objects
+// 
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE        136
+#define _APS_NEXT_COMMAND_VALUE         32796
+#define _APS_NEXT_CONTROL_VALUE         1028
+#define _APS_NEXT_SYMED_VALUE           101
+#endif
+#endif
Index: src/ictranslate/stdafx.cpp
===================================================================
diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/ictranslate/stdafx.cpp	(.../stdafx.cpp)	(revision 4eceec553f29c0ba93452ffeb52a647204dc9fce)
+++ src/ictranslate/stdafx.cpp	(.../stdafx.cpp)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,25 +1,25 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-// stdafx.cpp : source file that includes just the standard includes
-// ictranslate.pch will be the pre-compiled header
-// stdafx.obj will contain the pre-compiled type information
-
-#include "stdafx.h"
-
-
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+// stdafx.cpp : source file that includes just the standard includes
+// ictranslate.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+
Index: src/ictranslate/stdafx.h
===================================================================
diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/ictranslate/stdafx.h	(.../stdafx.h)	(revision 4eceec553f29c0ba93452ffeb52a647204dc9fce)
+++ src/ictranslate/stdafx.h	(.../stdafx.h)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,75 +1,75 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-// stdafx.h : include file for standard system include files,
-// or project specific include files that are used frequently,
-// but are changed infrequently
-
-#pragma once
-
-#ifndef _SECURE_ATL
-#define _SECURE_ATL 1
-#endif
-
-#ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN            // Exclude rarely-used stuff from Windows headers
-#endif
-
-#include "targetver.h"
-
-#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // some CString constructors will be explicit
-
-// turns off MFC's hiding of some common and often safely ignored warning messages
-#define _AFX_ALL_WARNINGS
-
-#include <afxwin.h>         // MFC core and standard components
-#include <afxext.h>         // MFC extensions
-
-
-#include <afxdisp.h>        // MFC Automation classes
-
-
-
-#ifndef _AFX_NO_OLE_SUPPORT
-#include <afxdtctl.h>           // MFC support for Internet Explorer 4 Common Controls
-#endif
-#ifndef _AFX_NO_AFXCMN_SUPPORT
-#include <afxcmn.h>                     // MFC support for Windows Common Controls
-#endif // _AFX_NO_AFXCMN_SUPPORT
-
-
-
-
-
-
-
-
-
-#ifdef _UNICODE
-#if defined _M_IX86
-#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
-#elif defined _M_IA64
-#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
-#elif defined _M_X64
-#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
-#else
-#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
-#endif
-#endif
-
-
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently,
+// but are changed infrequently
+
+#pragma once
+
+#ifndef _SECURE_ATL
+#define _SECURE_ATL 1
+#endif
+
+#ifndef VC_EXTRALEAN
+#define VC_EXTRALEAN            // Exclude rarely-used stuff from Windows headers
+#endif
+
+#include "targetver.h"
+
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // some CString constructors will be explicit
+
+// turns off MFC's hiding of some common and often safely ignored warning messages
+#define _AFX_ALL_WARNINGS
+
+#include <afxwin.h>         // MFC core and standard components
+#include <afxext.h>         // MFC extensions
+
+
+#include <afxdisp.h>        // MFC Automation classes
+
+
+
+#ifndef _AFX_NO_OLE_SUPPORT
+#include <afxdtctl.h>           // MFC support for Internet Explorer 4 Common Controls
+#endif
+#ifndef _AFX_NO_AFXCMN_SUPPORT
+#include <afxcmn.h>                     // MFC support for Windows Common Controls
+#endif // _AFX_NO_AFXCMN_SUPPORT
+
+
+
+
+
+
+
+
+
+#ifdef _UNICODE
+#if defined _M_IX86
+#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#elif defined _M_IA64
+#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#elif defined _M_X64
+#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#else
+#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#endif
+#endif
+
+
Index: src/ictranslate/targetver.h
===================================================================
diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/ictranslate/targetver.h	(.../targetver.h)	(revision 4eceec553f29c0ba93452ffeb52a647204dc9fce)
+++ src/ictranslate/targetver.h	(.../targetver.h)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,44 +1,44 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-
-#pragma once
-
-// The following macros define the minimum required platform.  The minimum required platform
-// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 
-// your application.  The macros work by enabling all features available on platform versions up to and 
-// including the version specified.
-
-// Modify the following defines if you have to target a platform prior to the ones specified below.
-// Refer to MSDN for the latest info on corresponding values for different platforms.
-#ifndef WINVER                          // Specifies that the minimum required platform is Windows Vista.
-#define WINVER 0x0600           // Change this to the appropriate value to target other versions of Windows.
-#endif
-
-#ifndef _WIN32_WINNT            // Specifies that the minimum required platform is Windows Vista.
-#define _WIN32_WINNT 0x0600     // Change this to the appropriate value to target other versions of Windows.
-#endif
-
-#ifndef _WIN32_WINDOWS          // Specifies that the minimum required platform is Windows 98.
-#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
-#endif
-
-#ifndef _WIN32_IE                       // Specifies that the minimum required platform is Internet Explorer 7.0.
-#define _WIN32_IE 0x0700        // Change this to the appropriate value to target other versions of IE.
-#endif
-
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+
+#pragma once
+
+// The following macros define the minimum required platform.  The minimum required platform
+// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 
+// your application.  The macros work by enabling all features available on platform versions up to and 
+// including the version specified.
+
+// Modify the following defines if you have to target a platform prior to the ones specified below.
+// Refer to MSDN for the latest info on corresponding values for different platforms.
+#ifndef WINVER                          // Specifies that the minimum required platform is Windows Vista.
+#define WINVER 0x0600           // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#ifndef _WIN32_WINNT            // Specifies that the minimum required platform is Windows Vista.
+#define _WIN32_WINNT 0x0600     // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#ifndef _WIN32_WINDOWS          // Specifies that the minimum required platform is Windows 98.
+#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
+#endif
+
+#ifndef _WIN32_IE                       // Specifies that the minimum required platform is Internet Explorer 7.0.
+#define _WIN32_IE 0x0700        // Change this to the appropriate value to target other versions of IE.
+#endif
+
Index: src/libictranslate/LanguageDialog.cpp
===================================================================
diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/libictranslate/LanguageDialog.cpp	(.../LanguageDialog.cpp)	(revision 4eceec553f29c0ba93452ffeb52a647204dc9fce)
+++ src/libictranslate/LanguageDialog.cpp	(.../LanguageDialog.cpp)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,717 +1,717 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-#include "stdafx.h"
-#include "LanguageDialog.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
-BEGIN_ICTRANSLATE_NAMESPACE
-
-/////////////////////////////////////////////////////////////////////////////
-// CDlgTemplate
-CDlgTemplate::CDlgTemplate(const DLGTEMPLATE* pDlgTemplate)
-{
-	Open(pDlgTemplate);
-}
-
-CDlgTemplate::CDlgTemplate(const DLGTEMPLATEEX* pDlgTemplate)
-{
-	Open((DLGTEMPLATE*)pDlgTemplate);
-}
-
-CDlgTemplate::~CDlgTemplate()
-{
-	delete [] m_pszMenu;
-	delete [] m_pszClass;
-	delete [] m_pszTitle;
-	delete [] m_pszFace;
-
-	// items
-	vector<_ITEM>::iterator it;
-	for (it=m_vItems.begin();it != m_vItems.end();it++)
-	{
-		delete [] (*it).m_pbyCreationData;
-		delete [] (*it).m_pszClass;
-		delete [] (*it).m_pszTitle;
-	}
-}
-
-bool CDlgTemplate::Open(const DLGTEMPLATE* pDlgTemplate)
-{
-	if (pDlgTemplate == NULL)
-		return false;
-	bool bExt=((DLGTEMPLATEEX*)pDlgTemplate)->signature == 0xffff;
-	const BYTE* pData=((BYTE*)pDlgTemplate);
-	if (bExt)
-	{
-		m_dlgTemplate=*((DLGTEMPLATEEX*)pDlgTemplate);
-		pData+=sizeof(DLGTEMPLATEEX);
-	}
-	else
-	{
-		ConvertDlgToEx(pDlgTemplate, &m_dlgTemplate);
-		pData+=sizeof(DLGTEMPLATE);
-	}
-	
-	// here is the menu, class and title
-	pData=ReadCompoundData(pData, &m_wMenu, &m_pszMenu);
-	pData=ReadCompoundData(pData, &m_wClass, &m_pszClass);
-	pData=ReadCompoundData(pData, &m_wTitle, &m_pszTitle);
-
-	// font
-	if (m_dlgTemplate.style & DS_SETFONT || m_dlgTemplate.style & DS_SHELLFONT)
-	{
-		m_wFontSize=*((WORD*)pData);
-		pData+=sizeof(WORD);
-		if (bExt)
-		{
-			m_wWeight=*((WORD*)pData);
-			pData+=sizeof(WORD);
-			m_byItalic=*((BYTE*)pData);
-			pData+=sizeof(BYTE);
-			m_byCharset=*((BYTE*)pData);
-			pData+=sizeof(BYTE);
-		}
-		else
-		{
-			m_wWeight=FW_NORMAL;
-			m_byItalic=FALSE;
-			m_byCharset=DEFAULT_CHARSET;
-		}
-		DWORD dwLen=(DWORD)wcslen((wchar_t*)pData);
-		m_pszFace=new TCHAR[dwLen+1];
-#ifdef _UNICODE
-		_tcscpy(m_pszFace, (wchar_t*)pData);
-#else
-		WideCharToMultiByte(CP_ACP, 0, (wchar_t*)pData, dwLen+1, m_pszFace, dwLen+1, NULL, NULL);
-#endif
-		pData+=(dwLen+1)*sizeof(wchar_t);
-	}
-	else
-	{
-		m_wFontSize=0xffff;
-		m_pszFace=NULL;
-	}
-
-	// items
-	_ITEM item;
-	for (int i=0;i<m_dlgTemplate.cDlgItems;i++)
-	{
-		// align to the nearest DWORD
-		pData=(BYTE*)((LONG_PTR)(pData + 3) & ~3);
-
-		// item
-		if (bExt)
-		{
-			item.m_itemTemplate=*((DLGITEMTEMPLATEEX*)pData);
-			pData+=sizeof(DLGITEMTEMPLATEEX);
-		}
-		else
-		{
-			ConvertItemToEx((DLGITEMTEMPLATE*)pData, &item.m_itemTemplate);
-			pData+=sizeof(DLGITEMTEMPLATE);
-		}
-
-		pData=ReadCompoundData(pData, &item.m_wClass, &item.m_pszClass);
-		if (item.m_wClass == 0xffff && item.m_pszClass != NULL)
-		{
-			// check the class strings and translate to atom values
-			if (_tcscmp(item.m_pszClass, _T("STATIC")) == 0)
-			{
-				item.m_wClass=0x0082;
-				delete [] item.m_pszClass;
-				item.m_pszClass=NULL;
-			}
-			else if (_tcscmp(item.m_pszClass, _T("BUTTON")) == 0)
-			{
-				item.m_wClass=0x0080;
-				delete [] item.m_pszClass;
-				item.m_pszClass=NULL;
-			}
-			else if (_tcscmp(item.m_pszClass, _T("EDIT")) == 0)
-			{
-				item.m_wClass=0x0081;
-				delete [] item.m_pszClass;
-				item.m_pszClass=NULL;
-			}
-			else if (_tcscmp(item.m_pszClass, _T("COMBOBOX")) == 0)
-			{
-				item.m_wClass=0x0085;
-				delete [] item.m_pszClass;
-				item.m_pszClass=NULL;
-			}
-			else if (_tcscmp(item.m_pszClass, _T("LISTBOX")) == 0)
-			{
-				item.m_wClass=0x0083;
-				delete [] item.m_pszClass;
-				item.m_pszClass=NULL;
-			}
-			else if (_tcscmp(item.m_pszClass, _T("SCROLLBAR")) == 0)
-			{
-				item.m_wClass=0x0084;
-				delete [] item.m_pszClass;
-				item.m_pszClass=NULL;
-			}
-		}
-		pData=ReadCompoundData(pData, &item.m_wTitle, &item.m_pszTitle);
-
-		// creation data
-		item.m_wCreationDataSize=(*((WORD*)pData));
-		pData+=sizeof(WORD);
-		if (item.m_wCreationDataSize > 0)
-		{
-			item.m_wCreationDataSize-=sizeof(WORD);
-			item.m_pbyCreationData=new BYTE[item.m_wCreationDataSize];
-			memcpy(item.m_pbyCreationData, pData, item.m_wCreationDataSize);
-		}
-		else
-			item.m_pbyCreationData=NULL;
-
-		m_vItems.push_back(item);
-	}
-
-	return true;
-}
-
-void CDlgTemplate::ConvertItemToEx(const DLGITEMTEMPLATE* pSrc, DLGITEMTEMPLATEEX* pDst)
-{
-	pDst->helpID=0;
-	pDst->exStyle=pSrc->dwExtendedStyle;
-	pDst->style=pSrc->style;
-	pDst->x=pSrc->x;
-	pDst->y=pSrc->y;
-	pDst->cx=pSrc->cx;
-	pDst->cy=pSrc->cy;
-	pDst->id=pSrc->id;
-}
-
-void CDlgTemplate::ConvertDlgToEx(const DLGTEMPLATE* pSrc, DLGTEMPLATEEX* pDst)
-{
-	pDst->dlgVer=1;
-	pDst->signature=0x0000;
-	pDst->helpID=(ULONG)0;
-	pDst->exStyle=pSrc->dwExtendedStyle;
-	pDst->style=pSrc->style;
-	pDst->cDlgItems=pSrc->cdit;
-	pDst->x=pSrc->x;
-	pDst->y=pSrc->y;
-	pDst->cx=pSrc->cx;
-	pDst->cy=pSrc->cy;
-}
-
-const BYTE* CDlgTemplate::ReadCompoundData(const BYTE* pBuffer, WORD* pwData, PTSTR* ppszStr)
-{
-	if (*((WORD*)pBuffer) == 0xffff)
-	{
-		*pwData=*((WORD*)(pBuffer+2));
-		*ppszStr=NULL;
-
-		return pBuffer+4;
-	}
-	else
-	{
-		*pwData=0xffff;
-		DWORD dwLen=(DWORD)wcslen((wchar_t*)pBuffer);
-		*ppszStr=new TCHAR[dwLen+1];
-#ifdef _UNICODE
-		_tcscpy(*ppszStr, (wchar_t*)pBuffer);
-#else
-		WideCharToMultiByte(CP_ACP, 0, (wchar_t*)pBuffer, dwLen+1, *ppszStr, dwLen+1, NULL, NULL);
-#endif
-		return pBuffer+(dwLen+1)*sizeof(wchar_t);
-	}
-
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// CLanguageDialog dialog
-
-BEGIN_MESSAGE_MAP(CLanguageDialog, CDialog)
-	ON_WM_HELPINFO()
-	ON_WM_CONTEXTMENU()
-	ON_BN_CLICKED(IDHELP, OnHelpButton)
-END_MESSAGE_MAP()
-
-
-CResourceManager *CLanguageDialog::m_prm=NULL;
-
-///////////////////////////////////////////////////////////////
-// Standard constructor
-// pLock [in] - specifies address of a bool value that'll be
-//		used to check if another instance of this window has
-//		already been shown. Should be declared in derived class
-//		as 'static bool m_xxx;' and initialized to 0.
-///////////////////////////////////////////////////////////////
-CLanguageDialog::CLanguageDialog(bool* pLock) : CDialog()
-{
-	m_pszResName=NULL;
-	m_uiResID=0;
-	m_pParent=NULL;
-	m_cType=-1;
-	m_bAutoDelete=false;
-	m_pFont=NULL;
-	m_pbLock=pLock;
-	m_bLockChanged=false;
-	m_bLockInstance=false;
-	m_iBaseX=m_iBaseY=0;
-	_ASSERT(m_prm);			// make sure the CLanguageDialog::SetResManager() has been called aready
-	if(m_prm)
-		m_prm->m_lhDialogs.push_back(this);
-}
-
-///////////////////////////////////////////////////////////////
-// Constructor that takes string based template name
-// lpszTemplateName [in] - specifies the template name to load
-//		and show as this dialog.
-// pParent [in] - logical (everyone knows)
-// pLock [in] - address of a bool for dialog instance checks
-///////////////////////////////////////////////////////////////
-CLanguageDialog::CLanguageDialog(PCTSTR lpszTemplateName, CWnd* pParent, bool* pLock) : CDialog()
-{
-	m_pszResName=lpszTemplateName;
-	if (IS_INTRESOURCE(lpszTemplateName))
-		m_uiResID=(WORD)lpszTemplateName;
-	else
-		m_uiResID=0;
-	m_pParent=pParent;
-	m_cType=-1;
-	m_bAutoDelete=false;
-	m_pFont=NULL;
-	m_pbLock=pLock;
-	m_bLockChanged=false;
-	m_bLockInstance=false;
-	m_iBaseX=m_iBaseY=0;
-	_ASSERT(m_prm);			// make sure the CLanguageDialog::SetResManager() has been called aready
-	if(m_prm)
-		m_prm->m_lhDialogs.push_back(this);
-}
-
-///////////////////////////////////////////////////////////////
-// Constructor that takes UINT based template name
-// uiIDTemplate [in] - specifies the template ID to load
-//		and show as this dialog.
-// pParent [in] - logical (everyone knows)
-// pLock [in] - address of a bool for dialog instance checks
-///////////////////////////////////////////////////////////////
-CLanguageDialog::CLanguageDialog(UINT uiIDTemplate, CWnd* pParent, bool* pLock) : CDialog()
-{
-	m_pszResName=MAKEINTRESOURCE(uiIDTemplate);
-	m_uiResID=uiIDTemplate;
-	m_pParent=pParent;
-	m_cType=-1;
-	m_bAutoDelete=false;
-	m_pFont=NULL;
-	m_pbLock=pLock;
-	m_bLockChanged=false;
-	m_bLockInstance=false;
-	m_iBaseX=m_iBaseY=0;
-	_ASSERT(m_prm);			// make sure the CLanguageDialog::SetResManager() has been called aready
-	if(m_prm)
-		m_prm->m_lhDialogs.push_back(this);
-}
-
-///////////////////////////////////////////////////////////////
-// Standard destructor
-// Removes itself from a list in CWinApp (not to get any window
-// messages anymore).
-///////////////////////////////////////////////////////////////
-CLanguageDialog::~CLanguageDialog()
-{
-	list<CWnd*>::iterator it=m_prm->m_lhDialogs.begin();
-	while (it != m_prm->m_lhDialogs.end())
-	{
-		if (*it == this)
-		{
-			m_prm->m_lhDialogs.erase(it);
-			break;
-		}
-
-		it++;
-	}
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// CLanguageDialog message handlers
-
-///////////////////////////////////////////////////////////////
-// Makes properly constructed dialog modal.
-// RetVal [out] - value returned by dialog proc
-///////////////////////////////////////////////////////////////
-INT_PTR CLanguageDialog::DoModal() 
-{
-	if (m_pszResName)
-	{
-		HGLOBAL hDialog=m_prm->LoadResource(RT_DIALOG, m_pszResName);
-		if (!InitModalIndirect(hDialog))
-			return -1;
-	}
-	m_cType=0;
-	return CDialog::DoModal();
-}
-
-///////////////////////////////////////////////////////////////
-// Creates (and shows probably) this constructed dialog.
-// RetVal [out] - if creation succeeded
-///////////////////////////////////////////////////////////////
-BOOL CLanguageDialog::Create() 
-{
-	_ASSERT(m_pszResName);		// nothing was set as a dialog template
-    
-	if (!m_bLockInstance || m_pbLock == NULL || !(*m_pbLock))
-	{
-		HGLOBAL hDialog=m_prm->LoadResource(RT_DIALOG, m_pszResName);
-
-		// modeless dialog
-		if (!CreateIndirect(hDialog, m_pParent))
-			return FALSE;
-
-		m_cType=1;
-		if (m_pbLock)
-		{
-			*m_pbLock=true;
-			m_bLockChanged=true;
-		}
-
-		return TRUE;
-	}
-	else
-	{
-		m_bLockChanged=false;
-		Cleanup();
-		return FALSE;
-	}
-}
-
-///////////////////////////////////////////////////////////////
-// Changes values based on dialog units into the values in
-// pixels. Change is based on std MapDialogRect if the language
-// hasn't been changed otf or takes current font into
-// consideration.
-// pRect [in/out] - on [in] - dialog units, on [out] - pixels
-///////////////////////////////////////////////////////////////
-void CLanguageDialog::MapRect(RECT* pRect)
-{
-	if (m_pFont)
-	{
-		pRect->left=MulDiv(pRect->left, m_iBaseX, 4);
-		pRect->right=MulDiv(pRect->right, m_iBaseX, 4);
-		pRect->top=MulDiv(pRect->top, m_iBaseY, 8);
-		pRect->bottom=MulDiv(pRect->bottom, m_iBaseY, 8);
-	}
-	else
-		MapDialogRect(pRect);
-}
-
-///////////////////////////////////////////////////////////////
-// Helper function - called when this dialog receives message
-// WM_RMNOTIFY (with WPARAM == RMNT_LANGCHANGE). Updates the
-// dialog with data from a new template. Passes params to
-// virtual function OnLanguageChanged.
-// wOldLang [in] - specifies the old language code
-// wNewLang [in] - specifies the new language code.
-///////////////////////////////////////////////////////////////
-void CLanguageDialog::UpdateLanguage()
-{
-	// cannot update for string based template
-	if (m_uiResID == 0)
-		return;
-
-	// set the title
-	SetWindowText(m_prm->LoadString((WORD)m_uiResID, 0));
-
-	// load the dialog template
-	CDlgTemplate dt;
-	if (!dt.Open(m_prm->LoadDialog(MAKEINTRESOURCE(m_uiResID))))
-	{
-		TRACE("Cannot open dialog template in UpdateLanguage\n");
-		return;
-	}
-
-	// update the menu
-	if (GetMenu())
-		m_prm->UpdateMenu(GetMenu()->m_hMenu, dt.m_wMenu);
-
-	// font
-	if (!(GetLanguageUpdateOptions() & LDF_NODIALOGFONT))
-	{
-		// dialog font
-		LOGFONT lf;
-		memset(&lf, 0, sizeof(LOGFONT));
-		HDC hdc=::GetDC(NULL);
-		lf.lfHeight = -MulDiv(m_prm->m_ld.GetPointSize(), GetDeviceCaps(hdc, LOGPIXELSY), 72);
-		::ReleaseDC(NULL, hdc);
-		lf.lfWeight = FW_NORMAL;
-		lf.lfCharSet = DEFAULT_CHARSET;
-		_tcscpy(lf.lfFaceName, m_prm->m_ld.GetFontFace());
-		
-		delete m_pFont;
-		m_pFont=new CFont();
-		m_pFont->CreateFontIndirect(&lf);
-
-		// change base dlg units
-		CalcBaseUnits(dt.m_pszFace, dt.m_wFontSize);
-	}
-	
-	if (!(GetLanguageUpdateOptions() & LDF_NODIALOGSIZE))
-	{
-		// dialog size
-		CRect rcWin;
-		GetWindowRect(&rcWin);
-		
-		CRect rcDialog(0, 0, dt.m_dlgTemplate.cx, dt.m_dlgTemplate.cy);
-		MapRect(&rcDialog);
-		rcDialog.bottom+=2*GetSystemMetrics(SM_CYDLGFRAME)+GetSystemMetrics(SM_CYCAPTION);
-
-		// correct the height by a menu height
-		if ((dt.m_wMenu != 0xffff) || ((dt.m_pszMenu != NULL) && _tcslen(dt.m_pszMenu) != 0))
-			rcDialog.bottom+=GetSystemMetrics(SM_CYMENU);
-
-		rcDialog.right+=2*GetSystemMetrics(SM_CXDLGFRAME);
-		rcDialog.OffsetRect(rcWin.CenterPoint().x-rcDialog.Width()/2, rcWin.CenterPoint().y-rcDialog.Height()/2);
-		
-		//TEMP
-		TRACE("Old dlg pos/size: x=%lu, y=%lu, cx=%lu, cy=%lu; \n\tNew dlg pos/size: x=%lu, y=%lu, cx=%lu, cy=%lu\n", rcWin.left, rcWin.top, rcWin.Width(), rcWin.Height(), rcDialog.left, rcDialog.top, rcDialog.Width(), rcDialog.Height());
-		SetWindowPos(NULL, rcDialog.left, rcDialog.top, rcDialog.Width(), rcDialog.Height(), SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE);
-	}
-	
-	// the controls
-	CWnd* pWnd;
-	vector<CDlgTemplate::_ITEM>::iterator it;
-	for (it=dt.m_vItems.begin();it != dt.m_vItems.end();it++)
-	{
-		// skip controls that cannot be modified
-		if ( (*it).m_itemTemplate.id == 0xffff || (pWnd=GetDlgItem((*it).m_itemTemplate.id)) == NULL)
-			continue;
-		
-		// the font
-		if (!(GetLanguageUpdateOptions() & LDF_NODIALOGFONT))
-			pWnd->SetFont(m_pFont, FALSE);
-		
-		// style&ex style
-		// modify only the rtl/ltr reading order
-		LONG lStyleEx=::GetWindowLong(pWnd->m_hWnd, GWL_EXSTYLE);
-		if (lStyleEx & WS_EX_RTLREADING)
-		{
-			if (!m_prm->m_ld.GetDirection())
-				lStyleEx &= ~WS_EX_RTLREADING;
-		}
-		else
-		{
-			if (m_prm->m_ld.GetDirection())
-				lStyleEx |= WS_EX_RTLREADING;
-		}
-		
-		::SetWindowLong(pWnd->m_hWnd, GWL_EXSTYLE, lStyleEx);
-		
-		// size
-		CRect rc((*it).m_itemTemplate.x, (*it).m_itemTemplate.y, (*it).m_itemTemplate.x+(*it).m_itemTemplate.cx, (*it).m_itemTemplate.y+(*it).m_itemTemplate.cy);
-		MapRect(&rc);
-		pWnd->SetWindowPos(NULL, rc.left, rc.top, rc.Width(), rc.Height(), SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE);
-		
-		// text/caption
-		if ( (*it).m_wClass == 0x0080 || (*it).m_wClass == 0x0082 || (*it).m_wClass == 0x0086 || ((*it).m_pszClass != NULL && _tcscmp((*it).m_pszClass, _T("STATICEX")) == 0) )
-			pWnd->SetWindowText(m_prm->LoadString((WORD)m_uiResID, (*it).m_itemTemplate.id));
-	}
-}
-
-///////////////////////////////////////////////////////////////
-// Helper function - does the cleanup after destroying the
-// dialog (that means releasing the instance lock, deleting
-// unused fonts and in some cases deleting itself).
-///////////////////////////////////////////////////////////////
-void CLanguageDialog::Cleanup()
-{
-	TRACE("CLanguageDialog::Cleanup()\n");
-
-	if (m_bLockChanged && m_pbLock)
-		*m_pbLock=false;
-
-	delete m_pFont;
-
-	if (m_bAutoDelete)
-		delete this;
-}
-
-///////////////////////////////////////////////////////////////
-// Standard msg - initializes tool tip handling
-///////////////////////////////////////////////////////////////
-BOOL CLanguageDialog::OnInitDialog()
-{
-	CDialog::OnInitDialog();
-
-	UpdateLanguage();		// because initially all the texts are empty
-
-	EnableToolTips(TRUE);
-
-	return TRUE;  // return TRUE unless you set the focus to a control
-	// EXCEPTION: OCX Property Pages should return FALSE
-}
-
-///////////////////////////////////////////////////////////////
-// Standard handler for pressing cancel button in a dialog.
-// For modeless dialog causes dialog to be destroyed.
-///////////////////////////////////////////////////////////////
-void CLanguageDialog::OnCancel() 
-{
-	switch (m_cType)
-	{
-	case 0:
-		CDialog::OnCancel();
-		break;
-	case 1:
-		DestroyWindow();
-		break;
-	}
-}
-
-///////////////////////////////////////////////////////////////
-// Standard handler for pressing OK button in a dialog.
-// For modeless dialog causes destruction of a dialog.
-///////////////////////////////////////////////////////////////
-void CLanguageDialog::OnOK()
-{
-	switch(m_cType)
-	{
-	case 0:
-		CDialog::OnOK();
-		break;
-	case 1:
-		DestroyWindow();
-		break;
-	}
-}
-
-///////////////////////////////////////////////////////////////
-// Standard override - calls cleanup.
-///////////////////////////////////////////////////////////////
-void CLanguageDialog::PostNcDestroy() 
-{
-	CDialog::PostNcDestroy();
-	Cleanup();
-}
-
-///////////////////////////////////////////////////////////////
-// This dialog's window procedure handler - look at ms docs.
-///////////////////////////////////////////////////////////////
-LRESULT CLanguageDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
-{
-	switch(message)
-	{
-	case WM_RMNOTIFY:
-		if ((UINT)wParam == RMNT_LANGCHANGE)
-		{
-			UpdateLanguage();
-
-			// now update user controls (everybody has to do it him(her)self)
-			OnLanguageChanged();
-			break;
-		}
-	case WM_NOTIFY:
-		{
-			NMHDR* pnmh=(NMHDR*)lParam;
-			if (pnmh->code == TTN_NEEDTEXT)
-			{
-				// establish the ID of a control
-				TOOLTIPTEXT *ppt=(TOOLTIPTEXT*)pnmh;
-				UINT nID;
-				if (ppt->uFlags & TTF_IDISHWND)
-					nID=(UINT)::GetDlgCtrlID((HWND)pnmh->idFrom);
-				else
-					nID=(UINT)pnmh->idFrom;
-
-				return OnTooltipText(nID, ppt);
-			}
-			break;
-		}
-	}
-
-	return CDialog::WindowProc(message, wParam, lParam);
-}
-
-///////////////////////////////////////////////////////////////
-// Helper function. Recalculates current sizes of a dialog base
-// units (font dependent) and stores in the internal members.
-// pszFacename [in] - font's face name.
-// wPointSize [in] - size of the font in points.
-///////////////////////////////////////////////////////////////
-void CLanguageDialog::CalcBaseUnits(PCTSTR pszFacename, WORD wPointSize)
-{
-	LOGFONT lf;
-	HDC hDC = ::GetDC(NULL);
-	memset(&lf, 0, sizeof(LOGFONT));
-	lf.lfHeight = -MulDiv(wPointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
-	lf.lfWeight = FW_NORMAL;
-	lf.lfCharSet = DEFAULT_CHARSET;
-	lstrcpy(lf.lfFaceName, pszFacename);
-
-	HFONT hNewFont = CreateFontIndirect(&lf);
-	if (hNewFont != NULL)
-	{
-		HFONT hFontOld = (HFONT)SelectObject(hDC, hNewFont);
-		TEXTMETRIC tm;
-		GetTextMetrics(hDC, &tm);
-		m_iBaseY = tm.tmHeight + tm.tmExternalLeading;
-		SIZE size;
-		::GetTextExtentPoint32(hDC, _T("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"), 52,	&size);
-		m_iBaseX = (size.cx + 26) / 52;
-		SelectObject(hDC, hFontOld);
-		DeleteObject(hNewFont);
-	}
-	else
-	{
-		// Could not create the font so just use the system's values
-		m_iBaseX = LOWORD(GetDialogBaseUnits());
-		m_iBaseY = HIWORD(GetDialogBaseUnits());
-	}
-	::ReleaseDC(NULL, hDC);
-}
-
-BOOL CLanguageDialog::OnHelpInfo(HELPINFO* pHelpInfo)
-{
-	if (pHelpInfo->iContextType == HELPINFO_WINDOW)
-	{
-		pHelpInfo->dwContextId=(m_uiResID << 16) | pHelpInfo->iCtrlId;
-		AfxGetApp()->HtmlHelp((DWORD_PTR)pHelpInfo, HH_DISPLAY_TEXT_POPUP);
-		return true;
-	}
-	else
-		return false;
-}
-
-void CLanguageDialog::OnContextMenu(CWnd* pWnd, CPoint point)
-{
-	HELPINFO hi;
-	hi.cbSize=sizeof(HELPINFO);
-	hi.iCtrlId=pWnd->GetDlgCtrlID();
-	hi.dwContextId=(m_uiResID << 16) | hi.iCtrlId;
-	hi.hItemHandle=pWnd->m_hWnd;
-	hi.iContextType=HELPINFO_WINDOW;
-	hi.MousePos=point;
-
-	AfxGetApp()->HtmlHelp((DWORD_PTR)&hi, HH_DISPLAY_TEXT_POPUP);
-}
-
-void CLanguageDialog::OnHelpButton() 
-{
-	AfxGetApp()->HtmlHelp(m_uiResID+0x20000, HH_HELP_CONTEXT);
-}
-
-END_ICTRANSLATE_NAMESPACE
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+#include "stdafx.h"
+#include "LanguageDialog.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+BEGIN_ICTRANSLATE_NAMESPACE
+
+/////////////////////////////////////////////////////////////////////////////
+// CDlgTemplate
+CDlgTemplate::CDlgTemplate(const DLGTEMPLATE* pDlgTemplate)
+{
+	Open(pDlgTemplate);
+}
+
+CDlgTemplate::CDlgTemplate(const DLGTEMPLATEEX* pDlgTemplate)
+{
+	Open((DLGTEMPLATE*)pDlgTemplate);
+}
+
+CDlgTemplate::~CDlgTemplate()
+{
+	delete [] m_pszMenu;
+	delete [] m_pszClass;
+	delete [] m_pszTitle;
+	delete [] m_pszFace;
+
+	// items
+	vector<_ITEM>::iterator it;
+	for (it=m_vItems.begin();it != m_vItems.end();it++)
+	{
+		delete [] (*it).m_pbyCreationData;
+		delete [] (*it).m_pszClass;
+		delete [] (*it).m_pszTitle;
+	}
+}
+
+bool CDlgTemplate::Open(const DLGTEMPLATE* pDlgTemplate)
+{
+	if (pDlgTemplate == NULL)
+		return false;
+	bool bExt=((DLGTEMPLATEEX*)pDlgTemplate)->signature == 0xffff;
+	const BYTE* pData=((BYTE*)pDlgTemplate);
+	if (bExt)
+	{
+		m_dlgTemplate=*((DLGTEMPLATEEX*)pDlgTemplate);
+		pData+=sizeof(DLGTEMPLATEEX);
+	}
+	else
+	{
+		ConvertDlgToEx(pDlgTemplate, &m_dlgTemplate);
+		pData+=sizeof(DLGTEMPLATE);
+	}
+	
+	// here is the menu, class and title
+	pData=ReadCompoundData(pData, &m_wMenu, &m_pszMenu);
+	pData=ReadCompoundData(pData, &m_wClass, &m_pszClass);
+	pData=ReadCompoundData(pData, &m_wTitle, &m_pszTitle);
+
+	// font
+	if (m_dlgTemplate.style & DS_SETFONT || m_dlgTemplate.style & DS_SHELLFONT)
+	{
+		m_wFontSize=*((WORD*)pData);
+		pData+=sizeof(WORD);
+		if (bExt)
+		{
+			m_wWeight=*((WORD*)pData);
+			pData+=sizeof(WORD);
+			m_byItalic=*((BYTE*)pData);
+			pData+=sizeof(BYTE);
+			m_byCharset=*((BYTE*)pData);
+			pData+=sizeof(BYTE);
+		}
+		else
+		{
+			m_wWeight=FW_NORMAL;
+			m_byItalic=FALSE;
+			m_byCharset=DEFAULT_CHARSET;
+		}
+		DWORD dwLen=(DWORD)wcslen((wchar_t*)pData);
+		m_pszFace=new TCHAR[dwLen+1];
+#ifdef _UNICODE
+		_tcscpy(m_pszFace, (wchar_t*)pData);
+#else
+		WideCharToMultiByte(CP_ACP, 0, (wchar_t*)pData, dwLen+1, m_pszFace, dwLen+1, NULL, NULL);
+#endif
+		pData+=(dwLen+1)*sizeof(wchar_t);
+	}
+	else
+	{
+		m_wFontSize=0xffff;
+		m_pszFace=NULL;
+	}
+
+	// items
+	_ITEM item;
+	for (int i=0;i<m_dlgTemplate.cDlgItems;i++)
+	{
+		// align to the nearest DWORD
+		pData=(BYTE*)((LONG_PTR)(pData + 3) & ~3);
+
+		// item
+		if (bExt)
+		{
+			item.m_itemTemplate=*((DLGITEMTEMPLATEEX*)pData);
+			pData+=sizeof(DLGITEMTEMPLATEEX);
+		}
+		else
+		{
+			ConvertItemToEx((DLGITEMTEMPLATE*)pData, &item.m_itemTemplate);
+			pData+=sizeof(DLGITEMTEMPLATE);
+		}
+
+		pData=ReadCompoundData(pData, &item.m_wClass, &item.m_pszClass);
+		if (item.m_wClass == 0xffff && item.m_pszClass != NULL)
+		{
+			// check the class strings and translate to atom values
+			if (_tcscmp(item.m_pszClass, _T("STATIC")) == 0)
+			{
+				item.m_wClass=0x0082;
+				delete [] item.m_pszClass;
+				item.m_pszClass=NULL;
+			}
+			else if (_tcscmp(item.m_pszClass, _T("BUTTON")) == 0)
+			{
+				item.m_wClass=0x0080;
+				delete [] item.m_pszClass;
+				item.m_pszClass=NULL;
+			}
+			else if (_tcscmp(item.m_pszClass, _T("EDIT")) == 0)
+			{
+				item.m_wClass=0x0081;
+				delete [] item.m_pszClass;
+				item.m_pszClass=NULL;
+			}
+			else if (_tcscmp(item.m_pszClass, _T("COMBOBOX")) == 0)
+			{
+				item.m_wClass=0x0085;
+				delete [] item.m_pszClass;
+				item.m_pszClass=NULL;
+			}
+			else if (_tcscmp(item.m_pszClass, _T("LISTBOX")) == 0)
+			{
+				item.m_wClass=0x0083;
+				delete [] item.m_pszClass;
+				item.m_pszClass=NULL;
+			}
+			else if (_tcscmp(item.m_pszClass, _T("SCROLLBAR")) == 0)
+			{
+				item.m_wClass=0x0084;
+				delete [] item.m_pszClass;
+				item.m_pszClass=NULL;
+			}
+		}
+		pData=ReadCompoundData(pData, &item.m_wTitle, &item.m_pszTitle);
+
+		// creation data
+		item.m_wCreationDataSize=(*((WORD*)pData));
+		pData+=sizeof(WORD);
+		if (item.m_wCreationDataSize > 0)
+		{
+			item.m_wCreationDataSize-=sizeof(WORD);
+			item.m_pbyCreationData=new BYTE[item.m_wCreationDataSize];
+			memcpy(item.m_pbyCreationData, pData, item.m_wCreationDataSize);
+		}
+		else
+			item.m_pbyCreationData=NULL;
+
+		m_vItems.push_back(item);
+	}
+
+	return true;
+}
+
+void CDlgTemplate::ConvertItemToEx(const DLGITEMTEMPLATE* pSrc, DLGITEMTEMPLATEEX* pDst)
+{
+	pDst->helpID=0;
+	pDst->exStyle=pSrc->dwExtendedStyle;
+	pDst->style=pSrc->style;
+	pDst->x=pSrc->x;
+	pDst->y=pSrc->y;
+	pDst->cx=pSrc->cx;
+	pDst->cy=pSrc->cy;
+	pDst->id=pSrc->id;
+}
+
+void CDlgTemplate::ConvertDlgToEx(const DLGTEMPLATE* pSrc, DLGTEMPLATEEX* pDst)
+{
+	pDst->dlgVer=1;
+	pDst->signature=0x0000;
+	pDst->helpID=(ULONG)0;
+	pDst->exStyle=pSrc->dwExtendedStyle;
+	pDst->style=pSrc->style;
+	pDst->cDlgItems=pSrc->cdit;
+	pDst->x=pSrc->x;
+	pDst->y=pSrc->y;
+	pDst->cx=pSrc->cx;
+	pDst->cy=pSrc->cy;
+}
+
+const BYTE* CDlgTemplate::ReadCompoundData(const BYTE* pBuffer, WORD* pwData, PTSTR* ppszStr)
+{
+	if (*((WORD*)pBuffer) == 0xffff)
+	{
+		*pwData=*((WORD*)(pBuffer+2));
+		*ppszStr=NULL;
+
+		return pBuffer+4;
+	}
+	else
+	{
+		*pwData=0xffff;
+		DWORD dwLen=(DWORD)wcslen((wchar_t*)pBuffer);
+		*ppszStr=new TCHAR[dwLen+1];
+#ifdef _UNICODE
+		_tcscpy(*ppszStr, (wchar_t*)pBuffer);
+#else
+		WideCharToMultiByte(CP_ACP, 0, (wchar_t*)pBuffer, dwLen+1, *ppszStr, dwLen+1, NULL, NULL);
+#endif
+		return pBuffer+(dwLen+1)*sizeof(wchar_t);
+	}
+
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// CLanguageDialog dialog
+
+BEGIN_MESSAGE_MAP(CLanguageDialog, CDialog)
+	ON_WM_HELPINFO()
+	ON_WM_CONTEXTMENU()
+	ON_BN_CLICKED(IDHELP, OnHelpButton)
+END_MESSAGE_MAP()
+
+
+CResourceManager *CLanguageDialog::m_prm=NULL;
+
+///////////////////////////////////////////////////////////////
+// Standard constructor
+// pLock [in] - specifies address of a bool value that'll be
+//		used to check if another instance of this window has
+//		already been shown. Should be declared in derived class
+//		as 'static bool m_xxx;' and initialized to 0.
+///////////////////////////////////////////////////////////////
+CLanguageDialog::CLanguageDialog(bool* pLock) : CDialog()
+{
+	m_pszResName=NULL;
+	m_uiResID=0;
+	m_pParent=NULL;
+	m_cType=-1;
+	m_bAutoDelete=false;
+	m_pFont=NULL;
+	m_pbLock=pLock;
+	m_bLockChanged=false;
+	m_bLockInstance=false;
+	m_iBaseX=m_iBaseY=0;
+	_ASSERT(m_prm);			// make sure the CLanguageDialog::SetResManager() has been called aready
+	if(m_prm)
+		m_prm->m_lhDialogs.push_back(this);
+}
+
+///////////////////////////////////////////////////////////////
+// Constructor that takes string based template name
+// lpszTemplateName [in] - specifies the template name to load
+//		and show as this dialog.
+// pParent [in] - logical (everyone knows)
+// pLock [in] - address of a bool for dialog instance checks
+///////////////////////////////////////////////////////////////
+CLanguageDialog::CLanguageDialog(PCTSTR lpszTemplateName, CWnd* pParent, bool* pLock) : CDialog()
+{
+	m_pszResName=lpszTemplateName;
+	if (IS_INTRESOURCE(lpszTemplateName))
+		m_uiResID=(WORD)lpszTemplateName;
+	else
+		m_uiResID=0;
+	m_pParent=pParent;
+	m_cType=-1;
+	m_bAutoDelete=false;
+	m_pFont=NULL;
+	m_pbLock=pLock;
+	m_bLockChanged=false;
+	m_bLockInstance=false;
+	m_iBaseX=m_iBaseY=0;
+	_ASSERT(m_prm);			// make sure the CLanguageDialog::SetResManager() has been called aready
+	if(m_prm)
+		m_prm->m_lhDialogs.push_back(this);
+}
+
+///////////////////////////////////////////////////////////////
+// Constructor that takes UINT based template name
+// uiIDTemplate [in] - specifies the template ID to load
+//		and show as this dialog.
+// pParent [in] - logical (everyone knows)
+// pLock [in] - address of a bool for dialog instance checks
+///////////////////////////////////////////////////////////////
+CLanguageDialog::CLanguageDialog(UINT uiIDTemplate, CWnd* pParent, bool* pLock) : CDialog()
+{
+	m_pszResName=MAKEINTRESOURCE(uiIDTemplate);
+	m_uiResID=uiIDTemplate;
+	m_pParent=pParent;
+	m_cType=-1;
+	m_bAutoDelete=false;
+	m_pFont=NULL;
+	m_pbLock=pLock;
+	m_bLockChanged=false;
+	m_bLockInstance=false;
+	m_iBaseX=m_iBaseY=0;
+	_ASSERT(m_prm);			// make sure the CLanguageDialog::SetResManager() has been called aready
+	if(m_prm)
+		m_prm->m_lhDialogs.push_back(this);
+}
+
+///////////////////////////////////////////////////////////////
+// Standard destructor
+// Removes itself from a list in CWinApp (not to get any window
+// messages anymore).
+///////////////////////////////////////////////////////////////
+CLanguageDialog::~CLanguageDialog()
+{
+	list<CWnd*>::iterator it=m_prm->m_lhDialogs.begin();
+	while (it != m_prm->m_lhDialogs.end())
+	{
+		if (*it == this)
+		{
+			m_prm->m_lhDialogs.erase(it);
+			break;
+		}
+
+		it++;
+	}
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// CLanguageDialog message handlers
+
+///////////////////////////////////////////////////////////////
+// Makes properly constructed dialog modal.
+// RetVal [out] - value returned by dialog proc
+///////////////////////////////////////////////////////////////
+INT_PTR CLanguageDialog::DoModal() 
+{
+	if (m_pszResName)
+	{
+		HGLOBAL hDialog=m_prm->LoadResource(RT_DIALOG, m_pszResName);
+		if (!InitModalIndirect(hDialog))
+			return -1;
+	}
+	m_cType=0;
+	return CDialog::DoModal();
+}
+
+///////////////////////////////////////////////////////////////
+// Creates (and shows probably) this constructed dialog.
+// RetVal [out] - if creation succeeded
+///////////////////////////////////////////////////////////////
+BOOL CLanguageDialog::Create() 
+{
+	_ASSERT(m_pszResName);		// nothing was set as a dialog template
+    
+	if (!m_bLockInstance || m_pbLock == NULL || !(*m_pbLock))
+	{
+		HGLOBAL hDialog=m_prm->LoadResource(RT_DIALOG, m_pszResName);
+
+		// modeless dialog
+		if (!CreateIndirect(hDialog, m_pParent))
+			return FALSE;
+
+		m_cType=1;
+		if (m_pbLock)
+		{
+			*m_pbLock=true;
+			m_bLockChanged=true;
+		}
+
+		return TRUE;
+	}
+	else
+	{
+		m_bLockChanged=false;
+		Cleanup();
+		return FALSE;
+	}
+}
+
+///////////////////////////////////////////////////////////////
+// Changes values based on dialog units into the values in
+// pixels. Change is based on std MapDialogRect if the language
+// hasn't been changed otf or takes current font into
+// consideration.
+// pRect [in/out] - on [in] - dialog units, on [out] - pixels
+///////////////////////////////////////////////////////////////
+void CLanguageDialog::MapRect(RECT* pRect)
+{
+	if (m_pFont)
+	{
+		pRect->left=MulDiv(pRect->left, m_iBaseX, 4);
+		pRect->right=MulDiv(pRect->right, m_iBaseX, 4);
+		pRect->top=MulDiv(pRect->top, m_iBaseY, 8);
+		pRect->bottom=MulDiv(pRect->bottom, m_iBaseY, 8);
+	}
+	else
+		MapDialogRect(pRect);
+}
+
+///////////////////////////////////////////////////////////////
+// Helper function - called when this dialog receives message
+// WM_RMNOTIFY (with WPARAM == RMNT_LANGCHANGE). Updates the
+// dialog with data from a new template. Passes params to
+// virtual function OnLanguageChanged.
+// wOldLang [in] - specifies the old language code
+// wNewLang [in] - specifies the new language code.
+///////////////////////////////////////////////////////////////
+void CLanguageDialog::UpdateLanguage()
+{
+	// cannot update for string based template
+	if (m_uiResID == 0)
+		return;
+
+	// set the title
+	SetWindowText(m_prm->LoadString((WORD)m_uiResID, 0));
+
+	// load the dialog template
+	CDlgTemplate dt;
+	if (!dt.Open(m_prm->LoadDialog(MAKEINTRESOURCE(m_uiResID))))
+	{
+		TRACE("Cannot open dialog template in UpdateLanguage\n");
+		return;
+	}
+
+	// update the menu
+	if (GetMenu())
+		m_prm->UpdateMenu(GetMenu()->m_hMenu, dt.m_wMenu);
+
+	// font
+	if (!(GetLanguageUpdateOptions() & LDF_NODIALOGFONT))
+	{
+		// dialog font
+		LOGFONT lf;
+		memset(&lf, 0, sizeof(LOGFONT));
+		HDC hdc=::GetDC(NULL);
+		lf.lfHeight = -MulDiv(m_prm->m_ld.GetPointSize(), GetDeviceCaps(hdc, LOGPIXELSY), 72);
+		::ReleaseDC(NULL, hdc);
+		lf.lfWeight = FW_NORMAL;
+		lf.lfCharSet = DEFAULT_CHARSET;
+		_tcscpy(lf.lfFaceName, m_prm->m_ld.GetFontFace());
+		
+		delete m_pFont;
+		m_pFont=new CFont();
+		m_pFont->CreateFontIndirect(&lf);
+
+		// change base dlg units
+		CalcBaseUnits(dt.m_pszFace, dt.m_wFontSize);
+	}
+	
+	if (!(GetLanguageUpdateOptions() & LDF_NODIALOGSIZE))
+	{
+		// dialog size
+		CRect rcWin;
+		GetWindowRect(&rcWin);
+		
+		CRect rcDialog(0, 0, dt.m_dlgTemplate.cx, dt.m_dlgTemplate.cy);
+		MapRect(&rcDialog);
+		rcDialog.bottom+=2*GetSystemMetrics(SM_CYDLGFRAME)+GetSystemMetrics(SM_CYCAPTION);
+
+		// correct the height by a menu height
+		if ((dt.m_wMenu != 0xffff) || ((dt.m_pszMenu != NULL) && _tcslen(dt.m_pszMenu) != 0))
+			rcDialog.bottom+=GetSystemMetrics(SM_CYMENU);
+
+		rcDialog.right+=2*GetSystemMetrics(SM_CXDLGFRAME);
+		rcDialog.OffsetRect(rcWin.CenterPoint().x-rcDialog.Width()/2, rcWin.CenterPoint().y-rcDialog.Height()/2);
+		
+		//TEMP
+		TRACE("Old dlg pos/size: x=%lu, y=%lu, cx=%lu, cy=%lu; \n\tNew dlg pos/size: x=%lu, y=%lu, cx=%lu, cy=%lu\n", rcWin.left, rcWin.top, rcWin.Width(), rcWin.Height(), rcDialog.left, rcDialog.top, rcDialog.Width(), rcDialog.Height());
+		SetWindowPos(NULL, rcDialog.left, rcDialog.top, rcDialog.Width(), rcDialog.Height(), SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE);
+	}
+	
+	// the controls
+	CWnd* pWnd;
+	vector<CDlgTemplate::_ITEM>::iterator it;
+	for (it=dt.m_vItems.begin();it != dt.m_vItems.end();it++)
+	{
+		// skip controls that cannot be modified
+		if ( (*it).m_itemTemplate.id == 0xffff || (pWnd=GetDlgItem((*it).m_itemTemplate.id)) == NULL)
+			continue;
+		
+		// the font
+		if (!(GetLanguageUpdateOptions() & LDF_NODIALOGFONT))
+			pWnd->SetFont(m_pFont, FALSE);
+		
+		// style&ex style
+		// modify only the rtl/ltr reading order
+		LONG lStyleEx=::GetWindowLong(pWnd->m_hWnd, GWL_EXSTYLE);
+		if (lStyleEx & WS_EX_RTLREADING)
+		{
+			if (!m_prm->m_ld.GetDirection())
+				lStyleEx &= ~WS_EX_RTLREADING;
+		}
+		else
+		{
+			if (m_prm->m_ld.GetDirection())
+				lStyleEx |= WS_EX_RTLREADING;
+		}
+		
+		::SetWindowLong(pWnd->m_hWnd, GWL_EXSTYLE, lStyleEx);
+		
+		// size
+		CRect rc((*it).m_itemTemplate.x, (*it).m_itemTemplate.y, (*it).m_itemTemplate.x+(*it).m_itemTemplate.cx, (*it).m_itemTemplate.y+(*it).m_itemTemplate.cy);
+		MapRect(&rc);
+		pWnd->SetWindowPos(NULL, rc.left, rc.top, rc.Width(), rc.Height(), SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE);
+		
+		// text/caption
+		if ( (*it).m_wClass == 0x0080 || (*it).m_wClass == 0x0082 || (*it).m_wClass == 0x0086 || ((*it).m_pszClass != NULL && _tcscmp((*it).m_pszClass, _T("STATICEX")) == 0) )
+			pWnd->SetWindowText(m_prm->LoadString((WORD)m_uiResID, (*it).m_itemTemplate.id));
+	}
+}
+
+///////////////////////////////////////////////////////////////
+// Helper function - does the cleanup after destroying the
+// dialog (that means releasing the instance lock, deleting
+// unused fonts and in some cases deleting itself).
+///////////////////////////////////////////////////////////////
+void CLanguageDialog::Cleanup()
+{
+	TRACE("CLanguageDialog::Cleanup()\n");
+
+	if (m_bLockChanged && m_pbLock)
+		*m_pbLock=false;
+
+	delete m_pFont;
+
+	if (m_bAutoDelete)
+		delete this;
+}
+
+///////////////////////////////////////////////////////////////
+// Standard msg - initializes tool tip handling
+///////////////////////////////////////////////////////////////
+BOOL CLanguageDialog::OnInitDialog()
+{
+	CDialog::OnInitDialog();
+
+	UpdateLanguage();		// because initially all the texts are empty
+
+	EnableToolTips(TRUE);
+
+	return TRUE;  // return TRUE unless you set the focus to a control
+	// EXCEPTION: OCX Property Pages should return FALSE
+}
+
+///////////////////////////////////////////////////////////////
+// Standard handler for pressing cancel button in a dialog.
+// For modeless dialog causes dialog to be destroyed.
+///////////////////////////////////////////////////////////////
+void CLanguageDialog::OnCancel() 
+{
+	switch (m_cType)
+	{
+	case 0:
+		CDialog::OnCancel();
+		break;
+	case 1:
+		DestroyWindow();
+		break;
+	}
+}
+
+///////////////////////////////////////////////////////////////
+// Standard handler for pressing OK button in a dialog.
+// For modeless dialog causes destruction of a dialog.
+///////////////////////////////////////////////////////////////
+void CLanguageDialog::OnOK()
+{
+	switch(m_cType)
+	{
+	case 0:
+		CDialog::OnOK();
+		break;
+	case 1:
+		DestroyWindow();
+		break;
+	}
+}
+
+///////////////////////////////////////////////////////////////
+// Standard override - calls cleanup.
+///////////////////////////////////////////////////////////////
+void CLanguageDialog::PostNcDestroy() 
+{
+	CDialog::PostNcDestroy();
+	Cleanup();
+}
+
+///////////////////////////////////////////////////////////////
+// This dialog's window procedure handler - look at ms docs.
+///////////////////////////////////////////////////////////////
+LRESULT CLanguageDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
+{
+	switch(message)
+	{
+	case WM_RMNOTIFY:
+		if ((UINT)wParam == RMNT_LANGCHANGE)
+		{
+			UpdateLanguage();
+
+			// now update user controls (everybody has to do it him(her)self)
+			OnLanguageChanged();
+			break;
+		}
+	case WM_NOTIFY:
+		{
+			NMHDR* pnmh=(NMHDR*)lParam;
+			if (pnmh->code == TTN_NEEDTEXT)
+			{
+				// establish the ID of a control
+				TOOLTIPTEXT *ppt=(TOOLTIPTEXT*)pnmh;
+				UINT nID;
+				if (ppt->uFlags & TTF_IDISHWND)
+					nID=(UINT)::GetDlgCtrlID((HWND)pnmh->idFrom);
+				else
+					nID=(UINT)pnmh->idFrom;
+
+				return OnTooltipText(nID, ppt);
+			}
+			break;
+		}
+	}
+
+	return CDialog::WindowProc(message, wParam, lParam);
+}
+
+///////////////////////////////////////////////////////////////
+// Helper function. Recalculates current sizes of a dialog base
+// units (font dependent) and stores in the internal members.
+// pszFacename [in] - font's face name.
+// wPointSize [in] - size of the font in points.
+///////////////////////////////////////////////////////////////
+void CLanguageDialog::CalcBaseUnits(PCTSTR pszFacename, WORD wPointSize)
+{
+	LOGFONT lf;
+	HDC hDC = ::GetDC(NULL);
+	memset(&lf, 0, sizeof(LOGFONT));
+	lf.lfHeight = -MulDiv(wPointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
+	lf.lfWeight = FW_NORMAL;
+	lf.lfCharSet = DEFAULT_CHARSET;
+	lstrcpy(lf.lfFaceName, pszFacename);
+
+	HFONT hNewFont = CreateFontIndirect(&lf);
+	if (hNewFont != NULL)
+	{
+		HFONT hFontOld = (HFONT)SelectObject(hDC, hNewFont);
+		TEXTMETRIC tm;
+		GetTextMetrics(hDC, &tm);
+		m_iBaseY = tm.tmHeight + tm.tmExternalLeading;
+		SIZE size;
+		::GetTextExtentPoint32(hDC, _T("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"), 52,	&size);
+		m_iBaseX = (size.cx + 26) / 52;
+		SelectObject(hDC, hFontOld);
+		DeleteObject(hNewFont);
+	}
+	else
+	{
+		// Could not create the font so just use the system's values
+		m_iBaseX = LOWORD(GetDialogBaseUnits());
+		m_iBaseY = HIWORD(GetDialogBaseUnits());
+	}
+	::ReleaseDC(NULL, hDC);
+}
+
+BOOL CLanguageDialog::OnHelpInfo(HELPINFO* pHelpInfo)
+{
+	if (pHelpInfo->iContextType == HELPINFO_WINDOW)
+	{
+		pHelpInfo->dwContextId=(m_uiResID << 16) | pHelpInfo->iCtrlId;
+		AfxGetApp()->HtmlHelp((DWORD_PTR)pHelpInfo, HH_DISPLAY_TEXT_POPUP);
+		return true;
+	}
+	else
+		return false;
+}
+
+void CLanguageDialog::OnContextMenu(CWnd* pWnd, CPoint point)
+{
+	HELPINFO hi;
+	hi.cbSize=sizeof(HELPINFO);
+	hi.iCtrlId=pWnd->GetDlgCtrlID();
+	hi.dwContextId=(m_uiResID << 16) | hi.iCtrlId;
+	hi.hItemHandle=pWnd->m_hWnd;
+	hi.iContextType=HELPINFO_WINDOW;
+	hi.MousePos=point;
+
+	AfxGetApp()->HtmlHelp((DWORD_PTR)&hi, HH_DISPLAY_TEXT_POPUP);
+}
+
+void CLanguageDialog::OnHelpButton() 
+{
+	AfxGetApp()->HtmlHelp(m_uiResID+0x20000, HH_HELP_CONTEXT);
+}
+
+END_ICTRANSLATE_NAMESPACE
Index: src/libictranslate/LanguageDialog.h
===================================================================
diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/libictranslate/LanguageDialog.h	(.../LanguageDialog.h)	(revision 4eceec553f29c0ba93452ffeb52a647204dc9fce)
+++ src/libictranslate/LanguageDialog.h	(.../LanguageDialog.h)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,211 +1,211 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-/*************************************************************************
-	CLanguageDialog template
-
-	Files: LanguageDialog.h, LanguageDialog.cpp
-	Author: Ixen Gerthannes
-	Usage:
-		Derive your class from CLanguageDialog instead of CDialog, change all
-		calls from CDialog to CLanguageDialog, change call to base constructor
-		so it can take language as parameter.
-	Creating dialog class:
-		- derive class from CLanguageDialog
-		- change all occurences of CDialog to CLanguageDialog
-		- change parameters list of your default constructor so it can take
-			language as parameter (WORD wLang)
-		- modify call to base class constructor by putting into it declared
-			wLang from your constructor
-	Displaying dialog box:
-		- declare object as your dialog class
-		- eventually set public member m_bAutoDelete to true if you're
-			creating dialog with operator new, and it should be
-			automatically deleted when closed
-		- call DoModal/Create/CreateModeless member function for
-			modal/modeless/mixed mode dialog
-	Members:
-		Constructors - as described in CDialog constructors - language
-						specifies resource language to load
-			CLanguageDialog();
-			CLanguageDialog(PCTSTR lpszTemplateName, CWnd* pParent = NULL);
-			CLanguageDialog(UINT uiIDTemplate, CWnd* pParent = NULL);
-		Functions:
-			int DoModal(); - like in CDialog
-			BOOL Create(); - creates modeless dialog box; this class
-				automatically handles DestroyWindow, and like
-			void Cleanup(); - function cleans unused data - use only when 
-				window object wasn't created yet (in Create() and earlier)
-			WORD GetCurrentLanguage() const; - retrieves current language
-				setting for this dialog
-		Attributes:
-			bool m_bAutoDelete; - specifies whether this dialog should be
-				deleted (by 'delete this') when closed.
-*************************************************************************/
-#pragma once
-
-#include "libictranslate.h"
-#include "ResourceManager.h"
-
-BEGIN_ICTRANSLATE_NAMESPACE
-
-#pragma pack(push, 1)
-struct DLGTEMPLATEEX
-{
-	WORD dlgVer;
-	WORD signature;
-	DWORD helpID;
-	DWORD exStyle;
-	DWORD style;
-	WORD cDlgItems;
-	short x;
-	short y;
-	short cx;
-	short cy;
-};
-
-struct DLGITEMTEMPLATEEX
-{
-	DWORD helpID;
-	DWORD exStyle;
-	DWORD style;
-	short x;
-	short y;
-	short cx;
-	short cy;
-	WORD id;
-	WORD __DUMMY__;
-};
-#pragma pack(pop)
-
-class CDlgTemplate
-{
-public:
-	CDlgTemplate() { m_wMenu=(WORD)-1; m_pszMenu=NULL; m_wClass=(WORD)-1; m_pszClass=NULL, m_wTitle=(WORD)-1; m_pszTitle=NULL; m_wFontSize=0; m_wWeight=0; m_byItalic=0; m_byCharset=0; m_pszFace=NULL; };
-	CDlgTemplate(const DLGTEMPLATE* pDlgTemplate);
-	CDlgTemplate(const DLGTEMPLATEEX* pDlgTemplate);
-	~CDlgTemplate();
-
-	bool Open(const DLGTEMPLATE* pDlgTemplate);
-
-protected:
-	void ConvertItemToEx(const DLGITEMTEMPLATE* pSrc, DLGITEMTEMPLATEEX* pDst);		// converts DLGITEMTEMPLATE to DLGITEMTEMPLATEEX
-	void ConvertDlgToEx(const DLGTEMPLATE* pSrc, DLGTEMPLATEEX* pDst);
-
-	const BYTE* ReadCompoundData(const BYTE* pBuffer, WORD* pwData, PTSTR* ppszStr);
-
-public:
-	struct _ITEM
-	{
-		DLGITEMTEMPLATEEX m_itemTemplate;
-		
-		WORD m_wClass;
-		TCHAR *m_pszClass;
-
-		WORD m_wTitle;
-		TCHAR *m_pszTitle;
-
-		WORD m_wCreationDataSize;
-		BYTE *m_pbyCreationData;
-	};
-	vector<_ITEM> m_vItems;
-
-	DLGTEMPLATEEX m_dlgTemplate;
-
-	WORD m_wMenu;
-	TCHAR *m_pszMenu;
-
-	WORD m_wClass;
-	TCHAR *m_pszClass;
-
-	WORD m_wTitle;		// always -1
-	TCHAR *m_pszTitle;		
-	
-	// font
-	WORD m_wFontSize;
-	WORD m_wWeight;
-	BYTE m_byItalic;
-	BYTE m_byCharset;
-	TCHAR *m_pszFace;
-};
-
-/////////////////////////////////////////////////////////////////////////////
-// CLanguageDialog dialog
-#define LDF_NODIALOGSIZE 0x01
-#define LDF_NODIALOGFONT 0x02
-
-class LIBICTRANSLATE_API CLanguageDialog : public CDialog
-{
-public:
-// Construction/destruction
-	CLanguageDialog(bool* pLock=NULL);
-	CLanguageDialog(PCTSTR lpszTemplateName, CWnd* pParent = NULL, bool* pLock=NULL);   // standard constructor
-	CLanguageDialog(UINT uiIDTemplate, CWnd* pParent = NULL, bool* pLock=NULL);   // standard constructor
-	
-	~CLanguageDialog();
-
-	// static members - initialize global pointer to a resource manager
-	static void SetResManager(CResourceManager* prm) { m_prm=prm; };
-
-	// creation
-	virtual INT_PTR DoModal();
-	virtual BOOL Create();
-
-	void MapRect(RECT* pRect);
-	CFont* GetFont() { return m_pFont ? m_pFont : ((CDialog*)this)->GetFont(); };
-
-	BOOL OnHelpInfo(HELPINFO* pHelpInfo);
-	void OnContextMenu(CWnd* pWnd, CPoint point);
-	void OnHelpButton();
-
-protected:
-	void UpdateLanguage();
-	virtual UINT GetLanguageUpdateOptions() { return 0; };
-	virtual void OnLanguageChanged() { };
-	void Cleanup();
-
-	virtual BOOL OnTooltipText(UINT /*uiID*/, TOOLTIPTEXT* /*pTip*/) { return FALSE; };
-	virtual BOOL OnInitDialog();
-	virtual void OnCancel();
-	virtual void OnOK();
-	virtual void PostNcDestroy();
-	virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
-
-	DECLARE_MESSAGE_MAP()
-private:
-	void CalcBaseUnits(PCTSTR pszFacename, WORD wPointSize);
-
-// Attributes
-public:
-	bool m_bAutoDelete;			// deletes this dialog when exiting
-	bool m_bLockInstance;		// allows only one instance of this dialog if set
-
-protected:
-	static CResourceManager* m_prm;		// points to the resource manager instance
-
-	bool *m_pbLock;				// dialog box instance lock system
-	bool m_bLockChanged;		// if this dialog changed the lock
-	PCTSTR m_pszResName;		// resource (string) name of the dialog template
-	UINT m_uiResID;				// resource ID if any of the dialog template
-	CWnd* m_pParent;			// parent window ptr
-	char m_cType;				// type of this dialog box
-	CFont* m_pFont;				// currently used font
-	int m_iBaseX, m_iBaseY;
-};
-
-END_ICTRANSLATE_NAMESPACE
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+/*************************************************************************
+	CLanguageDialog template
+
+	Files: LanguageDialog.h, LanguageDialog.cpp
+	Author: Ixen Gerthannes
+	Usage:
+		Derive your class from CLanguageDialog instead of CDialog, change all
+		calls from CDialog to CLanguageDialog, change call to base constructor
+		so it can take language as parameter.
+	Creating dialog class:
+		- derive class from CLanguageDialog
+		- change all occurences of CDialog to CLanguageDialog
+		- change parameters list of your default constructor so it can take
+			language as parameter (WORD wLang)
+		- modify call to base class constructor by putting into it declared
+			wLang from your constructor
+	Displaying dialog box:
+		- declare object as your dialog class
+		- eventually set public member m_bAutoDelete to true if you're
+			creating dialog with operator new, and it should be
+			automatically deleted when closed
+		- call DoModal/Create/CreateModeless member function for
+			modal/modeless/mixed mode dialog
+	Members:
+		Constructors - as described in CDialog constructors - language
+						specifies resource language to load
+			CLanguageDialog();
+			CLanguageDialog(PCTSTR lpszTemplateName, CWnd* pParent = NULL);
+			CLanguageDialog(UINT uiIDTemplate, CWnd* pParent = NULL);
+		Functions:
+			int DoModal(); - like in CDialog
+			BOOL Create(); - creates modeless dialog box; this class
+				automatically handles DestroyWindow, and like
+			void Cleanup(); - function cleans unused data - use only when 
+				window object wasn't created yet (in Create() and earlier)
+			WORD GetCurrentLanguage() const; - retrieves current language
+				setting for this dialog
+		Attributes:
+			bool m_bAutoDelete; - specifies whether this dialog should be
+				deleted (by 'delete this') when closed.
+*************************************************************************/
+#pragma once
+
+#include "libictranslate.h"
+#include "ResourceManager.h"
+
+BEGIN_ICTRANSLATE_NAMESPACE
+
+#pragma pack(push, 1)
+struct DLGTEMPLATEEX
+{
+	WORD dlgVer;
+	WORD signature;
+	DWORD helpID;
+	DWORD exStyle;
+	DWORD style;
+	WORD cDlgItems;
+	short x;
+	short y;
+	short cx;
+	short cy;
+};
+
+struct DLGITEMTEMPLATEEX
+{
+	DWORD helpID;
+	DWORD exStyle;
+	DWORD style;
+	short x;
+	short y;
+	short cx;
+	short cy;
+	WORD id;
+	WORD __DUMMY__;
+};
+#pragma pack(pop)
+
+class CDlgTemplate
+{
+public:
+	CDlgTemplate() { m_wMenu=(WORD)-1; m_pszMenu=NULL; m_wClass=(WORD)-1; m_pszClass=NULL, m_wTitle=(WORD)-1; m_pszTitle=NULL; m_wFontSize=0; m_wWeight=0; m_byItalic=0; m_byCharset=0; m_pszFace=NULL; };
+	CDlgTemplate(const DLGTEMPLATE* pDlgTemplate);
+	CDlgTemplate(const DLGTEMPLATEEX* pDlgTemplate);
+	~CDlgTemplate();
+
+	bool Open(const DLGTEMPLATE* pDlgTemplate);
+
+protected:
+	void ConvertItemToEx(const DLGITEMTEMPLATE* pSrc, DLGITEMTEMPLATEEX* pDst);		// converts DLGITEMTEMPLATE to DLGITEMTEMPLATEEX
+	void ConvertDlgToEx(const DLGTEMPLATE* pSrc, DLGTEMPLATEEX* pDst);
+
+	const BYTE* ReadCompoundData(const BYTE* pBuffer, WORD* pwData, PTSTR* ppszStr);
+
+public:
+	struct _ITEM
+	{
+		DLGITEMTEMPLATEEX m_itemTemplate;
+		
+		WORD m_wClass;
+		TCHAR *m_pszClass;
+
+		WORD m_wTitle;
+		TCHAR *m_pszTitle;
+
+		WORD m_wCreationDataSize;
+		BYTE *m_pbyCreationData;
+	};
+	vector<_ITEM> m_vItems;
+
+	DLGTEMPLATEEX m_dlgTemplate;
+
+	WORD m_wMenu;
+	TCHAR *m_pszMenu;
+
+	WORD m_wClass;
+	TCHAR *m_pszClass;
+
+	WORD m_wTitle;		// always -1
+	TCHAR *m_pszTitle;		
+	
+	// font
+	WORD m_wFontSize;
+	WORD m_wWeight;
+	BYTE m_byItalic;
+	BYTE m_byCharset;
+	TCHAR *m_pszFace;
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// CLanguageDialog dialog
+#define LDF_NODIALOGSIZE 0x01
+#define LDF_NODIALOGFONT 0x02
+
+class LIBICTRANSLATE_API CLanguageDialog : public CDialog
+{
+public:
+// Construction/destruction
+	CLanguageDialog(bool* pLock=NULL);
+	CLanguageDialog(PCTSTR lpszTemplateName, CWnd* pParent = NULL, bool* pLock=NULL);   // standard constructor
+	CLanguageDialog(UINT uiIDTemplate, CWnd* pParent = NULL, bool* pLock=NULL);   // standard constructor
+	
+	~CLanguageDialog();
+
+	// static members - initialize global pointer to a resource manager
+	static void SetResManager(CResourceManager* prm) { m_prm=prm; };
+
+	// creation
+	virtual INT_PTR DoModal();
+	virtual BOOL Create();
+
+	void MapRect(RECT* pRect);
+	CFont* GetFont() { return m_pFont ? m_pFont : ((CDialog*)this)->GetFont(); };
+
+	BOOL OnHelpInfo(HELPINFO* pHelpInfo);
+	void OnContextMenu(CWnd* pWnd, CPoint point);
+	void OnHelpButton();
+
+protected:
+	void UpdateLanguage();
+	virtual UINT GetLanguageUpdateOptions() { return 0; };
+	virtual void OnLanguageChanged() { };
+	void Cleanup();
+
+	virtual BOOL OnTooltipText(UINT /*uiID*/, TOOLTIPTEXT* /*pTip*/) { return FALSE; };
+	virtual BOOL OnInitDialog();
+	virtual void OnCancel();
+	virtual void OnOK();
+	virtual void PostNcDestroy();
+	virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
+
+	DECLARE_MESSAGE_MAP()
+private:
+	void CalcBaseUnits(PCTSTR pszFacename, WORD wPointSize);
+
+// Attributes
+public:
+	bool m_bAutoDelete;			// deletes this dialog when exiting
+	bool m_bLockInstance;		// allows only one instance of this dialog if set
+
+protected:
+	static CResourceManager* m_prm;		// points to the resource manager instance
+
+	bool *m_pbLock;				// dialog box instance lock system
+	bool m_bLockChanged;		// if this dialog changed the lock
+	PCTSTR m_pszResName;		// resource (string) name of the dialog template
+	UINT m_uiResID;				// resource ID if any of the dialog template
+	CWnd* m_pParent;			// parent window ptr
+	char m_cType;				// type of this dialog box
+	CFont* m_pFont;				// currently used font
+	int m_iBaseX, m_iBaseY;
+};
+
+END_ICTRANSLATE_NAMESPACE
Index: src/libictranslate/ResourceManager.cpp
===================================================================
diff -u -r945fdda3ea66a8ce8a09ee9307b04c3d79d518b3 -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/libictranslate/ResourceManager.cpp	(.../ResourceManager.cpp)	(revision 945fdda3ea66a8ce8a09ee9307b04c3d79d518b3)
+++ src/libictranslate/ResourceManager.cpp	(.../ResourceManager.cpp)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,1076 +1,1076 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-#include "stdafx.h"
-#include "ResourceManager.h"
-#include "../libicpf/exception.h"
-#include "../libicpf/cfg.h"
-#include "../libicpf/crc32.h"
-#include <assert.h>
-#include <sstream>
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
-BEGIN_ICTRANSLATE_NAMESPACE
-
-#define EMPTY_STRING _t("")
-
-CFormat::CFormat(const tchar_t* pszFormat) :
-	m_strText(pszFormat)
-{
-}
-
-CFormat::~CFormat()
-{
-}
-
-void CFormat::SetFormat(const tchar_t* pszFormat)
-{
-	m_strText = pszFormat;
-}
-
-CFormat& CFormat::SetParam(PCTSTR pszName, PCTSTR pszText)
-{
-	assert(pszName);
-	if(!pszName)
-		return *this;
-
-	size_t stLen = _tcslen(pszName);
-	tstring_t::size_type stPos = 0;
-	while((stPos = m_strText.find(pszName)) != tstring_t::npos)
-	{
-		m_strText.replace(stPos, stLen, pszText);
-	}
-
-	return *this;
-}
-
-CFormat& CFormat::SetParam(PCTSTR pszName, ull_t ullData)
-{
-	tchar_t szBuffer[64];
-	_sntprintf(szBuffer, 63, ULLFMT, ullData);
-	szBuffer[63] = _t('\0');
-
-	return SetParam(pszName, szBuffer);
-}
-
-CFormat& CFormat::SetParam(PCTSTR pszName, ll_t llData)
-{
-	tchar_t szBuffer[64];
-	_sntprintf(szBuffer, 63, LLFMT, llData);
-	szBuffer[63] = _t('\0');
-
-	return SetParam(pszName, szBuffer);
-}
-
-CFormat& CFormat::SetParam(PCTSTR pszName, ulong_t ulData)
-{
-	tchar_t szBuffer[64];
-	_sntprintf(szBuffer, 63, ULFMT, ulData);
-	szBuffer[63] = _t('\0');
-
-	return SetParam(pszName, szBuffer);
-}
-
-CFormat& CFormat::SetParam(PCTSTR pszName, uint_t uiData)
-{
-	tchar_t szBuffer[64];
-	_sntprintf(szBuffer, 63, UIFMT, uiData);
-	szBuffer[63] = _t('\0');
-
-	return SetParam(pszName, szBuffer);
-}
-
-CFormat& CFormat::SetParam(PCTSTR pszName, int_t iData)
-{
-	tchar_t szBuffer[64];
-	_sntprintf(szBuffer, 63, IFMT, iData);
-	szBuffer[63] = _t('\0');
-
-	return SetParam(pszName, szBuffer);
-}
-
-CFormat& CFormat::SetParam(PCTSTR pszName, bool bData)
-{
-	tchar_t szBuffer[64];
-	_sntprintf(szBuffer, 63, USFMT, (ushort_t)bData);
-	szBuffer[63] = _t('\0');
-
-	return SetParam(pszName, szBuffer);
-}
-
-CTranslationItem::CTranslationItem() :
-	m_pszText(NULL),
-	m_uiChecksum(0),
-	m_stTextLength(0)
-{
-}
-
-CTranslationItem::CTranslationItem(const tchar_t* pszText, uint_t uiChecksum) :
-	m_pszText(NULL),
-	m_stTextLength(0),
-	m_uiChecksum(uiChecksum)
-{
-	if(pszText)
-	{
-		m_stTextLength = _tcslen(pszText);
-		if(m_stTextLength > 0)
-		{
-			m_pszText = new tchar_t[m_stTextLength + 1];
-			_tcscpy(m_pszText, pszText);
-
-			UnescapeString();
-		}
-	}
-}
-
-CTranslationItem::~CTranslationItem()
-{
-	Clear();
-}
-
-CTranslationItem& CTranslationItem::operator=(const CTranslationItem& rSrc)
-{
-	if(this != &rSrc)
-	{
-		Clear();
-		if(rSrc.m_pszText)
-		{
-			m_stTextLength = rSrc.m_stTextLength;
-			if(m_stTextLength > 0)
-			{
-				m_pszText = new tchar_t[rSrc.m_stTextLength + 1];
-				_tcscpy(m_pszText, rSrc.m_pszText);
-			}
-		}
-		m_uiChecksum = rSrc.m_uiChecksum;
-	}
-
-	return *this;
-}
-
-void CTranslationItem::Clear()
-{
-	delete [] m_pszText;
-	m_pszText = NULL;
-	m_stTextLength = 0;
-	m_uiChecksum = 0;
-}
-
-void CTranslationItem::CalculateChecksum()
-{
-	if(m_pszText)
-		m_uiChecksum = icpf::crc32((const byte_t*)m_pszText, m_stTextLength*sizeof(tchar_t));
-	else
-		m_uiChecksum = 0;
-}
-
-const tchar_t* CTranslationItem::GetText() const
-{
-	return m_pszText ? m_pszText : _t("");
-}
-
-void CTranslationItem::SetText(const tchar_t* pszText, bool bUnescapeString)
-{
-	delete [] m_pszText;
-	if(pszText)
-	{
-		m_stTextLength = _tcslen(pszText);
-		if(m_stTextLength > 0)
-		{
-			m_pszText = new tchar_t[m_stTextLength + 1];
-			_tcscpy(m_pszText, pszText);
-			if(bUnescapeString)
-				UnescapeString();
-			return;
-		}
-	}
-
-	m_pszText = NULL;
-	m_stTextLength = 0;
-}
-
-void CTranslationItem::UnescapeString()
-{
-	if(!m_pszText)
-		return;
-
-	const tchar_t* pszIn = m_pszText;
-	tchar_t* pszOut = m_pszText;
-	while (*pszIn != 0)
-	{
-		if (*pszIn == _T('\\'))
-		{
-			pszIn++;
-			switch(*pszIn++)
-			{
-			case _T('t'):
-				*pszOut++ = _T('\t');
-				break;
-			case _T('r'):
-				*pszOut++ = _T('\r');
-				break;
-			case _T('n'):
-				*pszOut++ = _T('\n');
-				break;
-			default:
-				*pszOut++ = _T('\\');
-			}
-		}
-		else
-			*pszOut++ = *pszIn++;
-	}
-	*pszOut = _T('\0');
-}
-
-CTranslationItem::ECompareResult CTranslationItem::Compare(const CTranslationItem& rReferenceItem)
-{
-	if(!m_pszText || !rReferenceItem.m_pszText)
-		return eResult_Invalid;
-
-	if(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
-	std::set<tstring_t> setRefFmt;
-	if(!rReferenceItem.GetFormatStrings(setRefFmt))
-		return eResult_ContentWarning;
-
-	std::set<tstring_t> setThisFmt;
-	if(!GetFormatStrings(setThisFmt))
-		return eResult_ContentWarning;
-
-	if(setRefFmt != setThisFmt)
-		return eResult_ContentWarning;
-
-	return eResult_Valid;
-}
-
-bool CTranslationItem::GetFormatStrings(std::set<tstring_t>& setFmtStrings) const
-{
-	setFmtStrings.clear();
-
-	const tchar_t* pszData = m_pszText;
-	const tchar_t* pszNext = NULL;
-	const size_t stMaxFmt = 256;
-	tchar_t szFmt[stMaxFmt];
-	while((pszData = _tcschr(pszData, _t('%'))) != NULL)
-	{
-		pszData++;		// it works assuming the string is null-terminated
-
-		// search the end of fmt string
-		pszNext = pszData;
-		while(*pszNext && isalpha(*pszNext))
-			pszNext++;
-
-		// if we have bigger buffer needs than is available
-		if(pszNext - pszData >= stMaxFmt)
-			return false;
-
-		// copy data
-		_tcsncpy(szFmt, pszData, pszNext - pszData);
-		szFmt[pszNext - pszData] = _T('\0');
-
-		setFmtStrings.insert(tstring_t(szFmt));
-	}
-
-	return true;
-}
-
-CLangData::CLangData() :
-	m_pszFilename(NULL),
-	m_pszLngName(NULL),
-	m_pszFontFace(NULL),
-	m_wPointSize(0),
-	m_pszHelpName(NULL),
-	m_pszAuthor(NULL),
-	m_bRTL(false),
-	m_uiSectionID(0),
-	m_bUpdating(false),
-	m_bModified(false)
-{
-}
-
-CLangData::~CLangData()
-{
-	delete [] m_pszFilename;
-	delete [] m_pszLngName;
-	delete [] m_pszFontFace;
-	delete [] m_pszHelpName;
-	delete [] m_pszAuthor;
-}
-
-void CLangData::Clear()
-{
-	delete [] m_pszFilename;
-	m_pszFilename = NULL;
-	delete [] m_pszLngName;
-	m_pszLngName = NULL;
-	delete [] m_pszFontFace;
-	m_pszFontFace = NULL;
-	delete [] m_pszHelpName;
-	m_pszHelpName = NULL;
-	delete [] m_pszAuthor;
-	m_pszAuthor = NULL;
-	m_bModified = false;
-	m_bRTL = false;
-	m_bUpdating = false;
-	m_uiSectionID = 0;
-	m_wPointSize = 0;
-
-	m_mapTranslation.clear();
-}
-
-CLangData::CLangData(const CLangData& ld) :
-	m_pszFilename(NULL),
-	m_pszLngName(NULL),
-	m_pszFontFace(NULL),
-	m_pszHelpName(NULL),
-	m_pszAuthor(NULL),
-	m_bRTL(ld.m_bRTL),
-	m_bUpdating(ld.m_bUpdating),
-	m_uiSectionID(ld.m_uiSectionID),
-	m_wPointSize(ld.m_wPointSize),
-	m_bModified(false)
-{
-	SetFilename(ld.GetFilename(true));
-	SetLangName(ld.GetLangName());
-	SetFontFace(ld.GetFontFace());
-	SetPointSize(ld.GetPointSize());
-	SetDirection(ld.GetDirection());
-	SetHelpName(ld.GetHelpName());
-	SetAuthor(ld.GetAuthor());
-
-	m_mapTranslation.insert(ld.m_mapTranslation.begin(), ld.m_mapTranslation.end());
-}
-
-CLangData& CLangData::operator=(const CLangData& rSrc)
-{
-	if(this != &rSrc)
-	{
-		SetFilename(rSrc.GetFilename(true));
-		SetLangName(rSrc.GetLangName());
-		SetFontFace(rSrc.GetFontFace());
-		SetPointSize(rSrc.GetPointSize());
-		SetDirection(rSrc.GetDirection());
-		SetHelpName(rSrc.GetHelpName());
-		SetAuthor(rSrc.GetAuthor());
-		m_bRTL = rSrc.m_bRTL;
-		m_bUpdating = rSrc.m_bUpdating;
-		m_uiSectionID = rSrc.m_uiSectionID;
-		m_wPointSize = rSrc.m_wPointSize;
-		m_bModified = false;
-
-		m_mapTranslation.insert(rSrc.m_mapTranslation.begin(), rSrc.m_mapTranslation.end());
-	}
-
-	return *this;
-}
-
-bool CLangData::ReadInfo(PCTSTR pszFile)
-{
-	try
-	{
-		Clear();
-
-		icpf::config cfg(icpf::config::eIni);
-		const uint_t uiLangName = cfg.register_string(_T("Info/Lang Name"), _t(""));
-		const uint_t uiFontFace = cfg.register_string(_T("Info/Font Face"), _T(""));
-		const uint_t uiSize = cfg.register_signed_num(_T("Info/Size"), 0, 0, 0xffff);
-		const uint_t uiRTL = cfg.register_bool(_T("Info/RTL reading order"), false);
-		const uint_t uiHelpName = cfg.register_string(_T("Info/Help name"), _T(""));
-		const uint_t uiAuthor = cfg.register_string(_T("Info/Author"), _T(""));
-		cfg.read(pszFile);
-		
-		const tchar_t* psz = cfg.get_string(uiLangName);
-		if(!psz || psz[0] == _t('\0'))
-			return false;
-		SetLangName(psz);
-
-		psz = cfg.get_string(uiFontFace);
-		if(!psz || psz[0] == _t('\0'))
-			return false;
-		SetFontFace(psz);
-
-		ll_t ll = cfg.get_signed_num(uiSize);
-		if(ll == 0)
-			return false;
-		SetPointSize((WORD)ll);
-
-		SetDirection(cfg.get_bool(uiRTL));
-
-		psz = cfg.get_string(uiHelpName);
-		if(!psz || psz[0] == _t('\0'))
-			return false;
-		SetHelpName(psz);
-
-		psz = cfg.get_string(uiAuthor);
-		if(!psz || psz[0] == _t('\0'))
-			return false;
-		SetAuthor(psz);
-
-		SetFilename(pszFile);
-
-		m_bModified = false;
-
-		return true;
-	}
-	catch(...)
-	{
-		return false;
-	}
-}
-
-void CLangData::EnumAttributesCallback(bool bGroup, const tchar_t* pszName, const tchar_t* pszValue, ptr_t pData)
-{
-	CLangData* pLangData = (CLangData*)pData;
-	assert(pLangData);
-	assert(pszName);
-	if(!pLangData || !pszName)
-		return;
-
-	if(bGroup && _tcsicmp(pszName, _t("Info")) == 0)
-		return;
-	if(bGroup)
-	{
-		// new section - remember in member
-		pLangData->m_uiSectionID = _ttoi(pszName);
-	}
-	else
-	{
-		uint_t uiID = 0;
-		uint_t uiChecksum = 0;
-
-		// parse the pszName to get both the string id and checksum
-		const tchar_t* pszChecksum = _tcschr(pszName, _T('['));
-		if(pszChecksum == NULL)
-		{
-			TRACE(_T("Warning! Old-style translation string %s.\n"), pszName);
-
-			int iCount = _stscanf(pszName, UIFMT, &uiID);
-			if(iCount != 1)
-			{
-				TRACE(_T("Warning! Problem retrieving id from string '%s'\n"), pszName);
-				return;
-			}
-		}
-		else
-		{
-			int iCount = _stscanf(pszName, UIFMT _T("[0x%lx]"), &uiID, &uiChecksum);
-			if(iCount != 2)
-			{
-				TRACE(_T("Warning! Problem retrieving id/checksum from string '%s'\n"), pszName);
-				return;
-			}
-		}
-
-		uint_t uiKey = pLangData->m_uiSectionID << 16 | uiID;
-		translation_map::iterator itTranslation = pLangData->m_mapTranslation.end();
-		if(pLangData->m_bUpdating)
-		{
-			// check if the checksum exists and matches
-			itTranslation = pLangData->m_mapTranslation.find(uiKey);
-			if(itTranslation == pLangData->m_mapTranslation.end())
-			{
-				TRACE(_T("Warning! Superfluous entry %lu in processed language file\n"), uiKey);
-				return;		// entry not found - probably superfluous entry in the language file
-			}
-
-			if((*itTranslation).second.GetChecksum() != uiChecksum)
-			{
-				TRACE(_T("Warning! Invalid checksum for string ID %lu in processed language file\n"), uiKey);
-				return;		// entry has invalid checksum (older version of translation)
-			}
-		}
-		else
-		{
-			std::pair<translation_map::iterator, bool> pairTranslation = pLangData->m_mapTranslation.insert(translation_map::value_type(uiKey, CTranslationItem()));
-			itTranslation = pairTranslation.first;
-		}
-
-		assert(itTranslation != pLangData->m_mapTranslation.end());
-		if(itTranslation != pLangData->m_mapTranslation.end())
-		{
-			(*itTranslation).second.SetText(pszValue, true);
-			if(!pLangData->m_bUpdating)
-				(*itTranslation).second.SetChecksum(uiChecksum);
-		}
-	}
-}
-
-void CLangData::UnescapeString(tchar_t* pszData)
-{
-	tchar_t* pszOut = pszData;
-	while (*pszData != 0)
-	{
-		if (*pszData == _T('\\'))
-		{
-			pszData++;
-			switch(*pszData++)
-			{
-			case _T('t'):
-				*pszOut++ = _T('\t');
-				break;
-			case _T('r'):
-				*pszOut++ = _T('\r');
-				break;
-			case _T('n'):
-				*pszOut++ = _T('\n');
-				break;
-			default:
-				*pszOut++ = _T('\\');
-			}
-		}
-		else
-			*pszOut++ = *pszData++;
-	}
-	*pszOut = _T('\0');
-
-}
-
-bool CLangData::ReadTranslation(PCTSTR pszFile, bool bUpdateTranslation)
-{
-	try
-	{
-		if(!bUpdateTranslation)
-			Clear();
-
-		// load data from file
-		icpf::config cfg(icpf::config::eIni);
-		const uint_t uiLangName = cfg.register_string(_T("Info/Lang Name"), _t(""));
-		const uint_t uiFontFace = cfg.register_string(_T("Info/Font Face"), _T(""));
-		const uint_t uiSize = cfg.register_signed_num(_T("Info/Size"), 0, 0, 0xffff);
-		const uint_t uiRTL = cfg.register_bool(_T("Info/RTL reading order"), false);
-		const uint_t uiHelpName = cfg.register_string(_T("Info/Help name"), _T(""));
-		const uint_t uiAuthor = cfg.register_string(_T("Info/Author"), _T(""));
-		cfg.read(pszFile);
-
-		const tchar_t* psz = cfg.get_string(uiLangName);
-		if(!psz || psz[0] == _t('\0'))
-			return false;
-		SetLangName(psz);
-
-		psz = cfg.get_string(uiFontFace);
-		if(!psz || psz[0] == _t('\0'))
-			return false;
-		SetFontFace(psz);
-
-		ll_t ll = cfg.get_signed_num(uiSize);
-		if(ll == 0)
-			return false;
-		SetPointSize((WORD)ll);
-
-		SetDirection(cfg.get_bool(uiRTL));
-
-		psz = cfg.get_string(uiHelpName);
-		if(!psz || psz[0] == _t('\0'))
-			return false;
-		SetHelpName(psz);
-
-		psz = cfg.get_string(uiAuthor);
-		if(!psz || psz[0] == _t('\0'))
-			return false;
-		SetAuthor(psz);
-
-		m_bUpdating = bUpdateTranslation;
-		m_uiSectionID = 0;
-		if(!cfg.enum_properties(_t("*"), EnumAttributesCallback, this))
-		{
-			m_bUpdating = false;
-			return false;
-		}
-		m_bUpdating = false;
-
-		SetFilename(pszFile);
-
-		m_bModified = false;
-
-		return true;
-	}
-	catch(...)
-	{
-		return false;
-	}
-}
-
-void CLangData::WriteTranslation(PCTSTR pszPath)
-{
-	if(!IsValidDescription())
-		THROW(_t("Invalid translation information (author, name or point size)"), 0, 0, 0);
-
-	// real writing
-	const int iBufferSize = 256;
-	tchar_t szTemp[iBufferSize];
-
-	// load data from file
-	icpf::config cfg(icpf::config::eIni);
-	cfg.set_string(_t("Info/Lang Name"), m_pszLngName);
-	cfg.set_string(_T("Info/Font Face"), m_pszFontFace);
-	cfg.set_string(_T("Info/Size"), _itot(m_wPointSize, szTemp, 10));
-	cfg.set_string(_T("Info/RTL reading order"), m_bRTL ? _T("1") : _T("0"));
-	cfg.set_string(_T("Info/Help name"), m_pszHelpName);
-	cfg.set_string(_T("Info/Author"), m_pszAuthor);
-
-	tstring_t strText;
-	for(translation_map::iterator it = m_mapTranslation.begin(); it != m_mapTranslation.end(); it++)
-	{
-		uint_t uiKey = (*it).first;
-		_sntprintf(szTemp, iBufferSize - 1, UIFMT _T("/") UIFMT _T("[") UIXFMT _T("]"), (uiKey >> 16), uiKey & 0x0000ffff, (*it).second.GetChecksum());
-
-		strText = (*it).second.GetText();
-		tstring_t::size_type stPos;
-		while((stPos = strText.find_first_of(_t("\r\n\t"))) != tstring_t::npos)
-		{
-			switch(strText[stPos])
-			{
-			case _t('\r'):
-				strText.replace(stPos, 1, _t("\\r"));
-				break;
-			case _t('\n'):
-				strText.replace(stPos, 1, _t("\\n"));
-				break;
-			case _t('\t'):
-				strText.replace(stPos, 1, _t("\\t"));
-				break;
-			}
-		}
-
-		cfg.set_string(szTemp, strText.c_str());
-	}
-
-	if(pszPath == NULL)
-		pszPath = m_pszFilename;
-	else
-		SetFilename(pszPath);
-	cfg.write(pszPath);
-
-	m_bModified = false;
-}
-
-PCTSTR CLangData::GetString(WORD wHiID, WORD wLoID)
-{
-	translation_map::const_iterator it=m_mapTranslation.find((wHiID << 16) | wLoID);
-	if (it != m_mapTranslation.end())
-		return (*it).second.GetText();
-	else
-		return EMPTY_STRING;
-}
-
-void CLangData::EnumStrings(PFNENUMCALLBACK pfnCallback, ptr_t pData)
-{
-	for(translation_map::const_iterator iterTranslation = m_mapTranslation.begin(); iterTranslation != m_mapTranslation.end(); ++iterTranslation)
-	{
-		(*pfnCallback)((*iterTranslation).first, &(*iterTranslation).second, pData);
-	}
-}
-
-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<translation_map::iterator, bool> pairTranslation = m_mapTranslation.insert(std::make_pair(uiTranslationKey, CTranslationItem()));
-			if(pairTranslation.second)
-			{
-				m_bModified = true;
-				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_bModified = true;
-			m_mapTranslation.erase(iterTranslation++);
-		}
-		else
-			++iterTranslation;
-	}
-}
-
-void CLangData::SetFilename(PCTSTR psz)
-{
-	if (m_pszFilename)
-		delete [] m_pszFilename;
-
-	// copy
-	m_pszFilename=new TCHAR[_tcslen(psz)+1];
-	_tcscpy(m_pszFilename, psz);
-
-	m_bModified = true;
-}
-
-PCTSTR CLangData::GetFilename(bool bFullPath) const
-{
-	if (bFullPath)
-		return m_pszFilename;
-	else
-	{
-		if(m_pszFilename)
-		{
-			TCHAR *pszFnd=_tcsrchr(m_pszFilename, _T('\\'));
-			if (pszFnd)
-				return pszFnd+1;
-		}
-
-		return m_pszFilename;
-	}
-}
-
-void CLangData::SetLangName(PCTSTR psz)
-{
-	if (m_pszLngName)
-		delete [] m_pszLngName;
-	m_pszLngName=new TCHAR[_tcslen(psz)+1];
-	_tcscpy(m_pszLngName, psz);
-	m_bModified = true;
-}
-
-void CLangData::SetFontFace(PCTSTR psz)
-{
-	if (m_pszFontFace)
-		delete [] m_pszFontFace;
-	m_pszFontFace=new TCHAR[_tcslen(psz)+1];
-	_tcscpy(m_pszFontFace, psz);
-	m_bModified = true;
-}
-
-void CLangData::SetHelpName(PCTSTR psz)
-{
-	SetFnameData(&m_pszHelpName, psz);
-	m_bModified = true;
-}
-
-void CLangData::SetAuthor(PCTSTR psz)
-{
-	if (m_pszAuthor)
-		delete [] m_pszAuthor;
-	m_pszAuthor=new TCHAR[_tcslen(psz)+1];
-	_tcscpy(m_pszAuthor, psz);
-	m_bModified = true;
-}
-
-bool CLangData::IsValidDescription() const
-{
-	// basic sanity checks
-	if(!m_pszAuthor || m_pszAuthor[0] == _t('\0') ||
-		!m_pszLngName || m_pszLngName[0] == _t('\0') ||
-		!m_pszFontFace || m_pszFontFace[0] == _t('\0') ||
-		m_wPointSize == 0)
-		return false;
-	return true;
-}
-
-void CLangData::SetFnameData(PTSTR *ppszDst, PCTSTR pszSrc)
-{
-	if (*ppszDst)
-		delete [] (*ppszDst);
-	const TCHAR* pszLast=NULL;
-	if ( (pszLast=_tcsrchr(pszSrc, _T('\\'))) != NULL)
-		pszLast++;
-	else
-		pszLast=pszSrc;
-
-	// copy
-	*ppszDst=new TCHAR[_tcslen(pszLast)+1];
-	_tcscpy(*ppszDst, pszLast);
-}
-
-CResourceManager::CResourceManager() :
-	m_pfnCallback(NULL),
-	m_hRes(NULL)
-{
-	InitializeCriticalSection(&m_cs);
-}
-
-CResourceManager::~CResourceManager()
-{
-	DeleteCriticalSection(&m_cs);
-}
-
-void CResourceManager::Init(HMODULE hrc)
-{
-	m_hRes=hrc;
-}
-
-// requires the param with ending '\\'
-void CResourceManager::Scan(LPCTSTR pszFolder, vector<CLangData>* pvData)
-{
-	assert(pszFolder);
-	assert(pvData);
-	if(!pszFolder || !pvData)
-		return;
-
-	TCHAR szPath[_MAX_PATH];
-	_tcscpy(szPath, pszFolder);
-	_tcscat(szPath, _T("*.lng"));
-	
-	WIN32_FIND_DATA wfd;
-	HANDLE hFind=::FindFirstFile(szPath, &wfd);
-	BOOL bFound=TRUE;
-	CLangData ld;
-	while (bFound && hFind != INVALID_HANDLE_VALUE)
-	{
-		if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
-		{
-			_tcscpy(szPath, pszFolder);
-			_tcscat(szPath, wfd.cFileName);
-			if (ld.ReadInfo(szPath))
-				pvData->push_back(ld);
-		}
-
-		bFound=::FindNextFile(hFind, &wfd);
-	}
-
-	if (hFind != INVALID_HANDLE_VALUE)
-		::FindClose(hFind);
-}
-
-bool CResourceManager::SetLanguage(PCTSTR pszPath)
-{
-	bool bRet = false;
-	tchar_t szPath[_MAX_PATH];
-
-	// parse the path to allow reading the english language first
-	const tchar_t* pszBaseName = _t("english.lng");
-	if(_tcsstr(pszPath, pszBaseName) != NULL)
-	{
-		_tcscpy(szPath, pszPath);
-		pszPath = NULL;
-	}
-	else
-	{
-		const tchar_t* pszData = _tcsrchr(pszPath, _t('\\'));
-		if(pszData != NULL)
-		{
-			memset(szPath, 0, _MAX_PATH*sizeof(tchar_t));
-			_tcsncpy(szPath, pszPath, pszData - pszPath + 1);
-			szPath[_MAX_PATH - 1] = _T('\0');
-			_tcscat(szPath, pszBaseName);
-		}
-		else
-			_tcscpy(szPath, pszPath);
-	}
-
-	// and load everything
-	EnterCriticalSection(&m_cs);
-	try
-	{
-		bRet = m_ld.ReadTranslation(szPath);		// base language
-		if(bRet && pszPath)
-			bRet=m_ld.ReadTranslation(pszPath, true);	// real language
-	}
-	catch(...)
-	{
-		LeaveCriticalSection(&m_cs);
-		return false;
-	}
-	LeaveCriticalSection(&m_cs);
-	if (!bRet)
-		return false;
-	
-	// update registered dialog boxes
-	list<CWnd*>::iterator it=m_lhDialogs.begin();
-	while (it != m_lhDialogs.end())
-	{
-		if (::IsWindow((*it)->m_hWnd))
-			(*it)->PostMessage(WM_RMNOTIFY, RMNT_LANGCHANGE, 0);
-		it++;
-	}
-				
-	// send the notification stuff to the others
-	if (m_pfnCallback)
-		(*m_pfnCallback)(RMNT_LANGCHANGE);
-
-	return bRet;
-}
-
-HGLOBAL CResourceManager::LoadResource(LPCTSTR pszType, LPCTSTR pszName)
-{
-	EnterCriticalSection(&m_cs);
-
-	// find resource
-	HGLOBAL hRet=NULL;
-	HRSRC hr=FindResource(m_hRes, pszName, pszType);
-	if (hr)
-		hRet=::LoadResource(m_hRes, hr);
-
-	LeaveCriticalSection(&m_cs);
-	return hRet;
-}
-
-HACCEL CResourceManager::LoadAccelerators(LPCTSTR pszName)
-{
-	return ::LoadAccelerators(m_hRes, pszName);
-}
-
-HBITMAP CResourceManager::LoadBitmap(LPCTSTR pszName)
-{
-	return ::LoadBitmap(m_hRes, pszName);
-}
-
-HCURSOR CResourceManager::LoadCursor(LPCTSTR pszName)
-{
-	return ::LoadCursor(m_hRes, pszName);
-}
-
-HICON CResourceManager::LoadIcon(LPCTSTR pszName)
-{
-	return ::LoadIcon(m_hRes, pszName);
-}
-
-void CResourceManager::UpdateMenu(HMENU hMenu, WORD wMenuID)
-{
-	// change the strings inside the menu to the one from txt res file
-	int iCount=::GetMenuItemCount(hMenu);
-	MENUITEMINFO mif;
-	WORD wLoID;
-	TCHAR szItem[1024];
-	memset(szItem, 0, 1024);
-	for (int i=0;i<iCount;i++)
-	{
-		memset(&mif, 0, sizeof(MENUITEMINFO));
-		mif.cbSize=sizeof(MENUITEMINFO);
-		mif.dwTypeData=szItem;
-		mif.cch=1023;
-		mif.fMask=MIIM_FTYPE | MIIM_SUBMENU | MIIM_ID | MIIM_DATA | MIIM_STRING;
-		if (::GetMenuItemInfo(hMenu, i, TRUE, &mif))
-		{
-			// has sub items ?
-			if (mif.hSubMenu)
-				UpdateMenu(mif.hSubMenu, wMenuID);
-
-			// the menu item contains a string to update
-			if (mif.fType == MFT_STRING)
-			{
-				if (mif.hSubMenu)
-				{
-					if (mif.dwItemData != 0)
-						wLoID=(WORD)mif.dwItemData;		// already updated data
-					else
-					{
-						// fresh menu - try to update info from caption
-						wLoID=(WORD)_ttoi((PCTSTR)mif.dwTypeData);
-
-						// remember this info in item's private storage
-						MENUITEMINFO ii;
-						ii.cbSize=sizeof(MENUITEMINFO);
-						ii.fMask=MIIM_DATA;
-						::SetMenuItemInfo(hMenu, i, TRUE, &ii);
-					}
-				}
-				else
-					wLoID=(WORD)::GetMenuItemID(hMenu, i);
-
-				mif.fMask=MIIM_STRING | MIIM_FTYPE;
-				if (m_ld.GetDirection())
-					mif.fType |= MFT_RIGHTORDER;
-				else
-					mif.fType &= ~MFT_RIGHTORDER;
-				mif.dwTypeData=(LPTSTR)(m_ld.GetString(wMenuID, wLoID));
-				::SetMenuItemInfo(hMenu, i, TRUE, &mif);
-			}
-		}
-	}
-}
-
-HMENU CResourceManager::LoadMenu(LPCTSTR pszName)
-{
-	EnterCriticalSection(&m_cs);
-	HMENU hMenu=::LoadMenu(m_hRes, pszName);
-
-	if (hMenu && IS_INTRESOURCE(pszName))
-		UpdateMenu(hMenu, (WORD)pszName);
-
-	LeaveCriticalSection(&m_cs);
-	return hMenu;
-}
-
-LPDLGTEMPLATE CResourceManager::LoadDialog(LPCTSTR pszName)
-{
-	HGLOBAL hgl=LoadResource(RT_DIALOG, pszName);
-	DLGTEMPLATE *dlgt=(DLGTEMPLATE*)::LockResource(hgl);
-	return dlgt;
-}
-
-PCTSTR CResourceManager::LoadString(UINT uiID)
-{
-	EnterCriticalSection(&m_cs);
-	PCTSTR pszData=m_ld.GetString(0, (WORD)uiID);
-	LeaveCriticalSection(&m_cs);
-	
-	return pszData;
-}
-
-PCTSTR CResourceManager::LoadString(WORD wGroup, WORD wID)
-{
-	EnterCriticalSection(&m_cs);
-	PCTSTR pszData=m_ld.GetString(wGroup, wID);
-	LeaveCriticalSection(&m_cs);
-	return pszData;
-}
-
-PTSTR CResourceManager::LoadStringCopy(UINT uiID, PTSTR pszStr, UINT uiMax)
-{
-	EnterCriticalSection(&m_cs);
-	_tcsncpy(pszStr, m_ld.GetString(0, (WORD)uiID), uiMax-1);
-	pszStr[uiMax-1]=_T('\0');
-	LeaveCriticalSection(&m_cs);
-	return pszStr;
-}
-
-HANDLE CResourceManager::LoadImage(LPCTSTR lpszName, UINT uType, int cxDesired, int cyDesired, UINT fuLoad)
-{
-	EnterCriticalSection(&m_cs);
-
-	HANDLE hImg=::LoadImage(m_hRes, lpszName, uType, cxDesired, cyDesired, fuLoad);
-
-	LeaveCriticalSection(&m_cs);
-	return hImg;
-}
-
-END_ICTRANSLATE_NAMESPACE
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+#include "stdafx.h"
+#include "ResourceManager.h"
+#include "../libicpf/exception.h"
+#include "../libicpf/cfg.h"
+#include "../libicpf/crc32.h"
+#include <assert.h>
+#include <sstream>
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+BEGIN_ICTRANSLATE_NAMESPACE
+
+#define EMPTY_STRING _t("")
+
+CFormat::CFormat(const tchar_t* pszFormat) :
+	m_strText(pszFormat)
+{
+}
+
+CFormat::~CFormat()
+{
+}
+
+void CFormat::SetFormat(const tchar_t* pszFormat)
+{
+	m_strText = pszFormat;
+}
+
+CFormat& CFormat::SetParam(PCTSTR pszName, PCTSTR pszText)
+{
+	assert(pszName);
+	if(!pszName)
+		return *this;
+
+	size_t stLen = _tcslen(pszName);
+	tstring_t::size_type stPos = 0;
+	while((stPos = m_strText.find(pszName)) != tstring_t::npos)
+	{
+		m_strText.replace(stPos, stLen, pszText);
+	}
+
+	return *this;
+}
+
+CFormat& CFormat::SetParam(PCTSTR pszName, ull_t ullData)
+{
+	tchar_t szBuffer[64];
+	_sntprintf(szBuffer, 63, ULLFMT, ullData);
+	szBuffer[63] = _t('\0');
+
+	return SetParam(pszName, szBuffer);
+}
+
+CFormat& CFormat::SetParam(PCTSTR pszName, ll_t llData)
+{
+	tchar_t szBuffer[64];
+	_sntprintf(szBuffer, 63, LLFMT, llData);
+	szBuffer[63] = _t('\0');
+
+	return SetParam(pszName, szBuffer);
+}
+
+CFormat& CFormat::SetParam(PCTSTR pszName, ulong_t ulData)
+{
+	tchar_t szBuffer[64];
+	_sntprintf(szBuffer, 63, ULFMT, ulData);
+	szBuffer[63] = _t('\0');
+
+	return SetParam(pszName, szBuffer);
+}
+
+CFormat& CFormat::SetParam(PCTSTR pszName, uint_t uiData)
+{
+	tchar_t szBuffer[64];
+	_sntprintf(szBuffer, 63, UIFMT, uiData);
+	szBuffer[63] = _t('\0');
+
+	return SetParam(pszName, szBuffer);
+}
+
+CFormat& CFormat::SetParam(PCTSTR pszName, int_t iData)
+{
+	tchar_t szBuffer[64];
+	_sntprintf(szBuffer, 63, IFMT, iData);
+	szBuffer[63] = _t('\0');
+
+	return SetParam(pszName, szBuffer);
+}
+
+CFormat& CFormat::SetParam(PCTSTR pszName, bool bData)
+{
+	tchar_t szBuffer[64];
+	_sntprintf(szBuffer, 63, USFMT, (ushort_t)bData);
+	szBuffer[63] = _t('\0');
+
+	return SetParam(pszName, szBuffer);
+}
+
+CTranslationItem::CTranslationItem() :
+	m_pszText(NULL),
+	m_uiChecksum(0),
+	m_stTextLength(0)
+{
+}
+
+CTranslationItem::CTranslationItem(const tchar_t* pszText, uint_t uiChecksum) :
+	m_pszText(NULL),
+	m_stTextLength(0),
+	m_uiChecksum(uiChecksum)
+{
+	if(pszText)
+	{
+		m_stTextLength = _tcslen(pszText);
+		if(m_stTextLength > 0)
+		{
+			m_pszText = new tchar_t[m_stTextLength + 1];
+			_tcscpy(m_pszText, pszText);
+
+			UnescapeString();
+		}
+	}
+}
+
+CTranslationItem::~CTranslationItem()
+{
+	Clear();
+}
+
+CTranslationItem& CTranslationItem::operator=(const CTranslationItem& rSrc)
+{
+	if(this != &rSrc)
+	{
+		Clear();
+		if(rSrc.m_pszText)
+		{
+			m_stTextLength = rSrc.m_stTextLength;
+			if(m_stTextLength > 0)
+			{
+				m_pszText = new tchar_t[rSrc.m_stTextLength + 1];
+				_tcscpy(m_pszText, rSrc.m_pszText);
+			}
+		}
+		m_uiChecksum = rSrc.m_uiChecksum;
+	}
+
+	return *this;
+}
+
+void CTranslationItem::Clear()
+{
+	delete [] m_pszText;
+	m_pszText = NULL;
+	m_stTextLength = 0;
+	m_uiChecksum = 0;
+}
+
+void CTranslationItem::CalculateChecksum()
+{
+	if(m_pszText)
+		m_uiChecksum = icpf::crc32((const byte_t*)m_pszText, m_stTextLength*sizeof(tchar_t));
+	else
+		m_uiChecksum = 0;
+}
+
+const tchar_t* CTranslationItem::GetText() const
+{
+	return m_pszText ? m_pszText : _t("");
+}
+
+void CTranslationItem::SetText(const tchar_t* pszText, bool bUnescapeString)
+{
+	delete [] m_pszText;
+	if(pszText)
+	{
+		m_stTextLength = _tcslen(pszText);
+		if(m_stTextLength > 0)
+		{
+			m_pszText = new tchar_t[m_stTextLength + 1];
+			_tcscpy(m_pszText, pszText);
+			if(bUnescapeString)
+				UnescapeString();
+			return;
+		}
+	}
+
+	m_pszText = NULL;
+	m_stTextLength = 0;
+}
+
+void CTranslationItem::UnescapeString()
+{
+	if(!m_pszText)
+		return;
+
+	const tchar_t* pszIn = m_pszText;
+	tchar_t* pszOut = m_pszText;
+	while (*pszIn != 0)
+	{
+		if (*pszIn == _T('\\'))
+		{
+			pszIn++;
+			switch(*pszIn++)
+			{
+			case _T('t'):
+				*pszOut++ = _T('\t');
+				break;
+			case _T('r'):
+				*pszOut++ = _T('\r');
+				break;
+			case _T('n'):
+				*pszOut++ = _T('\n');
+				break;
+			default:
+				*pszOut++ = _T('\\');
+			}
+		}
+		else
+			*pszOut++ = *pszIn++;
+	}
+	*pszOut = _T('\0');
+}
+
+CTranslationItem::ECompareResult CTranslationItem::Compare(const CTranslationItem& rReferenceItem)
+{
+	if(!m_pszText || !rReferenceItem.m_pszText)
+		return eResult_Invalid;
+
+	if(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
+	std::set<tstring_t> setRefFmt;
+	if(!rReferenceItem.GetFormatStrings(setRefFmt))
+		return eResult_ContentWarning;
+
+	std::set<tstring_t> setThisFmt;
+	if(!GetFormatStrings(setThisFmt))
+		return eResult_ContentWarning;
+
+	if(setRefFmt != setThisFmt)
+		return eResult_ContentWarning;
+
+	return eResult_Valid;
+}
+
+bool CTranslationItem::GetFormatStrings(std::set<tstring_t>& setFmtStrings) const
+{
+	setFmtStrings.clear();
+
+	const tchar_t* pszData = m_pszText;
+	const tchar_t* pszNext = NULL;
+	const size_t stMaxFmt = 256;
+	tchar_t szFmt[stMaxFmt];
+	while((pszData = _tcschr(pszData, _t('%'))) != NULL)
+	{
+		pszData++;		// it works assuming the string is null-terminated
+
+		// search the end of fmt string
+		pszNext = pszData;
+		while(*pszNext && isalpha(*pszNext))
+			pszNext++;
+
+		// if we have bigger buffer needs than is available
+		if(pszNext - pszData >= stMaxFmt)
+			return false;
+
+		// copy data
+		_tcsncpy(szFmt, pszData, pszNext - pszData);
+		szFmt[pszNext - pszData] = _T('\0');
+
+		setFmtStrings.insert(tstring_t(szFmt));
+	}
+
+	return true;
+}
+
+CLangData::CLangData() :
+	m_pszFilename(NULL),
+	m_pszLngName(NULL),
+	m_pszFontFace(NULL),
+	m_wPointSize(0),
+	m_pszHelpName(NULL),
+	m_pszAuthor(NULL),
+	m_bRTL(false),
+	m_uiSectionID(0),
+	m_bUpdating(false),
+	m_bModified(false)
+{
+}
+
+CLangData::~CLangData()
+{
+	delete [] m_pszFilename;
+	delete [] m_pszLngName;
+	delete [] m_pszFontFace;
+	delete [] m_pszHelpName;
+	delete [] m_pszAuthor;
+}
+
+void CLangData::Clear()
+{
+	delete [] m_pszFilename;
+	m_pszFilename = NULL;
+	delete [] m_pszLngName;
+	m_pszLngName = NULL;
+	delete [] m_pszFontFace;
+	m_pszFontFace = NULL;
+	delete [] m_pszHelpName;
+	m_pszHelpName = NULL;
+	delete [] m_pszAuthor;
+	m_pszAuthor = NULL;
+	m_bModified = false;
+	m_bRTL = false;
+	m_bUpdating = false;
+	m_uiSectionID = 0;
+	m_wPointSize = 0;
+
+	m_mapTranslation.clear();
+}
+
+CLangData::CLangData(const CLangData& ld) :
+	m_pszFilename(NULL),
+	m_pszLngName(NULL),
+	m_pszFontFace(NULL),
+	m_pszHelpName(NULL),
+	m_pszAuthor(NULL),
+	m_bRTL(ld.m_bRTL),
+	m_bUpdating(ld.m_bUpdating),
+	m_uiSectionID(ld.m_uiSectionID),
+	m_wPointSize(ld.m_wPointSize),
+	m_bModified(false)
+{
+	SetFilename(ld.GetFilename(true));
+	SetLangName(ld.GetLangName());
+	SetFontFace(ld.GetFontFace());
+	SetPointSize(ld.GetPointSize());
+	SetDirection(ld.GetDirection());
+	SetHelpName(ld.GetHelpName());
+	SetAuthor(ld.GetAuthor());
+
+	m_mapTranslation.insert(ld.m_mapTranslation.begin(), ld.m_mapTranslation.end());
+}
+
+CLangData& CLangData::operator=(const CLangData& rSrc)
+{
+	if(this != &rSrc)
+	{
+		SetFilename(rSrc.GetFilename(true));
+		SetLangName(rSrc.GetLangName());
+		SetFontFace(rSrc.GetFontFace());
+		SetPointSize(rSrc.GetPointSize());
+		SetDirection(rSrc.GetDirection());
+		SetHelpName(rSrc.GetHelpName());
+		SetAuthor(rSrc.GetAuthor());
+		m_bRTL = rSrc.m_bRTL;
+		m_bUpdating = rSrc.m_bUpdating;
+		m_uiSectionID = rSrc.m_uiSectionID;
+		m_wPointSize = rSrc.m_wPointSize;
+		m_bModified = false;
+
+		m_mapTranslation.insert(rSrc.m_mapTranslation.begin(), rSrc.m_mapTranslation.end());
+	}
+
+	return *this;
+}
+
+bool CLangData::ReadInfo(PCTSTR pszFile)
+{
+	try
+	{
+		Clear();
+
+		icpf::config cfg(icpf::config::eIni);
+		const uint_t uiLangName = cfg.register_string(_T("Info/Lang Name"), _t(""));
+		const uint_t uiFontFace = cfg.register_string(_T("Info/Font Face"), _T(""));
+		const uint_t uiSize = cfg.register_signed_num(_T("Info/Size"), 0, 0, 0xffff);
+		const uint_t uiRTL = cfg.register_bool(_T("Info/RTL reading order"), false);
+		const uint_t uiHelpName = cfg.register_string(_T("Info/Help name"), _T(""));
+		const uint_t uiAuthor = cfg.register_string(_T("Info/Author"), _T(""));
+		cfg.read(pszFile);
+		
+		const tchar_t* psz = cfg.get_string(uiLangName);
+		if(!psz || psz[0] == _t('\0'))
+			return false;
+		SetLangName(psz);
+
+		psz = cfg.get_string(uiFontFace);
+		if(!psz || psz[0] == _t('\0'))
+			return false;
+		SetFontFace(psz);
+
+		ll_t ll = cfg.get_signed_num(uiSize);
+		if(ll == 0)
+			return false;
+		SetPointSize((WORD)ll);
+
+		SetDirection(cfg.get_bool(uiRTL));
+
+		psz = cfg.get_string(uiHelpName);
+		if(!psz || psz[0] == _t('\0'))
+			return false;
+		SetHelpName(psz);
+
+		psz = cfg.get_string(uiAuthor);
+		if(!psz || psz[0] == _t('\0'))
+			return false;
+		SetAuthor(psz);
+
+		SetFilename(pszFile);
+
+		m_bModified = false;
+
+		return true;
+	}
+	catch(...)
+	{
+		return false;
+	}
+}
+
+void CLangData::EnumAttributesCallback(bool bGroup, const tchar_t* pszName, const tchar_t* pszValue, ptr_t pData)
+{
+	CLangData* pLangData = (CLangData*)pData;
+	assert(pLangData);
+	assert(pszName);
+	if(!pLangData || !pszName)
+		return;
+
+	if(bGroup && _tcsicmp(pszName, _t("Info")) == 0)
+		return;
+	if(bGroup)
+	{
+		// new section - remember in member
+		pLangData->m_uiSectionID = _ttoi(pszName);
+	}
+	else
+	{
+		uint_t uiID = 0;
+		uint_t uiChecksum = 0;
+
+		// parse the pszName to get both the string id and checksum
+		const tchar_t* pszChecksum = _tcschr(pszName, _T('['));
+		if(pszChecksum == NULL)
+		{
+			TRACE(_T("Warning! Old-style translation string %s.\n"), pszName);
+
+			int iCount = _stscanf(pszName, UIFMT, &uiID);
+			if(iCount != 1)
+			{
+				TRACE(_T("Warning! Problem retrieving id from string '%s'\n"), pszName);
+				return;
+			}
+		}
+		else
+		{
+			int iCount = _stscanf(pszName, UIFMT _T("[0x%lx]"), &uiID, &uiChecksum);
+			if(iCount != 2)
+			{
+				TRACE(_T("Warning! Problem retrieving id/checksum from string '%s'\n"), pszName);
+				return;
+			}
+		}
+
+		uint_t uiKey = pLangData->m_uiSectionID << 16 | uiID;
+		translation_map::iterator itTranslation = pLangData->m_mapTranslation.end();
+		if(pLangData->m_bUpdating)
+		{
+			// check if the checksum exists and matches
+			itTranslation = pLangData->m_mapTranslation.find(uiKey);
+			if(itTranslation == pLangData->m_mapTranslation.end())
+			{
+				TRACE(_T("Warning! Superfluous entry %lu in processed language file\n"), uiKey);
+				return;		// entry not found - probably superfluous entry in the language file
+			}
+
+			if((*itTranslation).second.GetChecksum() != uiChecksum)
+			{
+				TRACE(_T("Warning! Invalid checksum for string ID %lu in processed language file\n"), uiKey);
+				return;		// entry has invalid checksum (older version of translation)
+			}
+		}
+		else
+		{
+			std::pair<translation_map::iterator, bool> pairTranslation = pLangData->m_mapTranslation.insert(translation_map::value_type(uiKey, CTranslationItem()));
+			itTranslation = pairTranslation.first;
+		}
+
+		assert(itTranslation != pLangData->m_mapTranslation.end());
+		if(itTranslation != pLangData->m_mapTranslation.end())
+		{
+			(*itTranslation).second.SetText(pszValue, true);
+			if(!pLangData->m_bUpdating)
+				(*itTranslation).second.SetChecksum(uiChecksum);
+		}
+	}
+}
+
+void CLangData::UnescapeString(tchar_t* pszData)
+{
+	tchar_t* pszOut = pszData;
+	while (*pszData != 0)
+	{
+		if (*pszData == _T('\\'))
+		{
+			pszData++;
+			switch(*pszData++)
+			{
+			case _T('t'):
+				*pszOut++ = _T('\t');
+				break;
+			case _T('r'):
+				*pszOut++ = _T('\r');
+				break;
+			case _T('n'):
+				*pszOut++ = _T('\n');
+				break;
+			default:
+				*pszOut++ = _T('\\');
+			}
+		}
+		else
+			*pszOut++ = *pszData++;
+	}
+	*pszOut = _T('\0');
+
+}
+
+bool CLangData::ReadTranslation(PCTSTR pszFile, bool bUpdateTranslation)
+{
+	try
+	{
+		if(!bUpdateTranslation)
+			Clear();
+
+		// load data from file
+		icpf::config cfg(icpf::config::eIni);
+		const uint_t uiLangName = cfg.register_string(_T("Info/Lang Name"), _t(""));
+		const uint_t uiFontFace = cfg.register_string(_T("Info/Font Face"), _T(""));
+		const uint_t uiSize = cfg.register_signed_num(_T("Info/Size"), 0, 0, 0xffff);
+		const uint_t uiRTL = cfg.register_bool(_T("Info/RTL reading order"), false);
+		const uint_t uiHelpName = cfg.register_string(_T("Info/Help name"), _T(""));
+		const uint_t uiAuthor = cfg.register_string(_T("Info/Author"), _T(""));
+		cfg.read(pszFile);
+
+		const tchar_t* psz = cfg.get_string(uiLangName);
+		if(!psz || psz[0] == _t('\0'))
+			return false;
+		SetLangName(psz);
+
+		psz = cfg.get_string(uiFontFace);
+		if(!psz || psz[0] == _t('\0'))
+			return false;
+		SetFontFace(psz);
+
+		ll_t ll = cfg.get_signed_num(uiSize);
+		if(ll == 0)
+			return false;
+		SetPointSize((WORD)ll);
+
+		SetDirection(cfg.get_bool(uiRTL));
+
+		psz = cfg.get_string(uiHelpName);
+		if(!psz || psz[0] == _t('\0'))
+			return false;
+		SetHelpName(psz);
+
+		psz = cfg.get_string(uiAuthor);
+		if(!psz || psz[0] == _t('\0'))
+			return false;
+		SetAuthor(psz);
+
+		m_bUpdating = bUpdateTranslation;
+		m_uiSectionID = 0;
+		if(!cfg.enum_properties(_t("*"), EnumAttributesCallback, this))
+		{
+			m_bUpdating = false;
+			return false;
+		}
+		m_bUpdating = false;
+
+		SetFilename(pszFile);
+
+		m_bModified = false;
+
+		return true;
+	}
+	catch(...)
+	{
+		return false;
+	}
+}
+
+void CLangData::WriteTranslation(PCTSTR pszPath)
+{
+	if(!IsValidDescription())
+		THROW(_t("Invalid translation information (author, name or point size)"), 0, 0, 0);
+
+	// real writing
+	const int iBufferSize = 256;
+	tchar_t szTemp[iBufferSize];
+
+	// load data from file
+	icpf::config cfg(icpf::config::eIni);
+	cfg.set_string(_t("Info/Lang Name"), m_pszLngName);
+	cfg.set_string(_T("Info/Font Face"), m_pszFontFace);
+	cfg.set_string(_T("Info/Size"), _itot(m_wPointSize, szTemp, 10));
+	cfg.set_string(_T("Info/RTL reading order"), m_bRTL ? _T("1") : _T("0"));
+	cfg.set_string(_T("Info/Help name"), m_pszHelpName);
+	cfg.set_string(_T("Info/Author"), m_pszAuthor);
+
+	tstring_t strText;
+	for(translation_map::iterator it = m_mapTranslation.begin(); it != m_mapTranslation.end(); it++)
+	{
+		uint_t uiKey = (*it).first;
+		_sntprintf(szTemp, iBufferSize - 1, UIFMT _T("/") UIFMT _T("[") UIXFMT _T("]"), (uiKey >> 16), uiKey & 0x0000ffff, (*it).second.GetChecksum());
+
+		strText = (*it).second.GetText();
+		tstring_t::size_type stPos;
+		while((stPos = strText.find_first_of(_t("\r\n\t"))) != tstring_t::npos)
+		{
+			switch(strText[stPos])
+			{
+			case _t('\r'):
+				strText.replace(stPos, 1, _t("\\r"));
+				break;
+			case _t('\n'):
+				strText.replace(stPos, 1, _t("\\n"));
+				break;
+			case _t('\t'):
+				strText.replace(stPos, 1, _t("\\t"));
+				break;
+			}
+		}
+
+		cfg.set_string(szTemp, strText.c_str());
+	}
+
+	if(pszPath == NULL)
+		pszPath = m_pszFilename;
+	else
+		SetFilename(pszPath);
+	cfg.write(pszPath);
+
+	m_bModified = false;
+}
+
+PCTSTR CLangData::GetString(WORD wHiID, WORD wLoID)
+{
+	translation_map::const_iterator it=m_mapTranslation.find((wHiID << 16) | wLoID);
+	if (it != m_mapTranslation.end())
+		return (*it).second.GetText();
+	else
+		return EMPTY_STRING;
+}
+
+void CLangData::EnumStrings(PFNENUMCALLBACK pfnCallback, ptr_t pData)
+{
+	for(translation_map::const_iterator iterTranslation = m_mapTranslation.begin(); iterTranslation != m_mapTranslation.end(); ++iterTranslation)
+	{
+		(*pfnCallback)((*iterTranslation).first, &(*iterTranslation).second, pData);
+	}
+}
+
+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<translation_map::iterator, bool> pairTranslation = m_mapTranslation.insert(std::make_pair(uiTranslationKey, CTranslationItem()));
+			if(pairTranslation.second)
+			{
+				m_bModified = true;
+				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_bModified = true;
+			m_mapTranslation.erase(iterTranslation++);
+		}
+		else
+			++iterTranslation;
+	}
+}
+
+void CLangData::SetFilename(PCTSTR psz)
+{
+	if (m_pszFilename)
+		delete [] m_pszFilename;
+
+	// copy
+	m_pszFilename=new TCHAR[_tcslen(psz)+1];
+	_tcscpy(m_pszFilename, psz);
+
+	m_bModified = true;
+}
+
+PCTSTR CLangData::GetFilename(bool bFullPath) const
+{
+	if (bFullPath)
+		return m_pszFilename;
+	else
+	{
+		if(m_pszFilename)
+		{
+			TCHAR *pszFnd=_tcsrchr(m_pszFilename, _T('\\'));
+			if (pszFnd)
+				return pszFnd+1;
+		}
+
+		return m_pszFilename;
+	}
+}
+
+void CLangData::SetLangName(PCTSTR psz)
+{
+	if (m_pszLngName)
+		delete [] m_pszLngName;
+	m_pszLngName=new TCHAR[_tcslen(psz)+1];
+	_tcscpy(m_pszLngName, psz);
+	m_bModified = true;
+}
+
+void CLangData::SetFontFace(PCTSTR psz)
+{
+	if (m_pszFontFace)
+		delete [] m_pszFontFace;
+	m_pszFontFace=new TCHAR[_tcslen(psz)+1];
+	_tcscpy(m_pszFontFace, psz);
+	m_bModified = true;
+}
+
+void CLangData::SetHelpName(PCTSTR psz)
+{
+	SetFnameData(&m_pszHelpName, psz);
+	m_bModified = true;
+}
+
+void CLangData::SetAuthor(PCTSTR psz)
+{
+	if (m_pszAuthor)
+		delete [] m_pszAuthor;
+	m_pszAuthor=new TCHAR[_tcslen(psz)+1];
+	_tcscpy(m_pszAuthor, psz);
+	m_bModified = true;
+}
+
+bool CLangData::IsValidDescription() const
+{
+	// basic sanity checks
+	if(!m_pszAuthor || m_pszAuthor[0] == _t('\0') ||
+		!m_pszLngName || m_pszLngName[0] == _t('\0') ||
+		!m_pszFontFace || m_pszFontFace[0] == _t('\0') ||
+		m_wPointSize == 0)
+		return false;
+	return true;
+}
+
+void CLangData::SetFnameData(PTSTR *ppszDst, PCTSTR pszSrc)
+{
+	if (*ppszDst)
+		delete [] (*ppszDst);
+	const TCHAR* pszLast=NULL;
+	if ( (pszLast=_tcsrchr(pszSrc, _T('\\'))) != NULL)
+		pszLast++;
+	else
+		pszLast=pszSrc;
+
+	// copy
+	*ppszDst=new TCHAR[_tcslen(pszLast)+1];
+	_tcscpy(*ppszDst, pszLast);
+}
+
+CResourceManager::CResourceManager() :
+	m_pfnCallback(NULL),
+	m_hRes(NULL)
+{
+	InitializeCriticalSection(&m_cs);
+}
+
+CResourceManager::~CResourceManager()
+{
+	DeleteCriticalSection(&m_cs);
+}
+
+void CResourceManager::Init(HMODULE hrc)
+{
+	m_hRes=hrc;
+}
+
+// requires the param with ending '\\'
+void CResourceManager::Scan(LPCTSTR pszFolder, vector<CLangData>* pvData)
+{
+	assert(pszFolder);
+	assert(pvData);
+	if(!pszFolder || !pvData)
+		return;
+
+	TCHAR szPath[_MAX_PATH];
+	_tcscpy(szPath, pszFolder);
+	_tcscat(szPath, _T("*.lng"));
+	
+	WIN32_FIND_DATA wfd;
+	HANDLE hFind=::FindFirstFile(szPath, &wfd);
+	BOOL bFound=TRUE;
+	CLangData ld;
+	while (bFound && hFind != INVALID_HANDLE_VALUE)
+	{
+		if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+		{
+			_tcscpy(szPath, pszFolder);
+			_tcscat(szPath, wfd.cFileName);
+			if (ld.ReadInfo(szPath))
+				pvData->push_back(ld);
+		}
+
+		bFound=::FindNextFile(hFind, &wfd);
+	}
+
+	if (hFind != INVALID_HANDLE_VALUE)
+		::FindClose(hFind);
+}
+
+bool CResourceManager::SetLanguage(PCTSTR pszPath)
+{
+	bool bRet = false;
+	tchar_t szPath[_MAX_PATH];
+
+	// parse the path to allow reading the english language first
+	const tchar_t* pszBaseName = _t("english.lng");
+	if(_tcsstr(pszPath, pszBaseName) != NULL)
+	{
+		_tcscpy(szPath, pszPath);
+		pszPath = NULL;
+	}
+	else
+	{
+		const tchar_t* pszData = _tcsrchr(pszPath, _t('\\'));
+		if(pszData != NULL)
+		{
+			memset(szPath, 0, _MAX_PATH*sizeof(tchar_t));
+			_tcsncpy(szPath, pszPath, pszData - pszPath + 1);
+			szPath[_MAX_PATH - 1] = _T('\0');
+			_tcscat(szPath, pszBaseName);
+		}
+		else
+			_tcscpy(szPath, pszPath);
+	}
+
+	// and load everything
+	EnterCriticalSection(&m_cs);
+	try
+	{
+		bRet = m_ld.ReadTranslation(szPath);		// base language
+		if(bRet && pszPath)
+			bRet=m_ld.ReadTranslation(pszPath, true);	// real language
+	}
+	catch(...)
+	{
+		LeaveCriticalSection(&m_cs);
+		return false;
+	}
+	LeaveCriticalSection(&m_cs);
+	if (!bRet)
+		return false;
+	
+	// update registered dialog boxes
+	list<CWnd*>::iterator it=m_lhDialogs.begin();
+	while (it != m_lhDialogs.end())
+	{
+		if (::IsWindow((*it)->m_hWnd))
+			(*it)->PostMessage(WM_RMNOTIFY, RMNT_LANGCHANGE, 0);
+		it++;
+	}
+				
+	// send the notification stuff to the others
+	if (m_pfnCallback)
+		(*m_pfnCallback)(RMNT_LANGCHANGE);
+
+	return bRet;
+}
+
+HGLOBAL CResourceManager::LoadResource(LPCTSTR pszType, LPCTSTR pszName)
+{
+	EnterCriticalSection(&m_cs);
+
+	// find resource
+	HGLOBAL hRet=NULL;
+	HRSRC hr=FindResource(m_hRes, pszName, pszType);
+	if (hr)
+		hRet=::LoadResource(m_hRes, hr);
+
+	LeaveCriticalSection(&m_cs);
+	return hRet;
+}
+
+HACCEL CResourceManager::LoadAccelerators(LPCTSTR pszName)
+{
+	return ::LoadAccelerators(m_hRes, pszName);
+}
+
+HBITMAP CResourceManager::LoadBitmap(LPCTSTR pszName)
+{
+	return ::LoadBitmap(m_hRes, pszName);
+}
+
+HCURSOR CResourceManager::LoadCursor(LPCTSTR pszName)
+{
+	return ::LoadCursor(m_hRes, pszName);
+}
+
+HICON CResourceManager::LoadIcon(LPCTSTR pszName)
+{
+	return ::LoadIcon(m_hRes, pszName);
+}
+
+void CResourceManager::UpdateMenu(HMENU hMenu, WORD wMenuID)
+{
+	// change the strings inside the menu to the one from txt res file
+	int iCount=::GetMenuItemCount(hMenu);
+	MENUITEMINFO mif;
+	WORD wLoID;
+	TCHAR szItem[1024];
+	memset(szItem, 0, 1024);
+	for (int i=0;i<iCount;i++)
+	{
+		memset(&mif, 0, sizeof(MENUITEMINFO));
+		mif.cbSize=sizeof(MENUITEMINFO);
+		mif.dwTypeData=szItem;
+		mif.cch=1023;
+		mif.fMask=MIIM_FTYPE | MIIM_SUBMENU | MIIM_ID | MIIM_DATA | MIIM_STRING;
+		if (::GetMenuItemInfo(hMenu, i, TRUE, &mif))
+		{
+			// has sub items ?
+			if (mif.hSubMenu)
+				UpdateMenu(mif.hSubMenu, wMenuID);
+
+			// the menu item contains a string to update
+			if (mif.fType == MFT_STRING)
+			{
+				if (mif.hSubMenu)
+				{
+					if (mif.dwItemData != 0)
+						wLoID=(WORD)mif.dwItemData;		// already updated data
+					else
+					{
+						// fresh menu - try to update info from caption
+						wLoID=(WORD)_ttoi((PCTSTR)mif.dwTypeData);
+
+						// remember this info in item's private storage
+						MENUITEMINFO ii;
+						ii.cbSize=sizeof(MENUITEMINFO);
+						ii.fMask=MIIM_DATA;
+						::SetMenuItemInfo(hMenu, i, TRUE, &ii);
+					}
+				}
+				else
+					wLoID=(WORD)::GetMenuItemID(hMenu, i);
+
+				mif.fMask=MIIM_STRING | MIIM_FTYPE;
+				if (m_ld.GetDirection())
+					mif.fType |= MFT_RIGHTORDER;
+				else
+					mif.fType &= ~MFT_RIGHTORDER;
+				mif.dwTypeData=(LPTSTR)(m_ld.GetString(wMenuID, wLoID));
+				::SetMenuItemInfo(hMenu, i, TRUE, &mif);
+			}
+		}
+	}
+}
+
+HMENU CResourceManager::LoadMenu(LPCTSTR pszName)
+{
+	EnterCriticalSection(&m_cs);
+	HMENU hMenu=::LoadMenu(m_hRes, pszName);
+
+	if (hMenu && IS_INTRESOURCE(pszName))
+		UpdateMenu(hMenu, (WORD)pszName);
+
+	LeaveCriticalSection(&m_cs);
+	return hMenu;
+}
+
+LPDLGTEMPLATE CResourceManager::LoadDialog(LPCTSTR pszName)
+{
+	HGLOBAL hgl=LoadResource(RT_DIALOG, pszName);
+	DLGTEMPLATE *dlgt=(DLGTEMPLATE*)::LockResource(hgl);
+	return dlgt;
+}
+
+PCTSTR CResourceManager::LoadString(UINT uiID)
+{
+	EnterCriticalSection(&m_cs);
+	PCTSTR pszData=m_ld.GetString(0, (WORD)uiID);
+	LeaveCriticalSection(&m_cs);
+	
+	return pszData;
+}
+
+PCTSTR CResourceManager::LoadString(WORD wGroup, WORD wID)
+{
+	EnterCriticalSection(&m_cs);
+	PCTSTR pszData=m_ld.GetString(wGroup, wID);
+	LeaveCriticalSection(&m_cs);
+	return pszData;
+}
+
+PTSTR CResourceManager::LoadStringCopy(UINT uiID, PTSTR pszStr, UINT uiMax)
+{
+	EnterCriticalSection(&m_cs);
+	_tcsncpy(pszStr, m_ld.GetString(0, (WORD)uiID), uiMax-1);
+	pszStr[uiMax-1]=_T('\0');
+	LeaveCriticalSection(&m_cs);
+	return pszStr;
+}
+
+HANDLE CResourceManager::LoadImage(LPCTSTR lpszName, UINT uType, int cxDesired, int cyDesired, UINT fuLoad)
+{
+	EnterCriticalSection(&m_cs);
+
+	HANDLE hImg=::LoadImage(m_hRes, lpszName, uType, cxDesired, cyDesired, fuLoad);
+
+	LeaveCriticalSection(&m_cs);
+	return hImg;
+}
+
+END_ICTRANSLATE_NAMESPACE
Index: src/libictranslate/ResourceManager.h
===================================================================
diff -u -r945fdda3ea66a8ce8a09ee9307b04c3d79d518b3 -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/libictranslate/ResourceManager.h	(.../ResourceManager.h)	(revision 945fdda3ea66a8ce8a09ee9307b04c3d79d518b3)
+++ src/libictranslate/ResourceManager.h	(.../ResourceManager.h)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,228 +1,228 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-#ifndef __RESOURCEMANAGER_H__
-#define __RESOURCEMANAGER_H__
-
-#include "libictranslate.h"
-#include <set>
-#include <map>
-#include <vector>
-#include <list>
-#include "../libicpf/gen_types.h"
-
-using namespace std;
-
-BEGIN_ICTRANSLATE_NAMESPACE
-
-/////////////////////////////////////////////////////////////////////////
-// types of notifications
-#define WM_RMNOTIFY (WM_USER + 2)
-
-// RMNT_LANGCHANGE, LPARAM - HIWORD - old language, LOWORD - new language
-#define RMNT_LANGCHANGE		0x0001
-
-typedef void(*PFNNOTIFYCALLBACK)(uint_t);
-
-class LIBICTRANSLATE_API CFormat
-{
-public:
-	CFormat() {};
-	CFormat(const tchar_t* pszFormat);
-	~CFormat();
-
-	void SetFormat(const tchar_t* pszFormat);
-
-	CFormat& SetParam(PCTSTR pszName, PCTSTR pszText);
-	CFormat& SetParam(PCTSTR pszName, ull_t ullData);
-	CFormat& SetParam(PCTSTR pszName, ll_t llData);
-	CFormat& SetParam(PCTSTR pszName, ulong_t ulData);
-	CFormat& SetParam(PCTSTR pszName, uint_t uiData);
-	CFormat& SetParam(PCTSTR pszName, int_t iData);
-	CFormat& SetParam(PCTSTR pszName, bool bData);
-
-	operator const tchar_t*() const { return m_strText.c_str(); }
-
-protected:
-	tstring_t m_strText;
-};
-
-///////////////////////////////////////////////////////////
-// language description structure
-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();
-
-	CTranslationItem& operator=(const CTranslationItem& rSrc);
-
-	void Clear();
-	void CalculateChecksum();
-
-	const tchar_t* GetText() const;
-	void SetText(const tchar_t* pszText, bool bUnescapeString);
-	uint_t GetChecksum() const { return m_uiChecksum; }
-	void SetChecksum(uint_t uiChecksum) { m_uiChecksum = uiChecksum; }
-
-	void UnescapeString();
-
-	ECompareResult Compare(const CTranslationItem& rReferenceItem);
-
-protected:
-	bool GetFormatStrings(std::set<tstring_t>& setFmtStrings) const;
-
-protected:
-	tchar_t* m_pszText;
-	size_t m_stTextLength;
-	uint_t m_uiChecksum;
-};
-
-typedef void(*PFNENUMCALLBACK)(uint_t, const CTranslationItem*, ptr_t);
-typedef std::map<uint_t, CTranslationItem> translation_map;
-
-class LIBICTRANSLATE_API CLangData
-{
-public:
-// construction/destruction
-	CLangData();
-	CLangData(const CLangData& ld);
-	~CLangData();
-
-	CLangData& operator=(const CLangData& rSrc);
-
-	void Clear();
-// operations
-	bool ReadInfo(PCTSTR pszFile);
-	bool ReadTranslation(PCTSTR pszFile, bool bReadBase = false);
-	void WriteTranslation(PCTSTR pszPath);
-
-// 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
-
-	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);
-	PCTSTR GetFilename(bool bFullPath) const;
-
-	void SetLangName(PCTSTR psz);
-	PCTSTR GetLangName() const { return m_pszLngName; };
-
-	void SetFontFace(PCTSTR psz);
-	PCTSTR GetFontFace() const { return m_pszFontFace; };
-
-	void SetPointSize(WORD wSize) { m_wPointSize=wSize; m_bModified = true; };
-	WORD GetPointSize() const { return m_wPointSize; };
-
-	void SetDirection(bool brtl) { m_bRTL=brtl; m_bModified = true; };
-	bool GetDirection() const { return m_bRTL; };
-
-	void SetHelpName(PCTSTR psz);
-	PCTSTR GetHelpName() const { return m_pszHelpName; };
-
-	void SetAuthor(PCTSTR psz);
-	PCTSTR GetAuthor() const { return m_pszAuthor; };
-
-	bool IsModified() const { return m_bModified; }
-	void SetModified() { m_bModified = true; }
-
-	bool IsValidDescription() const;
-protected:
-	void SetFnameData(PTSTR *ppszDst, PCTSTR pszSrc);
-	static void EnumAttributesCallback(bool bGroup, const tchar_t* pszName, const tchar_t* pszValue, ptr_t pData);
-	static void WriteAttributesCallback(bool bGroup, const tchar_t* pszName, const tchar_t* pszValue, ptr_t pData);
-	static void UnescapeString(tchar_t* pszData);
-
-protected:
-	TCHAR *m_pszFilename;		// file name of the language data (with path)
-	TCHAR *m_pszLngName;		// name of the language (ie. Chinese (PRC))
-	TCHAR *m_pszFontFace;		// face name of the font that will be used in dialogs
-	WORD m_wPointSize;		// font point size
-	TCHAR *m_pszHelpName;		// help name (wo the directory) for this language
-	TCHAR *m_pszAuthor;		// author name
-	bool m_bRTL;				// does the language require right-to-left reading order ?
-
-	// strings (for controls in dialog boxes the ID contains hi:dlg ID, lo:ctrl ID, for strings hi part is 0)
-	translation_map m_mapTranslation;		// maps string ID to the offset in pszStrings
-
-private:
-	uint_t m_uiSectionID;			///< ID of the currently processed section
-	bool m_bUpdating;				///< Are we updating the language with base language ?
-	bool m_bModified;				///< States if the translation has been modified
-};
-
-/////////////////////////////////////////////////////////////////////////////////////
-
-class LIBICTRANSLATE_API CResourceManager
-{
-public:
-	CResourceManager();
-	~CResourceManager();
-
-	void Init(HMODULE hrc);
-
-	void SetCallback(PFNNOTIFYCALLBACK pfn) { m_pfnCallback=pfn; };
-
-	void Scan(LPCTSTR pszFolder, vector<CLangData>* pvData);
-	bool SetLanguage(PCTSTR pszPath);
-
-	// loading functions
-	HGLOBAL LoadResource(LPCTSTR pszType, LPCTSTR pszName);
-	HACCEL LoadAccelerators(LPCTSTR pszName);
-	HBITMAP LoadBitmap(LPCTSTR pszName);
-	HCURSOR LoadCursor(LPCTSTR pszName);
-	HICON LoadIcon(LPCTSTR pszName);
-	HANDLE LoadImage(LPCTSTR lpszName, UINT uType, int cxDesired, int cyDesired, UINT fuLoad);
-	HMENU LoadMenu(LPCTSTR pszName);
-	LPDLGTEMPLATE LoadDialog(LPCTSTR pszName);
-
-	PCTSTR LoadString(UINT uiID);
-	PCTSTR LoadString(WORD wGroup, WORD wID);
-	PTSTR LoadStringCopy(UINT uiID, PTSTR pszStr, UINT uiMax);
-
-	// res updating functions
-	void UpdateMenu(HMENU hMenu, WORD wMenuID);
-
-	const CLangData* GetLanguageData() const { return &m_ld; }
-
-public:
-	CLangData m_ld;				// current language data
-	list<CWnd*> m_lhDialogs;	// currently displayed dialog boxes (even hidden)
-
-	uint_t m_uiNotificationMsgID;	// window message to send to windows
-	HMODULE m_hRes;
-	PFNNOTIFYCALLBACK m_pfnCallback;
-//	UINT m_uiMsg;
-	CRITICAL_SECTION m_cs;
-};
-
-END_ICTRANSLATE_NAMESPACE
-
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+#ifndef __RESOURCEMANAGER_H__
+#define __RESOURCEMANAGER_H__
+
+#include "libictranslate.h"
+#include <set>
+#include <map>
+#include <vector>
+#include <list>
+#include "../libicpf/gen_types.h"
+
+using namespace std;
+
+BEGIN_ICTRANSLATE_NAMESPACE
+
+/////////////////////////////////////////////////////////////////////////
+// types of notifications
+#define WM_RMNOTIFY (WM_USER + 2)
+
+// RMNT_LANGCHANGE, LPARAM - HIWORD - old language, LOWORD - new language
+#define RMNT_LANGCHANGE		0x0001
+
+typedef void(*PFNNOTIFYCALLBACK)(uint_t);
+
+class LIBICTRANSLATE_API CFormat
+{
+public:
+	CFormat() {};
+	CFormat(const tchar_t* pszFormat);
+	~CFormat();
+
+	void SetFormat(const tchar_t* pszFormat);
+
+	CFormat& SetParam(PCTSTR pszName, PCTSTR pszText);
+	CFormat& SetParam(PCTSTR pszName, ull_t ullData);
+	CFormat& SetParam(PCTSTR pszName, ll_t llData);
+	CFormat& SetParam(PCTSTR pszName, ulong_t ulData);
+	CFormat& SetParam(PCTSTR pszName, uint_t uiData);
+	CFormat& SetParam(PCTSTR pszName, int_t iData);
+	CFormat& SetParam(PCTSTR pszName, bool bData);
+
+	operator const tchar_t*() const { return m_strText.c_str(); }
+
+protected:
+	tstring_t m_strText;
+};
+
+///////////////////////////////////////////////////////////
+// language description structure
+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();
+
+	CTranslationItem& operator=(const CTranslationItem& rSrc);
+
+	void Clear();
+	void CalculateChecksum();
+
+	const tchar_t* GetText() const;
+	void SetText(const tchar_t* pszText, bool bUnescapeString);
+	uint_t GetChecksum() const { return m_uiChecksum; }
+	void SetChecksum(uint_t uiChecksum) { m_uiChecksum = uiChecksum; }
+
+	void UnescapeString();
+
+	ECompareResult Compare(const CTranslationItem& rReferenceItem);
+
+protected:
+	bool GetFormatStrings(std::set<tstring_t>& setFmtStrings) const;
+
+protected:
+	tchar_t* m_pszText;
+	size_t m_stTextLength;
+	uint_t m_uiChecksum;
+};
+
+typedef void(*PFNENUMCALLBACK)(uint_t, const CTranslationItem*, ptr_t);
+typedef std::map<uint_t, CTranslationItem> translation_map;
+
+class LIBICTRANSLATE_API CLangData
+{
+public:
+// construction/destruction
+	CLangData();
+	CLangData(const CLangData& ld);
+	~CLangData();
+
+	CLangData& operator=(const CLangData& rSrc);
+
+	void Clear();
+// operations
+	bool ReadInfo(PCTSTR pszFile);
+	bool ReadTranslation(PCTSTR pszFile, bool bReadBase = false);
+	void WriteTranslation(PCTSTR pszPath);
+
+// 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
+
+	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);
+	PCTSTR GetFilename(bool bFullPath) const;
+
+	void SetLangName(PCTSTR psz);
+	PCTSTR GetLangName() const { return m_pszLngName; };
+
+	void SetFontFace(PCTSTR psz);
+	PCTSTR GetFontFace() const { return m_pszFontFace; };
+
+	void SetPointSize(WORD wSize) { m_wPointSize=wSize; m_bModified = true; };
+	WORD GetPointSize() const { return m_wPointSize; };
+
+	void SetDirection(bool brtl) { m_bRTL=brtl; m_bModified = true; };
+	bool GetDirection() const { return m_bRTL; };
+
+	void SetHelpName(PCTSTR psz);
+	PCTSTR GetHelpName() const { return m_pszHelpName; };
+
+	void SetAuthor(PCTSTR psz);
+	PCTSTR GetAuthor() const { return m_pszAuthor; };
+
+	bool IsModified() const { return m_bModified; }
+	void SetModified() { m_bModified = true; }
+
+	bool IsValidDescription() const;
+protected:
+	void SetFnameData(PTSTR *ppszDst, PCTSTR pszSrc);
+	static void EnumAttributesCallback(bool bGroup, const tchar_t* pszName, const tchar_t* pszValue, ptr_t pData);
+	static void WriteAttributesCallback(bool bGroup, const tchar_t* pszName, const tchar_t* pszValue, ptr_t pData);
+	static void UnescapeString(tchar_t* pszData);
+
+protected:
+	TCHAR *m_pszFilename;		// file name of the language data (with path)
+	TCHAR *m_pszLngName;		// name of the language (ie. Chinese (PRC))
+	TCHAR *m_pszFontFace;		// face name of the font that will be used in dialogs
+	WORD m_wPointSize;		// font point size
+	TCHAR *m_pszHelpName;		// help name (wo the directory) for this language
+	TCHAR *m_pszAuthor;		// author name
+	bool m_bRTL;				// does the language require right-to-left reading order ?
+
+	// strings (for controls in dialog boxes the ID contains hi:dlg ID, lo:ctrl ID, for strings hi part is 0)
+	translation_map m_mapTranslation;		// maps string ID to the offset in pszStrings
+
+private:
+	uint_t m_uiSectionID;			///< ID of the currently processed section
+	bool m_bUpdating;				///< Are we updating the language with base language ?
+	bool m_bModified;				///< States if the translation has been modified
+};
+
+/////////////////////////////////////////////////////////////////////////////////////
+
+class LIBICTRANSLATE_API CResourceManager
+{
+public:
+	CResourceManager();
+	~CResourceManager();
+
+	void Init(HMODULE hrc);
+
+	void SetCallback(PFNNOTIFYCALLBACK pfn) { m_pfnCallback=pfn; };
+
+	void Scan(LPCTSTR pszFolder, vector<CLangData>* pvData);
+	bool SetLanguage(PCTSTR pszPath);
+
+	// loading functions
+	HGLOBAL LoadResource(LPCTSTR pszType, LPCTSTR pszName);
+	HACCEL LoadAccelerators(LPCTSTR pszName);
+	HBITMAP LoadBitmap(LPCTSTR pszName);
+	HCURSOR LoadCursor(LPCTSTR pszName);
+	HICON LoadIcon(LPCTSTR pszName);
+	HANDLE LoadImage(LPCTSTR lpszName, UINT uType, int cxDesired, int cyDesired, UINT fuLoad);
+	HMENU LoadMenu(LPCTSTR pszName);
+	LPDLGTEMPLATE LoadDialog(LPCTSTR pszName);
+
+	PCTSTR LoadString(UINT uiID);
+	PCTSTR LoadString(WORD wGroup, WORD wID);
+	PTSTR LoadStringCopy(UINT uiID, PTSTR pszStr, UINT uiMax);
+
+	// res updating functions
+	void UpdateMenu(HMENU hMenu, WORD wMenuID);
+
+	const CLangData* GetLanguageData() const { return &m_ld; }
+
+public:
+	CLangData m_ld;				// current language data
+	list<CWnd*> m_lhDialogs;	// currently displayed dialog boxes (even hidden)
+
+	uint_t m_uiNotificationMsgID;	// window message to send to windows
+	HMODULE m_hRes;
+	PFNNOTIFYCALLBACK m_pfnCallback;
+//	UINT m_uiMsg;
+	CRITICAL_SECTION m_cs;
+};
+
+END_ICTRANSLATE_NAMESPACE
+
 #endif
\ No newline at end of file
Index: src/libictranslate/dllmain.cpp
===================================================================
diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/libictranslate/dllmain.cpp	(.../dllmain.cpp)	(revision 4eceec553f29c0ba93452ffeb52a647204dc9fce)
+++ src/libictranslate/dllmain.cpp	(.../dllmain.cpp)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,69 +1,69 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-// dllmain.cpp : Defines the initialization routines for the DLL.
-//
-
-#include "stdafx.h"
-#include <afxwin.h>
-#include <afxdllx.h>
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
-static AFX_EXTENSION_MODULE libictranslateDLL = { NULL, NULL };
-
-extern "C" int APIENTRY
-DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
-{
-	// Remove this if you use lpReserved
-	UNREFERENCED_PARAMETER(lpReserved);
-
-	if (dwReason == DLL_PROCESS_ATTACH)
-	{
-		TRACE0("libictranslate.DLL Initializing!\n");
-		
-		// Extension DLL one-time initialization
-		if (!AfxInitExtensionModule(libictranslateDLL, hInstance))
-			return 0;
-
-		// Insert this DLL into the resource chain
-		// NOTE: If this Extension DLL is being implicitly linked to by
-		//  an MFC Regular DLL (such as an ActiveX Control)
-		//  instead of an MFC application, then you will want to
-		//  remove this line from DllMain and put it in a separate
-		//  function exported from this Extension DLL.  The Regular DLL
-		//  that uses this Extension DLL should then explicitly call that
-		//  function to initialize this Extension DLL.  Otherwise,
-		//  the CDynLinkLibrary object will not be attached to the
-		//  Regular DLL's resource chain, and serious problems will
-		//  result.
-
-		new CDynLinkLibrary(libictranslateDLL);
-
-	}
-	else if (dwReason == DLL_PROCESS_DETACH)
-	{
-		TRACE0("libictranslate.DLL Terminating!\n");
-
-		// Terminate the library before destructors are called
-		AfxTermExtensionModule(libictranslateDLL);
-	}
-	return 1;   // ok
-}
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+// dllmain.cpp : Defines the initialization routines for the DLL.
+//
+
+#include "stdafx.h"
+#include <afxwin.h>
+#include <afxdllx.h>
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+static AFX_EXTENSION_MODULE libictranslateDLL = { NULL, NULL };
+
+extern "C" int APIENTRY
+DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
+{
+	// Remove this if you use lpReserved
+	UNREFERENCED_PARAMETER(lpReserved);
+
+	if (dwReason == DLL_PROCESS_ATTACH)
+	{
+		TRACE0("libictranslate.DLL Initializing!\n");
+		
+		// Extension DLL one-time initialization
+		if (!AfxInitExtensionModule(libictranslateDLL, hInstance))
+			return 0;
+
+		// Insert this DLL into the resource chain
+		// NOTE: If this Extension DLL is being implicitly linked to by
+		//  an MFC Regular DLL (such as an ActiveX Control)
+		//  instead of an MFC application, then you will want to
+		//  remove this line from DllMain and put it in a separate
+		//  function exported from this Extension DLL.  The Regular DLL
+		//  that uses this Extension DLL should then explicitly call that
+		//  function to initialize this Extension DLL.  Otherwise,
+		//  the CDynLinkLibrary object will not be attached to the
+		//  Regular DLL's resource chain, and serious problems will
+		//  result.
+
+		new CDynLinkLibrary(libictranslateDLL);
+
+	}
+	else if (dwReason == DLL_PROCESS_DETACH)
+	{
+		TRACE0("libictranslate.DLL Terminating!\n");
+
+		// Terminate the library before destructors are called
+		AfxTermExtensionModule(libictranslateDLL);
+	}
+	return 1;   // ok
+}
Index: src/libictranslate/libictranslate.cpp
===================================================================
diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/libictranslate/libictranslate.cpp	(.../libictranslate.cpp)	(revision 4eceec553f29c0ba93452ffeb52a647204dc9fce)
+++ src/libictranslate/libictranslate.cpp	(.../libictranslate.cpp)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,28 +1,28 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-// libictranslate.cpp : Defines the initialization routines for the DLL.
-//
-
-#include "stdafx.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#endif
-
-
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+// libictranslate.cpp : Defines the initialization routines for the DLL.
+//
+
+#include "stdafx.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+
Index: src/libictranslate/libictranslate.h
===================================================================
diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/libictranslate/libictranslate.h	(.../libictranslate.h)	(revision 4eceec553f29c0ba93452ffeb52a647204dc9fce)
+++ src/libictranslate/libictranslate.h	(.../libictranslate.h)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,24 +1,24 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-#ifndef __LIBICTRANSLATE_H__
-#define __LIBICTRANSLATE_H__
-
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+#ifndef __LIBICTRANSLATE_H__
+#define __LIBICTRANSLATE_H__
+
 // import/export macros
 #if defined(_WIN32) || defined(_WIN64)
 	#ifdef LIBICTRANSLATE_EXPORTS
@@ -47,10 +47,10 @@
 	*/
 	#define LIBICTRANSLATE_API
 #endif
-
+
 /// Begins ch namespace
 #define BEGIN_ICTRANSLATE_NAMESPACE namespace ictranslate {
 /// Ends ch namespace
 #define END_ICTRANSLATE_NAMESPACE }
-
-#endif
+
+#endif
Index: src/libictranslate/resource.h
===================================================================
diff -u -rbee51aca3d5d9b67ecac4f528a3203738cc63455 -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/libictranslate/resource.h	(.../resource.h)	(revision bee51aca3d5d9b67ecac4f528a3203738cc63455)
+++ src/libictranslate/resource.h	(.../resource.h)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,16 +1,16 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by libictranslate.rc
-//
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-
-#define _APS_NEXT_RESOURCE_VALUE	3000
-#define _APS_NEXT_CONTROL_VALUE		3000
-#define _APS_NEXT_SYMED_VALUE		3000
-#define _APS_NEXT_COMMAND_VALUE		32771
-#endif
-#endif
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by libictranslate.rc
+//
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+
+#define _APS_NEXT_RESOURCE_VALUE	3000
+#define _APS_NEXT_CONTROL_VALUE		3000
+#define _APS_NEXT_SYMED_VALUE		3000
+#define _APS_NEXT_COMMAND_VALUE		32771
+#endif
+#endif
Index: src/libictranslate/stdafx.cpp
===================================================================
diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/libictranslate/stdafx.cpp	(.../stdafx.cpp)	(revision 4eceec553f29c0ba93452ffeb52a647204dc9fce)
+++ src/libictranslate/stdafx.cpp	(.../stdafx.cpp)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,25 +1,25 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-// stdafx.cpp : source file that includes just the standard includes
-// libictranslate.pch will be the pre-compiled header
-// stdafx.obj will contain the pre-compiled type information
-
-#include "stdafx.h"
-
-
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+// stdafx.cpp : source file that includes just the standard includes
+// libictranslate.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+
Index: src/libictranslate/stdafx.h
===================================================================
diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/libictranslate/stdafx.h	(.../stdafx.h)	(revision 4eceec553f29c0ba93452ffeb52a647204dc9fce)
+++ src/libictranslate/stdafx.h	(.../stdafx.h)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,57 +1,57 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-// stdafx.h : include file for standard system include files,
-// or project specific include files that are used frequently, but
-// are changed infrequently
-
-#pragma once
-
-#ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN            // Exclude rarely-used stuff from Windows headers
-#endif
-
-#include "targetver.h"
-
-#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // some CString constructors will be explicit
-
-#include <afxwin.h>         // MFC core and standard components
-#include <afxext.h>         // MFC extensions
-
-#ifndef _AFX_NO_OLE_SUPPORT
-#include <afxole.h>         // MFC OLE classes
-#include <afxodlgs.h>       // MFC OLE dialog classes
-#include <afxdisp.h>        // MFC Automation classes
-#endif // _AFX_NO_OLE_SUPPORT
-
-#ifndef _AFX_NO_DB_SUPPORT
-#include <afxdb.h>                      // MFC ODBC database classes
-#endif // _AFX_NO_DB_SUPPORT
-
-#ifndef _AFX_NO_DAO_SUPPORT
-#include <afxdao.h>                     // MFC DAO database classes
-#endif // _AFX_NO_DAO_SUPPORT
-
-#ifndef _AFX_NO_OLE_SUPPORT
-#include <afxdtctl.h>           // MFC support for Internet Explorer 4 Common Controls
-#endif
-#ifndef _AFX_NO_AFXCMN_SUPPORT
-#include <afxcmn.h>                     // MFC support for Windows Common Controls
-#endif // _AFX_NO_AFXCMN_SUPPORT
-
-
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+
+#pragma once
+
+#ifndef VC_EXTRALEAN
+#define VC_EXTRALEAN            // Exclude rarely-used stuff from Windows headers
+#endif
+
+#include "targetver.h"
+
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // some CString constructors will be explicit
+
+#include <afxwin.h>         // MFC core and standard components
+#include <afxext.h>         // MFC extensions
+
+#ifndef _AFX_NO_OLE_SUPPORT
+#include <afxole.h>         // MFC OLE classes
+#include <afxodlgs.h>       // MFC OLE dialog classes
+#include <afxdisp.h>        // MFC Automation classes
+#endif // _AFX_NO_OLE_SUPPORT
+
+#ifndef _AFX_NO_DB_SUPPORT
+#include <afxdb.h>                      // MFC ODBC database classes
+#endif // _AFX_NO_DB_SUPPORT
+
+#ifndef _AFX_NO_DAO_SUPPORT
+#include <afxdao.h>                     // MFC DAO database classes
+#endif // _AFX_NO_DAO_SUPPORT
+
+#ifndef _AFX_NO_OLE_SUPPORT
+#include <afxdtctl.h>           // MFC support for Internet Explorer 4 Common Controls
+#endif
+#ifndef _AFX_NO_AFXCMN_SUPPORT
+#include <afxcmn.h>                     // MFC support for Windows Common Controls
+#endif // _AFX_NO_AFXCMN_SUPPORT
+
+
Index: src/libictranslate/targetver.h
===================================================================
diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/libictranslate/targetver.h	(.../targetver.h)	(revision 4eceec553f29c0ba93452ffeb52a647204dc9fce)
+++ src/libictranslate/targetver.h	(.../targetver.h)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,44 +1,44 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-
-#pragma once
-
-// The following macros define the minimum required platform.  The minimum required platform
-// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 
-// your application.  The macros work by enabling all features available on platform versions up to and 
-// including the version specified.
-
-// Modify the following defines if you have to target a platform prior to the ones specified below.
-// Refer to MSDN for the latest info on corresponding values for different platforms.
-#ifndef WINVER                          // Specifies that the minimum required platform is Windows Vista.
-#define WINVER 0x0600           // Change this to the appropriate value to target other versions of Windows.
-#endif
-
-#ifndef _WIN32_WINNT            // Specifies that the minimum required platform is Windows Vista.
-#define _WIN32_WINNT 0x0600     // Change this to the appropriate value to target other versions of Windows.
-#endif
-
-#ifndef _WIN32_WINDOWS          // Specifies that the minimum required platform is Windows 98.
-#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
-#endif
-
-#ifndef _WIN32_IE                       // Specifies that the minimum required platform is Internet Explorer 7.0.
-#define _WIN32_IE 0x0700        // Change this to the appropriate value to target other versions of IE.
-#endif
-
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+
+#pragma once
+
+// The following macros define the minimum required platform.  The minimum required platform
+// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 
+// your application.  The macros work by enabling all features available on platform versions up to and 
+// including the version specified.
+
+// Modify the following defines if you have to target a platform prior to the ones specified below.
+// Refer to MSDN for the latest info on corresponding values for different platforms.
+#ifndef WINVER                          // Specifies that the minimum required platform is Windows Vista.
+#define WINVER 0x0600           // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#ifndef _WIN32_WINNT            // Specifies that the minimum required platform is Windows Vista.
+#define _WIN32_WINNT 0x0600     // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#ifndef _WIN32_WINDOWS          // Specifies that the minimum required platform is Windows 98.
+#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
+#endif
+
+#ifndef _WIN32_IE                       // Specifies that the minimum required platform is Internet Explorer 7.0.
+#define _WIN32_IE 0x0700        // Change this to the appropriate value to target other versions of IE.
+#endif
+
Index: src/rc2lng/rc.cpp
===================================================================
diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/rc2lng/rc.cpp	(.../rc.cpp)	(revision 4eceec553f29c0ba93452ffeb52a647204dc9fce)
+++ src/rc2lng/rc.cpp	(.../rc.cpp)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,597 +1,597 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-#include "stdafx.h"
-#include <vector>
-#include <map>
-#include <functional>
-#include <algorithm>
-#include "rc.h"
-#include "../libicpf/exception.h"
-#include "../libicpf/crc32.h"
-
-#define MAX_LINE 65536
-
-CRCFile::CRCFile() :
-	m_pszBuffer(new TCHAR[MAX_LINE])
-{
-	AddInitialValues();
-}
-
-CRCFile::~CRCFile()
-{
-	delete [] m_pszBuffer;
-}
-
-void CRCFile::ReadRC(PCTSTR pszFilename)
-{
-	// read file
-	CRCFile::ReadFile(pszFilename, m_vInRCFile, false);
-
-	// and process it
-	ProcessRCFile();
-}
-
-void CRCFile::ReadResourceIDs(PCTSTR pszFile)
-{
-	std::vector<CString> vLines;
-	CRCFile::ReadFile(pszFile, vLines, false);
-
-	long lLineNo = 0;
-	CString str, str2;
-	for(std::vector<CString>::iterator itLine = vLines.begin(); itLine != vLines.end(); ++itLine)
-	{
-		str = (*itLine);
-		str.TrimLeft(_T(" \t"));
-		if (str.Left(7) == _T("#define"))
-		{
-			str=str.Mid(8);
-			int iPos=str.FindOneOf(_T(" \t"));
-			str2=str.Left(iPos);
-			str=str.Mid(iPos);
-			str.TrimLeft(_T(" \t"));
-			str.TrimRight(_T(" \t\r\n"));
-
-			int iID;
-			if(str.Find(_T("x")) != -1)
-			{
-				// hex2dec
-				if(_stscanf(str, _T("%lx"), &iID) != 1)
-					THROW(icpf::exception::format(TSTRFMT _T("(%ld) : Error: Cannot parse hex number in line:\n") TSTRFMT, pszFile, lLineNo, m_pszBuffer), 0, 0, 0);
-			}
-			else
-				iID=_ttoi(str);
-
-			m_mapNameToID.insert(std::map<CString, UINT>::value_type(str2, iID));
-		}
-
-		++lLineNo;
-	}
-}
-
-void CRCFile::WriteRC(PCTSTR pszFilename)
-{
-	CRCFile::WriteFile(pszFilename, m_vOutRCFile, false);
-}
-
-void CRCFile::WriteLang(PCTSTR pszFilename, PCTSTR pszHeaderFile)
-{
-	// write header file to the output file
-	std::vector<CString> vData;
-	CRCFile::ReadFile(pszHeaderFile, vData, true);
-
-	// append the translation
-	CString str;
-	for(group_map::iterator itGroup = m_mapOutputLanguage.begin(); itGroup != m_mapOutputLanguage.end(); ++itGroup)
-	{
-		// write section header
-		AddTranslationLine(eLine_Group, (*itGroup).first, NULL, vData);
-
-		// and key=value assignment
-		element_map& rElementMap = (*itGroup).second;
-		for(element_map::iterator itElement = rElementMap.begin(); itElement != rElementMap.end(); ++itElement)
-		{
-			AddTranslationLine(eLine_Translation, (*itElement).first, (*itElement).second, vData);
-		}
-	}
-
-	CRCFile::WriteFile(pszFilename, vData, true);
-}
-
-void CRCFile::Clear()
-{
-	m_vInRCFile.clear();
-	m_vOutRCFile.clear();
-	m_mapNameToID.clear();
-	m_mapOutputLanguage.clear();
-
-	AddInitialValues();
-}
-
-void CRCFile::AddInitialValues()
-{
-	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDOK")), 1));
-	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDCANCEL")), 2));
-	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDABORT")), 3));
-	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDRETRY")), 4));
-	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDIGNORE")), 5));
-	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDYES")), 6));
-	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDNO")), 7));
-	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDCLOSE")), 8));
-	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDHELP")), 9));
-	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDTRYAGAIN")), 10));
-	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDCONTINUE")), 11));
-}
-
-int CRCFile::GetCommasCount(const CString& str)
-{
-	int cnt=0;
-	bool bInside=false;
-	for (int i=0;i<str.GetLength();i++)
-	{
-		if (str[i] == _T('\"'))
-			bInside=!bInside;
-
-		if (!bInside && str[i] == _T(','))
-			cnt++;
-	}
-
-	return cnt;
-}
-
-void CRCFile::AddTranslationLine(ELineType eLineType, UINT uiID, PCTSTR pszText, std::vector<CString>& vLines)
-{
-	switch(eLineType)
-	{
-	case eLine_Group:
-		{
-			CString str;
-			str.Format(_T("[") UIFMT _T("]"), uiID);
-			vLines.push_back(_T(""));
-			vLines.push_back(str);
-			break;
-		}
-	case eLine_Translation:
-		{
-			if(!pszText)
-				THROW(_T("Error: Invalid string."), 0, 0, 0);
-			if(pszText[0] != _T('\0'))
-			{
-				CString str;
-				str.Format(UIFMT _T("[") UIXFMT _T("]=") TSTRFMT, uiID, icpf::crc32((const byte_t*)pszText, _tcslen(pszText)*sizeof(TCHAR)), pszText);
-				vLines.push_back(str);
-			}
-			break;
-		}
-	default:
-		{
-			_ASSERTE(FALSE);
-			THROW(_T("Error: Unknown line type."), 0, 0, 0);
-		}
-	}
-}
-
-void CRCFile::ReadFile(PCTSTR pszFile, std::vector<CString>& rLines, bool bUnicode)
-{
-	// load file
-	FILE* pFile = _tfopen(pszFile, bUnicode ? _T("rb") : _T("rt"));
-	if(!pFile)
-		THROW(icpf::exception::format(_T("Error: Cannot open file: ") TSTRFMT, pszFile), 0, errno, 0);
-
-	CString str;
-	while(_fgetts(str.GetBufferSetLength(MAX_LINE), MAX_LINE, pFile))
-	{
-		str.ReleaseBuffer();
-		str.TrimRight(_T("\r\n"));
-		rLines.push_back(str);
-	}
-	str.ReleaseBuffer();
-
-	fclose(pFile);
-}
-
-void CRCFile::WriteFile(PCTSTR pszFile, const std::vector<CString>& rLines, bool bUnicode)
-{
-	FILE* pFile = _tfopen(pszFile, bUnicode ? _T("wb") : _T("wt"));
-	if(!pFile)
-		THROW(icpf::exception::format(_T("Error: Cannot open file: ") TSTRFMT _T(" for writing."), pszFile), 0, errno, 0);
-
-	for (std::vector<CString>::const_iterator it=rLines.begin();it != rLines.end();it++)
-	{
-		CString str = (*it);
-		str += _T("\r\n");
-		if(_fputts((PCTSTR)str, pFile) < 0)
-			THROW(icpf::exception::format(_T("Cannot write data to file ") TSTRFMT, pszFile), 0, errno, 0);
-	}
-
-	fclose(pFile);
-}
-
-void CRCFile::ProcessMenu(UINT uiMenuID, std::vector<CString>::iterator *init)
-{
-	element_map* pElementMap = GetElementMap(uiMenuID);
-	if(!pElementMap)
-		return;
-
-	CString str;
-	for (;(*init) != m_vInRCFile.end();(*init)++)
-	{
-		str=**init;
-		str.TrimLeft(_T(" "));
-		str.TrimRight(_T(" "));
-
-		// check for exit
-		if ( str == _T("END") )
-		{
-			// add the line to the outrc wo changes
-			m_vOutRCFile.push_back(**init);
-			return;
-		}
-		else if (str.Left(5) == _T("POPUP")) // if that is the popup string - call the function once more
-		{
-			// add the line to the outrc with changes - replace string inside "" with P
-			str=**init;
-
-			// processing menuitem - find the text
-			int iPos=str.Find(_T("\""), 0);
-			CString strText;
-			if (iPos != -1)
-			{
-				strText=str.Mid(iPos+1);
-				int iPos2=strText.Find(_T("\""));
-				if (iPos2 != -1)
-					strText=strText.Left(iPos2);
-			}
-
-			// now find the | that separates the text from the pseudo-ID
-			int iBar=strText.ReverseFind(_T('|'));
-			if (iBar != -1)
-			{
-				// there is a text with an ID
-				CString strID=strText.Mid(iBar+1);
-				strText=strText.Left(iBar);
-
-				// put the id and text in the translation file
-				// find the equiv for the id
-				UINT uiID = GetResourceID(strID);
-				pElementMap->insert(std::make_pair(uiID, strText));
-
-				// put the found ID as output text
-				CString out;
-				out.Format(_T("\"%lu\""), uiID);
-				str=str.Left(iPos)+out;
-			}
-			else
-			{
-				// no pseudoID in menu name
-				str=str.Left(iPos)+_T("\"P\"");
-			}
-
-			m_vOutRCFile.push_back(str);
-
-			(*init)++;
-			ProcessMenu(uiMenuID, init);
-		}
-		else
-		{
-			// if the line has MENUITEM
-			if (str.Left(8) == _T("MENUITEM") && str.Right(9) != _T("SEPARATOR"))
-			{
-				// restore original
-				str=**init;
-
-				// check if there is any text after the comma
-				int iPos=str.Find(_T(","), 0);
-				CString strTest=str.Mid(iPos);
-				strTest.TrimLeft(_T(" ,\t\r\n"));
-				if (strTest.IsEmpty())
-				{
-					(*init)++;
-
-					CString tmp=**init;
-					tmp.Trim(_T(" ,\t\r\n"));
-					str+=tmp;
-				}
-
-				// processing menuitem - find the text
-				iPos=str.Find(_T("\""), 0);
-				CString strText;
-				if (iPos != -1)
-				{
-					strText=str.Mid(iPos+1);
-					int iPos2=strText.Find(_T("\""));
-					if (iPos2 != -1)
-						strText=strText.Left(iPos2);
-				}
-
-				// find the ID
-				iPos=str.Find(_T(","), 0);
-				CString strID;
-				if (iPos != -1)
-				{
-					strID=str.Mid(iPos+1);
-					int iPos2=strID.Find(_T(","), 0);
-					if (iPos2 != -1)
-						strID=strID.Left(iPos2);
-				}
-				strID.TrimLeft(_T(" \t"));
-				strID.TrimRight(_T(" \t"));
-
-				// find the equiv for the id
-				UINT uiID = GetResourceID(strID);
-				pElementMap->insert(std::make_pair(uiID, strText));
-				CString out = str;
-				//				out=**init;
-				out.Replace(_T("\"")+strText+_T("\""), _T("\"i\""));
-				m_vOutRCFile.push_back(out);
-			}
-			else
-				m_vOutRCFile.push_back(**init);
-		}
-	}
-}
-
-void CRCFile::ProcessDialog(UINT uiDialogID, std::vector<CString>::iterator *init)
-{
-	element_map* pElementMap = GetElementMap(uiDialogID);
-	if(!pElementMap)
-		return;
-
-	CString str;
-	for (;(*init) != m_vInRCFile.end();(*init)++)
-	{
-		str=**init;
-		str.TrimLeft(_T(" "));
-		str.TrimRight(_T(" "));
-
-		// check for exit
-		if ( str == _T("END") )
-		{
-			// add the line to the outrc wo changes
-			m_vOutRCFile.push_back(**init);
-			return;
-		}
-		else if ( str.Left(7) == _T("CAPTION") )
-		{
-			// read the caption
-			CString strText=str.Mid(7);
-			strText.TrimLeft(_T(" \t\""));
-			strText.TrimRight(_T(" \t\""));
-
-			pElementMap->insert(std::make_pair(0, strText));
-
-			// save to rc wo title
-			str=**init;
-			str.Replace(_T("\"")+strText+_T("\""), _T("\"\""));
-			m_vOutRCFile.push_back(str);
-		}
-		else if ( str.Left(5) == _T("LTEXT") || str.Left(5) == _T("CTEXT") || str.Left(5) == _T("RTEXT") || str.Left(13) == _T("DEFPUSHBUTTON") || str.Left(10) == _T("PUSHBUTTON") || str.Left(7) == _T("CONTROL") || str.Left(8) == _T("GROUPBOX") )
-		{
-			// needed only 2 commas (outside the '\"')
-			if ( GetCommasCount(str) < 3 )
-				str+=*((*init)+1);
-
-			// the first thing after LTEXT(and other) is the caption
-			CString strText;
-			bool bControl = false;
-
-			if (str.Left(5) == _T("LTEXT") || str.Left(5) == _T("CTEXT") || str.Left(5) == _T("RTEXT"))
-				str=str.Mid(5);
-			else if (str.Left(13) == _T("DEFPUSHBUTTON"))
-				str=str.Mid(13);
-			else if (str.Left(10) == _T("PUSHBUTTON"))
-				str=str.Mid(10);
-			else if (str.Left(7) == _T("CONTROL"))
-			{
-				bControl = true;
-				str=str.Mid(7);
-			}
-			else if (str.Left(8) == _T("GROUPBOX"))
-				str=str.Mid(8);
-
-			str=str.Mid(str.Find(_T("\""))+1);
-			int iPos=str.Find(_T("\""), 0);
-			if (iPos != -1)
-				strText=str.Left(iPos);
-			else
-				THROW(_T("Error: cannot find a comma in processed text"), 0, 0, 0);
-
-			str = str.Mid(iPos+1);
-
-			// after the first comma there is an ID
-			iPos=str.Find(_T(","), 0);
-			CString strID;
-			if (iPos != -1)
-			{
-				str=str.Mid(iPos+1);
-				iPos=str.Find(_T(","), 0);
-				if (iPos != -1)
-					strID=str.Left(iPos);
-				else
-					THROW(_T("Error: cannot find a comma in processed text"), 0, 0, 0);
-
-				strID.TrimLeft(_T(" \t"));
-				strID.TrimRight(_T(" \t"));
-			}
-			else
-				THROW(_T("Error: cannot find a comma in processed text"), 0, 0, 0);
-
-			bool bSkip = false;
-			if(bControl)
-			{
-				str = str.Mid(iPos+1);
-				iPos = str.Find(_T(","), 0);
-				if(iPos == -1)
-					THROW(_T("Error: cannot find a comma in processed text"), 0, 0, 0);
-
-				CString strType = str.Left(iPos);
-				strType.Trim(_T("\""));
-				if(strType == _T("SysListView32") || strType == _T("msctls_progress32") ||
-					strType == _T("ComboBoxEx32") || strType == _T("msctls_updown32") ||
-					strType == _T("SysDateTimePick32"))
-				{
-					bSkip = true;
-				}
-			}
-
-			if(!bSkip)
-			{
-				// find id
-				UINT uiID = GetResourceID(strID);
-				CString out;
-				pElementMap->insert(std::make_pair(uiID, strText));
-			}
-
-			// now add the data to output rc
-			str=**init;
-			str.Replace(_T("\"")+strText+_T("\""), _T("\"\""));
-
-			m_vOutRCFile.push_back(str);
-		}
-		else
-			m_vOutRCFile.push_back(**init);
-	}
-}
-
-void CRCFile::ProcessStringTable(UINT uiStringGroupID, std::vector<CString>::iterator *init)
-{
-	element_map* pElementMap = GetElementMap(uiStringGroupID);
-	if(!pElementMap)
-		return;
-
-	CString str;
-	for (;(*init) != m_vInRCFile.end();(*init)++)
-	{
-		str=**init;
-		str.TrimLeft(_T(" "));
-		str.TrimRight(_T(" "));
-
-		if ( str == _T("END") )
-			return;
-		else if ( str != _T("BEGIN") )
-		{
-			// the first stuff is ID, the second is text
-			int iPos=str.Find(_T("\""), 0);
-			if (iPos == -1)
-			{
-				(*init)++;
-				str+=**init;
-				iPos=str.Find(_T("\""), 0);
-			}
-
-			if (iPos != -1)
-			{
-				CString strID=str.Left(iPos);
-				strID.TrimRight(_T(" \"\t\n\r"));
-
-				CString strText=str.Mid(iPos+1);
-				strText.Replace(_T("\"\""), _T("\""));
-				strText=strText.Left(strText.ReverseFind(_T('\"')));
-
-				UINT uiID = GetResourceID(strID);
-				pElementMap->insert(std::make_pair(uiID, strText));
-
-				str=**init;
-				str.Replace(_T("\"")+strText+_T("\""), _T("\"\""));
-			}
-		}
-	}
-}
-
-bool CRCFile::ProcessRCFile()
-{
-	int iPos;
-	CString strData;
-	std::vector<CString> vStrTable;
-	for (std::vector<CString>::iterator it=m_vInRCFile.begin();it != m_vInRCFile.end();it++)
-	{
-		if ( (iPos=it->Find(_T(" MENU "))) != -1 )
-		{
-			// add the line to the output rc with no change
-			m_vOutRCFile.push_back(*it);
-
-			UINT uiID = GetResourceID(it->Left(iPos));
-
-			// begin enumerating items
-			it++;
-
-			// process the menu
-			ProcessMenu(uiID, &it);
-		}
-		else if ( (iPos=it->Find(_T(" DIALOGEX "))) != -1)
-		{
-			// add the line to the output rc with no change
-			m_vOutRCFile.push_back(*it);
-
-			UINT uiID = GetResourceID(it->Left(iPos));
-			// begin processing dialog template
-			it++;
-			ProcessDialog(uiID, &it);
-		}
-		else if ( (iPos=it->Find(_T("STRINGTABLE "))) != -1)
-		{
-			// begin of the string table
-			it++;
-			ProcessStringTable(0, &it);
-		}
-		else
-			m_vOutRCFile.push_back(*it);
-	}
-
-	return true;
-}
-
-CRCFile::element_map* CRCFile::GetElementMap(UINT uiGroup)
-{
-	// insert menu if does not exist
-	element_map* pElementMap = NULL;
-	group_map::iterator itGroup = m_mapOutputLanguage.find(uiGroup);
-	if(itGroup == m_mapOutputLanguage.end())
-	{
-		std::pair<group_map::iterator, bool> pairGroup = m_mapOutputLanguage.insert(std::make_pair(uiGroup, element_map()));
-		if(!pairGroup.second)
-		{
-			_ASSERTE(false);
-			return NULL;
-		}
-
-		pElementMap = &(*(pairGroup.first)).second;
-	}
-	else
-		pElementMap = &((*itGroup).second);
-
-	if(!pElementMap)
-	{
-		_ASSERTE(false);
-		return NULL;
-	}
-
-	return pElementMap;
-}
-
-UINT CRCFile::GetResourceID(PCTSTR pszID)
-{
-	std::map<CString, UINT>::iterator mit = m_mapNameToID.find(pszID);
-	if (mit != m_mapNameToID.end())
-		return (*mit).second;
-	else
-	{
-		_ASSERTE(false);
-		THROW(icpf::exception::format(_T("Error: Cannot find resource identifier ") TSTRFMT, pszID), 0, 0, 0);
-	}
-}
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+#include "stdafx.h"
+#include <vector>
+#include <map>
+#include <functional>
+#include <algorithm>
+#include "rc.h"
+#include "../libicpf/exception.h"
+#include "../libicpf/crc32.h"
+
+#define MAX_LINE 65536
+
+CRCFile::CRCFile() :
+	m_pszBuffer(new TCHAR[MAX_LINE])
+{
+	AddInitialValues();
+}
+
+CRCFile::~CRCFile()
+{
+	delete [] m_pszBuffer;
+}
+
+void CRCFile::ReadRC(PCTSTR pszFilename)
+{
+	// read file
+	CRCFile::ReadFile(pszFilename, m_vInRCFile, false);
+
+	// and process it
+	ProcessRCFile();
+}
+
+void CRCFile::ReadResourceIDs(PCTSTR pszFile)
+{
+	std::vector<CString> vLines;
+	CRCFile::ReadFile(pszFile, vLines, false);
+
+	long lLineNo = 0;
+	CString str, str2;
+	for(std::vector<CString>::iterator itLine = vLines.begin(); itLine != vLines.end(); ++itLine)
+	{
+		str = (*itLine);
+		str.TrimLeft(_T(" \t"));
+		if (str.Left(7) == _T("#define"))
+		{
+			str=str.Mid(8);
+			int iPos=str.FindOneOf(_T(" \t"));
+			str2=str.Left(iPos);
+			str=str.Mid(iPos);
+			str.TrimLeft(_T(" \t"));
+			str.TrimRight(_T(" \t\r\n"));
+
+			int iID;
+			if(str.Find(_T("x")) != -1)
+			{
+				// hex2dec
+				if(_stscanf(str, _T("%lx"), &iID) != 1)
+					THROW(icpf::exception::format(TSTRFMT _T("(%ld) : Error: Cannot parse hex number in line:\n") TSTRFMT, pszFile, lLineNo, m_pszBuffer), 0, 0, 0);
+			}
+			else
+				iID=_ttoi(str);
+
+			m_mapNameToID.insert(std::map<CString, UINT>::value_type(str2, iID));
+		}
+
+		++lLineNo;
+	}
+}
+
+void CRCFile::WriteRC(PCTSTR pszFilename)
+{
+	CRCFile::WriteFile(pszFilename, m_vOutRCFile, false);
+}
+
+void CRCFile::WriteLang(PCTSTR pszFilename, PCTSTR pszHeaderFile)
+{
+	// write header file to the output file
+	std::vector<CString> vData;
+	CRCFile::ReadFile(pszHeaderFile, vData, true);
+
+	// append the translation
+	CString str;
+	for(group_map::iterator itGroup = m_mapOutputLanguage.begin(); itGroup != m_mapOutputLanguage.end(); ++itGroup)
+	{
+		// write section header
+		AddTranslationLine(eLine_Group, (*itGroup).first, NULL, vData);
+
+		// and key=value assignment
+		element_map& rElementMap = (*itGroup).second;
+		for(element_map::iterator itElement = rElementMap.begin(); itElement != rElementMap.end(); ++itElement)
+		{
+			AddTranslationLine(eLine_Translation, (*itElement).first, (*itElement).second, vData);
+		}
+	}
+
+	CRCFile::WriteFile(pszFilename, vData, true);
+}
+
+void CRCFile::Clear()
+{
+	m_vInRCFile.clear();
+	m_vOutRCFile.clear();
+	m_mapNameToID.clear();
+	m_mapOutputLanguage.clear();
+
+	AddInitialValues();
+}
+
+void CRCFile::AddInitialValues()
+{
+	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDOK")), 1));
+	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDCANCEL")), 2));
+	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDABORT")), 3));
+	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDRETRY")), 4));
+	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDIGNORE")), 5));
+	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDYES")), 6));
+	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDNO")), 7));
+	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDCLOSE")), 8));
+	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDHELP")), 9));
+	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDTRYAGAIN")), 10));
+	m_mapNameToID.insert(std::map<CString, UINT>::value_type(CString(_T("IDCONTINUE")), 11));
+}
+
+int CRCFile::GetCommasCount(const CString& str)
+{
+	int cnt=0;
+	bool bInside=false;
+	for (int i=0;i<str.GetLength();i++)
+	{
+		if (str[i] == _T('\"'))
+			bInside=!bInside;
+
+		if (!bInside && str[i] == _T(','))
+			cnt++;
+	}
+
+	return cnt;
+}
+
+void CRCFile::AddTranslationLine(ELineType eLineType, UINT uiID, PCTSTR pszText, std::vector<CString>& vLines)
+{
+	switch(eLineType)
+	{
+	case eLine_Group:
+		{
+			CString str;
+			str.Format(_T("[") UIFMT _T("]"), uiID);
+			vLines.push_back(_T(""));
+			vLines.push_back(str);
+			break;
+		}
+	case eLine_Translation:
+		{
+			if(!pszText)
+				THROW(_T("Error: Invalid string."), 0, 0, 0);
+			if(pszText[0] != _T('\0'))
+			{
+				CString str;
+				str.Format(UIFMT _T("[") UIXFMT _T("]=") TSTRFMT, uiID, icpf::crc32((const byte_t*)pszText, _tcslen(pszText)*sizeof(TCHAR)), pszText);
+				vLines.push_back(str);
+			}
+			break;
+		}
+	default:
+		{
+			_ASSERTE(FALSE);
+			THROW(_T("Error: Unknown line type."), 0, 0, 0);
+		}
+	}
+}
+
+void CRCFile::ReadFile(PCTSTR pszFile, std::vector<CString>& rLines, bool bUnicode)
+{
+	// load file
+	FILE* pFile = _tfopen(pszFile, bUnicode ? _T("rb") : _T("rt"));
+	if(!pFile)
+		THROW(icpf::exception::format(_T("Error: Cannot open file: ") TSTRFMT, pszFile), 0, errno, 0);
+
+	CString str;
+	while(_fgetts(str.GetBufferSetLength(MAX_LINE), MAX_LINE, pFile))
+	{
+		str.ReleaseBuffer();
+		str.TrimRight(_T("\r\n"));
+		rLines.push_back(str);
+	}
+	str.ReleaseBuffer();
+
+	fclose(pFile);
+}
+
+void CRCFile::WriteFile(PCTSTR pszFile, const std::vector<CString>& rLines, bool bUnicode)
+{
+	FILE* pFile = _tfopen(pszFile, bUnicode ? _T("wb") : _T("wt"));
+	if(!pFile)
+		THROW(icpf::exception::format(_T("Error: Cannot open file: ") TSTRFMT _T(" for writing."), pszFile), 0, errno, 0);
+
+	for (std::vector<CString>::const_iterator it=rLines.begin();it != rLines.end();it++)
+	{
+		CString str = (*it);
+		str += _T("\r\n");
+		if(_fputts((PCTSTR)str, pFile) < 0)
+			THROW(icpf::exception::format(_T("Cannot write data to file ") TSTRFMT, pszFile), 0, errno, 0);
+	}
+
+	fclose(pFile);
+}
+
+void CRCFile::ProcessMenu(UINT uiMenuID, std::vector<CString>::iterator *init)
+{
+	element_map* pElementMap = GetElementMap(uiMenuID);
+	if(!pElementMap)
+		return;
+
+	CString str;
+	for (;(*init) != m_vInRCFile.end();(*init)++)
+	{
+		str=**init;
+		str.TrimLeft(_T(" "));
+		str.TrimRight(_T(" "));
+
+		// check for exit
+		if ( str == _T("END") )
+		{
+			// add the line to the outrc wo changes
+			m_vOutRCFile.push_back(**init);
+			return;
+		}
+		else if (str.Left(5) == _T("POPUP")) // if that is the popup string - call the function once more
+		{
+			// add the line to the outrc with changes - replace string inside "" with P
+			str=**init;
+
+			// processing menuitem - find the text
+			int iPos=str.Find(_T("\""), 0);
+			CString strText;
+			if (iPos != -1)
+			{
+				strText=str.Mid(iPos+1);
+				int iPos2=strText.Find(_T("\""));
+				if (iPos2 != -1)
+					strText=strText.Left(iPos2);
+			}
+
+			// now find the | that separates the text from the pseudo-ID
+			int iBar=strText.ReverseFind(_T('|'));
+			if (iBar != -1)
+			{
+				// there is a text with an ID
+				CString strID=strText.Mid(iBar+1);
+				strText=strText.Left(iBar);
+
+				// put the id and text in the translation file
+				// find the equiv for the id
+				UINT uiID = GetResourceID(strID);
+				pElementMap->insert(std::make_pair(uiID, strText));
+
+				// put the found ID as output text
+				CString out;
+				out.Format(_T("\"%lu\""), uiID);
+				str=str.Left(iPos)+out;
+			}
+			else
+			{
+				// no pseudoID in menu name
+				str=str.Left(iPos)+_T("\"P\"");
+			}
+
+			m_vOutRCFile.push_back(str);
+
+			(*init)++;
+			ProcessMenu(uiMenuID, init);
+		}
+		else
+		{
+			// if the line has MENUITEM
+			if (str.Left(8) == _T("MENUITEM") && str.Right(9) != _T("SEPARATOR"))
+			{
+				// restore original
+				str=**init;
+
+				// check if there is any text after the comma
+				int iPos=str.Find(_T(","), 0);
+				CString strTest=str.Mid(iPos);
+				strTest.TrimLeft(_T(" ,\t\r\n"));
+				if (strTest.IsEmpty())
+				{
+					(*init)++;
+
+					CString tmp=**init;
+					tmp.Trim(_T(" ,\t\r\n"));
+					str+=tmp;
+				}
+
+				// processing menuitem - find the text
+				iPos=str.Find(_T("\""), 0);
+				CString strText;
+				if (iPos != -1)
+				{
+					strText=str.Mid(iPos+1);
+					int iPos2=strText.Find(_T("\""));
+					if (iPos2 != -1)
+						strText=strText.Left(iPos2);
+				}
+
+				// find the ID
+				iPos=str.Find(_T(","), 0);
+				CString strID;
+				if (iPos != -1)
+				{
+					strID=str.Mid(iPos+1);
+					int iPos2=strID.Find(_T(","), 0);
+					if (iPos2 != -1)
+						strID=strID.Left(iPos2);
+				}
+				strID.TrimLeft(_T(" \t"));
+				strID.TrimRight(_T(" \t"));
+
+				// find the equiv for the id
+				UINT uiID = GetResourceID(strID);
+				pElementMap->insert(std::make_pair(uiID, strText));
+				CString out = str;
+				//				out=**init;
+				out.Replace(_T("\"")+strText+_T("\""), _T("\"i\""));
+				m_vOutRCFile.push_back(out);
+			}
+			else
+				m_vOutRCFile.push_back(**init);
+		}
+	}
+}
+
+void CRCFile::ProcessDialog(UINT uiDialogID, std::vector<CString>::iterator *init)
+{
+	element_map* pElementMap = GetElementMap(uiDialogID);
+	if(!pElementMap)
+		return;
+
+	CString str;
+	for (;(*init) != m_vInRCFile.end();(*init)++)
+	{
+		str=**init;
+		str.TrimLeft(_T(" "));
+		str.TrimRight(_T(" "));
+
+		// check for exit
+		if ( str == _T("END") )
+		{
+			// add the line to the outrc wo changes
+			m_vOutRCFile.push_back(**init);
+			return;
+		}
+		else if ( str.Left(7) == _T("CAPTION") )
+		{
+			// read the caption
+			CString strText=str.Mid(7);
+			strText.TrimLeft(_T(" \t\""));
+			strText.TrimRight(_T(" \t\""));
+
+			pElementMap->insert(std::make_pair(0, strText));
+
+			// save to rc wo title
+			str=**init;
+			str.Replace(_T("\"")+strText+_T("\""), _T("\"\""));
+			m_vOutRCFile.push_back(str);
+		}
+		else if ( str.Left(5) == _T("LTEXT") || str.Left(5) == _T("CTEXT") || str.Left(5) == _T("RTEXT") || str.Left(13) == _T("DEFPUSHBUTTON") || str.Left(10) == _T("PUSHBUTTON") || str.Left(7) == _T("CONTROL") || str.Left(8) == _T("GROUPBOX") )
+		{
+			// needed only 2 commas (outside the '\"')
+			if ( GetCommasCount(str) < 3 )
+				str+=*((*init)+1);
+
+			// the first thing after LTEXT(and other) is the caption
+			CString strText;
+			bool bControl = false;
+
+			if (str.Left(5) == _T("LTEXT") || str.Left(5) == _T("CTEXT") || str.Left(5) == _T("RTEXT"))
+				str=str.Mid(5);
+			else if (str.Left(13) == _T("DEFPUSHBUTTON"))
+				str=str.Mid(13);
+			else if (str.Left(10) == _T("PUSHBUTTON"))
+				str=str.Mid(10);
+			else if (str.Left(7) == _T("CONTROL"))
+			{
+				bControl = true;
+				str=str.Mid(7);
+			}
+			else if (str.Left(8) == _T("GROUPBOX"))
+				str=str.Mid(8);
+
+			str=str.Mid(str.Find(_T("\""))+1);
+			int iPos=str.Find(_T("\""), 0);
+			if (iPos != -1)
+				strText=str.Left(iPos);
+			else
+				THROW(_T("Error: cannot find a comma in processed text"), 0, 0, 0);
+
+			str = str.Mid(iPos+1);
+
+			// after the first comma there is an ID
+			iPos=str.Find(_T(","), 0);
+			CString strID;
+			if (iPos != -1)
+			{
+				str=str.Mid(iPos+1);
+				iPos=str.Find(_T(","), 0);
+				if (iPos != -1)
+					strID=str.Left(iPos);
+				else
+					THROW(_T("Error: cannot find a comma in processed text"), 0, 0, 0);
+
+				strID.TrimLeft(_T(" \t"));
+				strID.TrimRight(_T(" \t"));
+			}
+			else
+				THROW(_T("Error: cannot find a comma in processed text"), 0, 0, 0);
+
+			bool bSkip = false;
+			if(bControl)
+			{
+				str = str.Mid(iPos+1);
+				iPos = str.Find(_T(","), 0);
+				if(iPos == -1)
+					THROW(_T("Error: cannot find a comma in processed text"), 0, 0, 0);
+
+				CString strType = str.Left(iPos);
+				strType.Trim(_T("\""));
+				if(strType == _T("SysListView32") || strType == _T("msctls_progress32") ||
+					strType == _T("ComboBoxEx32") || strType == _T("msctls_updown32") ||
+					strType == _T("SysDateTimePick32"))
+				{
+					bSkip = true;
+				}
+			}
+
+			if(!bSkip)
+			{
+				// find id
+				UINT uiID = GetResourceID(strID);
+				CString out;
+				pElementMap->insert(std::make_pair(uiID, strText));
+			}
+
+			// now add the data to output rc
+			str=**init;
+			str.Replace(_T("\"")+strText+_T("\""), _T("\"\""));
+
+			m_vOutRCFile.push_back(str);
+		}
+		else
+			m_vOutRCFile.push_back(**init);
+	}
+}
+
+void CRCFile::ProcessStringTable(UINT uiStringGroupID, std::vector<CString>::iterator *init)
+{
+	element_map* pElementMap = GetElementMap(uiStringGroupID);
+	if(!pElementMap)
+		return;
+
+	CString str;
+	for (;(*init) != m_vInRCFile.end();(*init)++)
+	{
+		str=**init;
+		str.TrimLeft(_T(" "));
+		str.TrimRight(_T(" "));
+
+		if ( str == _T("END") )
+			return;
+		else if ( str != _T("BEGIN") )
+		{
+			// the first stuff is ID, the second is text
+			int iPos=str.Find(_T("\""), 0);
+			if (iPos == -1)
+			{
+				(*init)++;
+				str+=**init;
+				iPos=str.Find(_T("\""), 0);
+			}
+
+			if (iPos != -1)
+			{
+				CString strID=str.Left(iPos);
+				strID.TrimRight(_T(" \"\t\n\r"));
+
+				CString strText=str.Mid(iPos+1);
+				strText.Replace(_T("\"\""), _T("\""));
+				strText=strText.Left(strText.ReverseFind(_T('\"')));
+
+				UINT uiID = GetResourceID(strID);
+				pElementMap->insert(std::make_pair(uiID, strText));
+
+				str=**init;
+				str.Replace(_T("\"")+strText+_T("\""), _T("\"\""));
+			}
+		}
+	}
+}
+
+bool CRCFile::ProcessRCFile()
+{
+	int iPos;
+	CString strData;
+	std::vector<CString> vStrTable;
+	for (std::vector<CString>::iterator it=m_vInRCFile.begin();it != m_vInRCFile.end();it++)
+	{
+		if ( (iPos=it->Find(_T(" MENU "))) != -1 )
+		{
+			// add the line to the output rc with no change
+			m_vOutRCFile.push_back(*it);
+
+			UINT uiID = GetResourceID(it->Left(iPos));
+
+			// begin enumerating items
+			it++;
+
+			// process the menu
+			ProcessMenu(uiID, &it);
+		}
+		else if ( (iPos=it->Find(_T(" DIALOGEX "))) != -1)
+		{
+			// add the line to the output rc with no change
+			m_vOutRCFile.push_back(*it);
+
+			UINT uiID = GetResourceID(it->Left(iPos));
+			// begin processing dialog template
+			it++;
+			ProcessDialog(uiID, &it);
+		}
+		else if ( (iPos=it->Find(_T("STRINGTABLE "))) != -1)
+		{
+			// begin of the string table
+			it++;
+			ProcessStringTable(0, &it);
+		}
+		else
+			m_vOutRCFile.push_back(*it);
+	}
+
+	return true;
+}
+
+CRCFile::element_map* CRCFile::GetElementMap(UINT uiGroup)
+{
+	// insert menu if does not exist
+	element_map* pElementMap = NULL;
+	group_map::iterator itGroup = m_mapOutputLanguage.find(uiGroup);
+	if(itGroup == m_mapOutputLanguage.end())
+	{
+		std::pair<group_map::iterator, bool> pairGroup = m_mapOutputLanguage.insert(std::make_pair(uiGroup, element_map()));
+		if(!pairGroup.second)
+		{
+			_ASSERTE(false);
+			return NULL;
+		}
+
+		pElementMap = &(*(pairGroup.first)).second;
+	}
+	else
+		pElementMap = &((*itGroup).second);
+
+	if(!pElementMap)
+	{
+		_ASSERTE(false);
+		return NULL;
+	}
+
+	return pElementMap;
+}
+
+UINT CRCFile::GetResourceID(PCTSTR pszID)
+{
+	std::map<CString, UINT>::iterator mit = m_mapNameToID.find(pszID);
+	if (mit != m_mapNameToID.end())
+		return (*mit).second;
+	else
+	{
+		_ASSERTE(false);
+		THROW(icpf::exception::format(_T("Error: Cannot find resource identifier ") TSTRFMT, pszID), 0, 0, 0);
+	}
+}
Index: src/rc2lng/rc.h
===================================================================
diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/rc2lng/rc.h	(.../rc.h)	(revision 4eceec553f29c0ba93452ffeb52a647204dc9fce)
+++ src/rc2lng/rc.h	(.../rc.h)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,74 +1,74 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-#ifndef __RC_H__
-#define __RC_H__
-
-class CRCFile
-{
-private:
-	typedef std::map<UINT, CString> element_map;
-	typedef std::map<UINT, element_map> group_map;
-
-	enum ELineType
-	{
-		eLine_Group,
-		eLine_Translation
-	};
-public:
-	CRCFile();
-	~CRCFile();
-
-	void ReadRC(PCTSTR pszFilename);
-	void ReadResourceIDs(PCTSTR pszFilename);
-
-	void WriteRC(PCTSTR pszFilename);
-	void WriteLang(PCTSTR pszFilename, PCTSTR pszHeaderFile);
-
-	void Clear();
-
-protected:
-	// Adds initial values to the maps
-	void AddInitialValues();
-
-	static int GetCommasCount(const CString& str);
-
-	static void WriteFile(PCTSTR pszFile, const std::vector<CString>& rLines, bool bUnicode);
-	static void ReadFile(PCTSTR pszFile, std::vector<CString>& rLines, bool bUnicode);
-
-	void AddTranslationLine(ELineType eLineType, UINT uiID, PCTSTR pszText, std::vector<CString>& vLines);
-
-	bool ProcessRCFile();
-	void ProcessMenu(UINT uiMenuID, std::vector<CString>::iterator *init);
-	void ProcessDialog(UINT uiDialogID, std::vector<CString>::iterator *init);
-	void ProcessStringTable(UINT uiStringGroupID, std::vector<CString>::iterator *init);
-
-	element_map* GetElementMap(UINT uiGroup);
-	UINT GetResourceID(PCTSTR pszID);
-
-protected:
-	std::map<CString, UINT> m_mapNameToID;		// resource name to resource id
-	std::vector<CString> m_vInRCFile;			// lines from rc file
-	std::vector<CString> m_vOutRCFile;			// lines to write to rc file
-
-	group_map m_mapOutputLanguage;	// section_id->element_id->string
-//	std::vector<CString> m_vOutputLanguage;		// lines of the language file to be written
-	TCHAR* m_pszBuffer;
-};
-
-#endif
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+#ifndef __RC_H__
+#define __RC_H__
+
+class CRCFile
+{
+private:
+	typedef std::map<UINT, CString> element_map;
+	typedef std::map<UINT, element_map> group_map;
+
+	enum ELineType
+	{
+		eLine_Group,
+		eLine_Translation
+	};
+public:
+	CRCFile();
+	~CRCFile();
+
+	void ReadRC(PCTSTR pszFilename);
+	void ReadResourceIDs(PCTSTR pszFilename);
+
+	void WriteRC(PCTSTR pszFilename);
+	void WriteLang(PCTSTR pszFilename, PCTSTR pszHeaderFile);
+
+	void Clear();
+
+protected:
+	// Adds initial values to the maps
+	void AddInitialValues();
+
+	static int GetCommasCount(const CString& str);
+
+	static void WriteFile(PCTSTR pszFile, const std::vector<CString>& rLines, bool bUnicode);
+	static void ReadFile(PCTSTR pszFile, std::vector<CString>& rLines, bool bUnicode);
+
+	void AddTranslationLine(ELineType eLineType, UINT uiID, PCTSTR pszText, std::vector<CString>& vLines);
+
+	bool ProcessRCFile();
+	void ProcessMenu(UINT uiMenuID, std::vector<CString>::iterator *init);
+	void ProcessDialog(UINT uiDialogID, std::vector<CString>::iterator *init);
+	void ProcessStringTable(UINT uiStringGroupID, std::vector<CString>::iterator *init);
+
+	element_map* GetElementMap(UINT uiGroup);
+	UINT GetResourceID(PCTSTR pszID);
+
+protected:
+	std::map<CString, UINT> m_mapNameToID;		// resource name to resource id
+	std::vector<CString> m_vInRCFile;			// lines from rc file
+	std::vector<CString> m_vOutRCFile;			// lines to write to rc file
+
+	group_map m_mapOutputLanguage;	// section_id->element_id->string
+//	std::vector<CString> m_vOutputLanguage;		// lines of the language file to be written
+	TCHAR* m_pszBuffer;
+};
+
+#endif
Index: src/rc2lng/rc2lng.cpp
===================================================================
diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/rc2lng/rc2lng.cpp	(.../rc2lng.cpp)	(revision 4eceec553f29c0ba93452ffeb52a647204dc9fce)
+++ src/rc2lng/rc2lng.cpp	(.../rc2lng.cpp)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,76 +1,76 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-// rc2lng.cpp : Defines the entry point for the console application.
-//
-
-#include "stdafx.h"
-#include "rc2lng.h"
-#include "conio.h"
-#include "rc.h"
-#include "../libicpf/exception.h"
-
-#pragma warning(disable : 4786)
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
-int _tmain(int argc, TCHAR* argv[], TCHAR* /*envp*/[])
-{
-	// initialize MFC and print and error on failure
-	HMODULE hModule = ::GetModuleHandle(NULL);
-	if(!hModule)
-		return -1;
-	if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), 0))
-	{
-		cerr << _T("Fatal Error: MFC initialization failed") << endl;
-		return 1;
-	}
-
-	// usage - rc2lng infile.rc resource.h inheader.lng outfile.rc outfile.lng
-	if (argc < 6)
-	{
-		wcerr << _T("Fatal Error: Incorrect numer of params") << endl;
-		wcerr << _T("Usage: infile.rc inheader.lng outfile.rc outfile.lng resource.h resource2.h") << endl;
-		return -1;
-	}
-
-	CRCFile rcFile;
-
-	try
-	{
-		for (int i=5;i<argc;i++)
-		{
-			rcFile.ReadResourceIDs(argv[i]);
-		}
-		
-		rcFile.ReadRC(argv[1]);
-
-		rcFile.WriteRC(argv[3]);
-		rcFile.WriteLang(argv[4], argv[2]);
-	}
-	catch(icpf::exception& e)
-	{
-		wcerr << e.get_desc() << endl;
-		return -1;
-	}
-	return 0;
-}
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+// rc2lng.cpp : Defines the entry point for the console application.
+//
+
+#include "stdafx.h"
+#include "rc2lng.h"
+#include "conio.h"
+#include "rc.h"
+#include "../libicpf/exception.h"
+
+#pragma warning(disable : 4786)
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+int _tmain(int argc, TCHAR* argv[], TCHAR* /*envp*/[])
+{
+	// initialize MFC and print and error on failure
+	HMODULE hModule = ::GetModuleHandle(NULL);
+	if(!hModule)
+		return -1;
+	if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), 0))
+	{
+		cerr << _T("Fatal Error: MFC initialization failed") << endl;
+		return 1;
+	}
+
+	// usage - rc2lng infile.rc resource.h inheader.lng outfile.rc outfile.lng
+	if (argc < 6)
+	{
+		wcerr << _T("Fatal Error: Incorrect numer of params") << endl;
+		wcerr << _T("Usage: infile.rc inheader.lng outfile.rc outfile.lng resource.h resource2.h") << endl;
+		return -1;
+	}
+
+	CRCFile rcFile;
+
+	try
+	{
+		for (int i=5;i<argc;i++)
+		{
+			rcFile.ReadResourceIDs(argv[i]);
+		}
+		
+		rcFile.ReadRC(argv[1]);
+
+		rcFile.WriteRC(argv[3]);
+		rcFile.WriteLang(argv[4], argv[2]);
+	}
+	catch(icpf::exception& e)
+	{
+		wcerr << e.get_desc() << endl;
+		return -1;
+	}
+	return 0;
+}
Index: src/rc2lng/rc2lng.h
===================================================================
diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/rc2lng/rc2lng.h	(.../rc2lng.h)	(revision 4eceec553f29c0ba93452ffeb52a647204dc9fce)
+++ src/rc2lng/rc2lng.h	(.../rc2lng.h)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,35 +1,35 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-
-#if !defined(AFX_CHEXE2LNG_H__71D002AA_5384_43E2_BEA2_CF86F1DB9C20__INCLUDED_)
-#define AFX_CHEXE2LNG_H__71D002AA_5384_43E2_BEA2_CF86F1DB9C20__INCLUDED_
-
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-#include "resource.h"
-#include <map>
-#include <vector>
-#include <algorithm>
-using namespace std;
-
-#pragma warning(disable : 4786)
-
-#endif // !defined(AFX_CHEXE2LNG_H__71D002AA_5384_43E2_BEA2_CF86F1DB9C20__INCLUDED_)
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+
+#if !defined(AFX_CHEXE2LNG_H__71D002AA_5384_43E2_BEA2_CF86F1DB9C20__INCLUDED_)
+#define AFX_CHEXE2LNG_H__71D002AA_5384_43E2_BEA2_CF86F1DB9C20__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "resource.h"
+#include <map>
+#include <vector>
+#include <algorithm>
+using namespace std;
+
+#pragma warning(disable : 4786)
+
+#endif // !defined(AFX_CHEXE2LNG_H__71D002AA_5384_43E2_BEA2_CF86F1DB9C20__INCLUDED_)
Index: src/rc2lng/resource.h
===================================================================
diff -u -rbee51aca3d5d9b67ecac4f528a3203738cc63455 -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/rc2lng/resource.h	(.../resource.h)	(revision bee51aca3d5d9b67ecac4f528a3203738cc63455)
+++ src/rc2lng/resource.h	(.../resource.h)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,16 +1,16 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by CHExe2Lng.rc
-//
-#define IDS_HELLO                       1
-
-// Next default values for new objects
-// 
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE        101
-#define _APS_NEXT_COMMAND_VALUE         40001
-#define _APS_NEXT_CONTROL_VALUE         1000
-#define _APS_NEXT_SYMED_VALUE           101
-#endif
-#endif
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by CHExe2Lng.rc
+//
+#define IDS_HELLO                       1
+
+// Next default values for new objects
+// 
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE        101
+#define _APS_NEXT_COMMAND_VALUE         40001
+#define _APS_NEXT_CONTROL_VALUE         1000
+#define _APS_NEXT_SYMED_VALUE           101
+#endif
+#endif
Index: src/rc2lng/stdafx.cpp
===================================================================
diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/rc2lng/stdafx.cpp	(.../stdafx.cpp)	(revision 4eceec553f29c0ba93452ffeb52a647204dc9fce)
+++ src/rc2lng/stdafx.cpp	(.../stdafx.cpp)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,26 +1,26 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-// stdafx.cpp : source file that includes just the standard includes
-//	CHExe2Lng.pch will be the pre-compiled header
-//	stdafx.obj will contain the pre-compiled type information
-
-#include "stdafx.h"
-
-// TODO: reference any additional headers you need in STDAFX.H
-// and not in this file
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+// stdafx.cpp : source file that includes just the standard includes
+//	CHExe2Lng.pch will be the pre-compiled header
+//	stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
Index: src/rc2lng/stdafx.h
===================================================================
diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r8443d0d98d380facaf07b540c8d98da08365b816
--- src/rc2lng/stdafx.h	(.../stdafx.h)	(revision 4eceec553f29c0ba93452ffeb52a647204dc9fce)
+++ src/rc2lng/stdafx.h	(.../stdafx.h)	(revision 8443d0d98d380facaf07b540c8d98da08365b816)
@@ -1,50 +1,50 @@
-/***************************************************************************
-*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
-*   ixen@copyhandler.com                                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License          *
-*   (version 2) as published by the Free Software Foundation;             *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-// stdafx.h : include file for standard system include files,
-//  or project specific include files that are used frequently, but
-//      are changed infrequently
-//
-
-#if !defined(AFX_STDAFX_H__C4BBF6E4_ACB3_44C7_97B7_293263788195__INCLUDED_)
-#define AFX_STDAFX_H__C4BBF6E4_ACB3_44C7_97B7_293263788195__INCLUDED_
-
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-#define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers
-
-#pragma warning(disable : 4786)
-
-#include <afx.h>
-#include <afxwin.h>         // MFC core and standard components
-#include <afxext.h>         // MFC extensions
-#include <afxdtctl.h>		// MFC support for Internet Explorer 4 Common Controls
-#ifndef _AFX_NO_AFXCMN_SUPPORT
-#include <afxcmn.h>			// MFC support for Windows Common Controls
-#endif // _AFX_NO_AFXCMN_SUPPORT
-
-#include <iostream>
-
-// TODO: reference additional headers your program requires here
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_STDAFX_H__C4BBF6E4_ACB3_44C7_97B7_293263788195__INCLUDED_)
+/***************************************************************************
+*   Copyright (C) 2001-2008 by J�zef Starosczyk                           *
+*   ixen@copyhandler.com                                                  *
+*                                                                         *
+*   This program is free software; you can redistribute it and/or modify  *
+*   it under the terms of the GNU Library General Public License          *
+*   (version 2) as published by the Free Software Foundation;             *
+*                                                                         *
+*   This program is distributed in the hope that it will be useful,       *
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+*   GNU General Public License for more details.                          *
+*                                                                         *
+*   You should have received a copy of the GNU Library General Public     *
+*   License along with this program; if not, write to the                 *
+*   Free Software Foundation, Inc.,                                       *
+*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+***************************************************************************/
+// stdafx.h : include file for standard system include files,
+//  or project specific include files that are used frequently, but
+//      are changed infrequently
+//
+
+#if !defined(AFX_STDAFX_H__C4BBF6E4_ACB3_44C7_97B7_293263788195__INCLUDED_)
+#define AFX_STDAFX_H__C4BBF6E4_ACB3_44C7_97B7_293263788195__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers
+
+#pragma warning(disable : 4786)
+
+#include <afx.h>
+#include <afxwin.h>         // MFC core and standard components
+#include <afxext.h>         // MFC extensions
+#include <afxdtctl.h>		// MFC support for Internet Explorer 4 Common Controls
+#ifndef _AFX_NO_AFXCMN_SUPPORT
+#include <afxcmn.h>			// MFC support for Windows Common Controls
+#endif // _AFX_NO_AFXCMN_SUPPORT
+
+#include <iostream>
+
+// TODO: reference additional headers your program requires here
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__C4BBF6E4_ACB3_44C7_97B7_293263788195__INCLUDED_)