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); wxIMPLEMENT_APP(ZRColaApp);
ZRColaApp::ZRColaApp() :
m_config(wxT(ZRCOLA_CFG_APPLICATION), wxT(ZRCOLA_CFG_VENDOR)),
wxApp()
{
}
bool ZRColaApp::OnInit() bool ZRColaApp::OnInit()
{ {
if (!wxAppEx::OnInit()) if (!wxApp::OnInit())
return false; 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"))); wxVERIFY(m_locale.AddCatalog(wxT("ZRCola")));
}
wxZRColaFrame* mainFrame = new wxZRColaFrame(); wxZRColaFrame* mainFrame = new wxZRColaFrame();

View File

@ -25,15 +25,19 @@ class ZRColaApp;
#pragma once #pragma once
#include <wxex/appex.h> #include <wx/app.h>
#include <wx/config.h>
#include <wx/intl.h>
/// ///
/// ZRCola application /// ZRCola application
/// ///
class ZRColaApp : public wxAppEx class ZRColaApp : public wxApp
{ {
public: public:
ZRColaApp();
/// ///
/// Called when application initializes. /// Called when application initializes.
/// ///
@ -41,6 +45,10 @@ public:
/// - true if initialization succeeded /// - true if initialization succeeded
/// - false otherwise /// - false otherwise
virtual bool OnInit(); 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. // Set desired locale.
wxLocale locale; wxLocale locale;
{ wxLanguage language = (wxLanguage)config.Read(wxT("Language"), wxLANGUAGE_DEFAULT);
if (wxLocale::IsAvailable(language)) {
wxString sPath; wxString sPath;
if (config.Read(wxT("LocalizationRepositoryPath"), &sPath)) if (config.Read(wxT("LocalizationRepositoryPath"), &sPath))
locale.AddCatalogLookupPathPrefix(sPath); locale.AddCatalogLookupPathPrefix(sPath);
} wxVERIFY(locale.Init(language));
wxVERIFY(locale.Init(config.Read(wxT("Language"), wxLANGUAGE_DEFAULT)));
wxVERIFY(locale.AddCatalog(wxT("ZRColaCompile"))); wxVERIFY(locale.AddCatalog(wxT("ZRColaCompile")));
}
// Parse command line. // Parse command line.
static const wxCmdLineEntryDesc cmdLineDesc[] = static const wxCmdLineEntryDesc cmdLineDesc[] =