Localization setup modified

This commit is contained in:
Simon Rozman 2016-03-14 17:06:26 +01:00
parent 3e3e311a62
commit 5edfe17fae
3 changed files with 32 additions and 7 deletions

View File

@ -27,13 +27,29 @@
wxIMPLEMENT_APP(ZRColaApp);
ZRColaApp::ZRColaApp() :
m_config(wxT(ZRCOLA_CFG_APPLICATION), wxT(ZRCOLA_CFG_VENDOR)),
wxApp()
{
}
bool ZRColaApp::OnInit()
{
if (!wxAppEx::OnInit())
if (!wxApp::OnInit())
return false;
if (wxLocale::IsAvailable(wxLANGUAGE_SLOVENIAN))
// Set desired locale.
wxLanguage language = (wxLanguage)m_config.Read(wxT("Language"), wxLANGUAGE_DEFAULT);
if (wxLocale::IsAvailable(language)) {
wxString sPath;
if (m_config.Read(wxT("LocalizationRepositoryPath"), &sPath))
m_locale.AddCatalogLookupPathPrefix(sPath);
wxVERIFY(m_locale.Init(language));
wxVERIFY(m_locale.AddCatalog(wxT("wxExtend")));
wxVERIFY(m_locale.AddCatalog(wxT("ZRColaCompile")));
wxVERIFY(m_locale.AddCatalog(wxT("ZRCola")));
}
wxZRColaFrame* mainFrame = new wxZRColaFrame();

View File

@ -25,15 +25,19 @@ class ZRColaApp;
#pragma once
#include <wxex/appex.h>
#include <wx/app.h>
#include <wx/config.h>
#include <wx/intl.h>
///
/// ZRCola application
///
class ZRColaApp : public wxAppEx
class ZRColaApp : public wxApp
{
public:
ZRColaApp();
///
/// Called when application initializes.
///
@ -41,6 +45,10 @@ public:
/// - true if initialization succeeded
/// - false otherwise
virtual bool OnInit();
protected:
wxConfig m_config; ///< Application configuration
wxLocale m_locale; ///< Current locale
};

View File

@ -150,13 +150,14 @@ int _tmain(int argc, _TCHAR *argv[])
// Set desired locale.
wxLocale locale;
{
wxLanguage language = (wxLanguage)config.Read(wxT("Language"), wxLANGUAGE_DEFAULT);
if (wxLocale::IsAvailable(language)) {
wxString sPath;
if (config.Read(wxT("LocalizationRepositoryPath"), &sPath))
locale.AddCatalogLookupPathPrefix(sPath);
}
wxVERIFY(locale.Init(config.Read(wxT("Language"), wxLANGUAGE_DEFAULT)));
wxVERIFY(locale.Init(language));
wxVERIFY(locale.AddCatalog(wxT("ZRColaCompile")));
}
// Parse command line.
static const wxCmdLineEntryDesc cmdLineDesc[] =