struct Language
{
UINT nDlgId;
UINT nStringId[lang_num];
};
static const Language structlanguage[] =
{
{ID_FILE_NEW, {ID_FILE_NEW, ID_FILE_NEW_ENG}},
{ID_FILE_OPEN, {ID_FILE_OPEN, ID_FILE_OPEN_ENG}},
{ID_FILE_SAVE, {ID_FILE_SAVE, ID_FILE_SAVE_ENG}},
};
for (int _i = 0; _i < _countof(structlanguage); ++_i)
{
LoadString(structlanguage[_i].nStringId[m_nLanguage], _strTxt);
m_LangString.insert(langStringPair(structlanguage[_i].nDlgId, _strTxt));
}
int LangLoadString(UINT nID_, LPTSTR lpszBuf_, UINT nMaxBuf_ = 256);
typedef std::pair<int, CString> langStringPair;
m_LangString.clear();
CString _strTxt;
for (int _i = 0; _i < _countof(structlanguage); ++_i)
{
LoadString(structlanguage[_i].nStringId[m_nLanguage], _strTxt);
m_LangString.insert(langStringPair(structlanguage[_i].nDlgId, _strTxt));
}
int CAxesErrEditorView::LangLoadString(UINT nID_, LPTSTR lpszBuf_, UINT nMaxBuf_ )
{
CString _strTxt;
TStringMap::const_iterator _it;
_it = m_LangString.find(nID_);
if (_it != m_LangString.end())
{
_strTxt = _it->second;
_tcsncpy(lpszBuf_, _strTxt, min((_strTxt.GetLength()+2), int(nMaxBuf_)));
return _strTxt.GetLength();
}
DWORD _nRet = AfxLoadString(nID_, lpszBuf_, nMaxBuf_);
if (_nRet)
{
_strTxt = lpszBuf_;
m_LangString.insert(langStringPair(nID_, _strTxt));
}
return _nRet;
}