Index: src/ictranslate/ICTranslateDlg.cpp =================================================================== diff -u -r8443d0d98d380facaf07b540c8d98da08365b816 -rc04cbdd0e391ca357bd9b2a24ce8de3231bf3871 --- src/ictranslate/ICTranslateDlg.cpp (.../ICTranslateDlg.cpp) (revision 8443d0d98d380facaf07b540c8d98da08365b816) +++ src/ictranslate/ICTranslateDlg.cpp (.../ICTranslateDlg.cpp) (revision c04cbdd0e391ca357bd9b2a24ce8de3231bf3871) @@ -303,7 +303,7 @@ 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())) + if(!m_ldCustom.ReadTranslation(fd.GetPathName(), false, true)) { AfxMessageBox(_T("Reading file failed")); return; Index: src/libictranslate/ResourceManager.cpp =================================================================== diff -u -r8443d0d98d380facaf07b540c8d98da08365b816 -rc04cbdd0e391ca357bd9b2a24ce8de3231bf3871 --- src/libictranslate/ResourceManager.cpp (.../ResourceManager.cpp) (revision 8443d0d98d380facaf07b540c8d98da08365b816) +++ src/libictranslate/ResourceManager.cpp (.../ResourceManager.cpp) (revision c04cbdd0e391ca357bd9b2a24ce8de3231bf3871) @@ -28,6 +28,8 @@ #define new DEBUG_NEW #endif +#define TRANSLATION_FORMAT_VERSION _T("2") + BEGIN_ICTRANSLATE_NAMESPACE #define EMPTY_STRING _t("") @@ -406,8 +408,15 @@ 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("")); + const uint_t uiVersion = cfg.register_string(_T("Info/Format version"), _T("1")); + cfg.read(pszFile); + // we don't support old language versions + const tchar_t* pszVersion = cfg.get_string(uiVersion); + if(_tcscmp(pszVersion, TRANSLATION_FORMAT_VERSION) != 0) + return false; + const tchar_t* psz = cfg.get_string(uiLangName); if(!psz || psz[0] == _t('\0')) return false; @@ -554,7 +563,7 @@ } -bool CLangData::ReadTranslation(PCTSTR pszFile, bool bUpdateTranslation) +bool CLangData::ReadTranslation(PCTSTR pszFile, bool bUpdateTranslation, bool bIgnoreVersion) { try { @@ -569,8 +578,18 @@ 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("")); + const uint_t uiVersion = cfg.register_string(_T("Info/Format version"), _T("1")); + cfg.read(pszFile); + // we don't support old language versions unless requested specifically + if(!bIgnoreVersion) + { + const tchar_t* pszVersion = cfg.get_string(uiVersion); + if(_tcscmp(pszVersion, TRANSLATION_FORMAT_VERSION) != 0) + return false; + } + const tchar_t* psz = cfg.get_string(uiLangName); if(!psz || psz[0] == _t('\0')) return false; @@ -636,6 +655,7 @@ 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); + cfg.set_string(_T("Info/Format version"), TRANSLATION_FORMAT_VERSION); tstring_t strText; for(translation_map::iterator it = m_mapTranslation.begin(); it != m_mapTranslation.end(); it++) Index: src/libictranslate/ResourceManager.h =================================================================== diff -u -r8443d0d98d380facaf07b540c8d98da08365b816 -rc04cbdd0e391ca357bd9b2a24ce8de3231bf3871 --- src/libictranslate/ResourceManager.h (.../ResourceManager.h) (revision 8443d0d98d380facaf07b540c8d98da08365b816) +++ src/libictranslate/ResourceManager.h (.../ResourceManager.h) (revision c04cbdd0e391ca357bd9b2a24ce8de3231bf3871) @@ -117,7 +117,7 @@ void Clear(); // operations bool ReadInfo(PCTSTR pszFile); - bool ReadTranslation(PCTSTR pszFile, bool bReadBase = false); + bool ReadTranslation(PCTSTR pszFile, bool bReadBase = false, bool bIgnoreVersion = false); void WriteTranslation(PCTSTR pszPath); // translation retrieving/setting