Blame | Last modification | View Log | RSS feed
#ifndef __LANGUAGES_H__
#define __LANGUAGES_H__
#include <spk.h>
enum Lang_Section { LANGSECTION_STARTUP, LANGSECTION_FILEDIALOG };
enum { LANGSTARTUP_ANOTHERINSTANCE_TITLE, LANGSTARTUP_ANOTHERINSTANCE };
#define LANGMAP std::map<std::string, std::string>
typedef struct SLanguageTexts {
int iLang;
LANGMAP texts;
} SLanguageTexts;
class CLanguages
{
public:
CLanguages() { m_iLanguage = -1; }
void SetLanguage(int lang) { m_iLanguage = lang; }
CyString GetText(int section, int id)
{
switch(section)
{
case LANGSECTION_STARTUP:
return GetText_Startup(id);
}
return Error(section, id);
}
CyString GetText_Startup(int id)
{
switch(id)
{
case LANGSTARTUP_ANOTHERINSTANCE_TITLE:
return "Another Instance Detected";
case LANGSTARTUP_ANOTHERINSTANCE:
return "Another instance of the plugin manager is already running";
}
return Error(LANGSECTION_STARTUP, id);
}
private:
CyString FindText(int section, int id)
{
SLanguageTexts *text = FindLanguageText();
if ( text )
{
LANGMAP::iterator itr = text->texts.find(CyString(CyString::Number(section) + ":" + CyString::Number(id)).ToString());
if ( itr != text->texts.end() )
return itr->second;
}
return GetText(section, id);
}
SLanguageTexts *FindLanguageText(int id = -1)
{
if ( id == -1 ) id = m_iLanguage;
for ( int i = 0; i < (int)m_lLanguages.size(); i++ )
{
if ( m_lLanguages.at(i).iLang == id )
return &m_lLanguages.at(i);
}
return NULL;
}
CyString Error(int section, int id)
{
return CyString("ReadText") + CyString::Number(section) + "-" + CyString::Number(id);
}
int m_iLanguage;
std::vector<SLanguageTexts> m_lLanguages;
};
#endif //__LANGUAGES_H__