예제 #1
0
	bool OnInit(void)
	{
		wxArrayString lcids;
		lcids.Add(wxT("en_US"));
		lcids.Add(wxT("sk_SK"));
		wxString lcid(
			wxGetSingleChoice(
				wxT("Pick a locale"),
				wxT("Locale"),
				lcids
			)
		);
		const wxLanguageInfo* lci = wxLocale::FindLanguageInfo(lcid);
		if((lci != nullptr) && appLocale.Init(lci->Language, 0))
		{
			wxStandardPaths stdPaths;
			wxFileName localePath(stdPaths.GetExecutablePath());
			localePath.SetName(wxEmptyString);
			localePath.AppendDir(wxT("locale"));
			appLocale.AddCatalogLookupPathPrefix(
				localePath.GetFullPath()
			);
			appLocale.AddCatalog(wxT("test"));
		}
		SetTopWindow(new TestFrame);
		return true;
	}
예제 #2
0
파일: szapp.cpp 프로젝트: marta09/szarp
void szAppImpl::InitializeLocale(wxArrayString &catalogs, wxLocale &locale) {

	wxString lang = wxConfig::Get()->Read(_T("LANGUAGE"), AUTO_LANGUAGE);
	if (lang == AUTO_LANGUAGE)
		lang = DEFAULT_LANGUAGE;

	const wxLanguageInfo *info = wxLocale::FindLanguageInfo(lang);

	int l;

	if (info)
	{
		l = info->Language;
	} else
		l = wxLANGUAGE_ENGLISH;

	locale.Init(l);

	if (!locale.IsOk()) {
		if(locale.IsAvailable(locale.GetSystemLanguage())) {
			l = locale.GetSystemLanguage();
			locale.Init(l);
			if(!locale.IsOk()) {
				wxMessageBox(_("Default locale cannot be loaded. Exiting"), _("Information."), wxICON_ERROR);
				exit(1);
			}
			wxString Ls = L"Locale " + lang + L" not available.\nDefault system locale loaded.";
			wxMessageBox(_(s), _("Information."), wxICON_INFORMATION);
		}
		else {
			wxLogWarning(_("No locale for this system`s language."));
		}
	}

	locale.AddCatalogLookupPathPrefix(GetSzarpDir() + _T("resources/locales"));

	for(size_t i = 0; i < catalogs.Count(); i++)
		locale.AddCatalog(catalogs[i]);

#ifdef __WXGTK__
	if (!locale.IsOk()) {
		wxLogInfo(_("Setting locale to \"C\""));
		setenv("LC_ALL", "C", 1);
	} else if( locale.GetSystemEncodingName() == _("") ) { // this probably doesn't happen on unix machines 
		wxLogInfo(_("wx: Setting locale to \"") + locale.GetCanonicalName() + _("\""));
		setenv("LC_ALL", SC::S2A(locale.GetCanonicalName()).c_str(), 1);
	} else {
		wxString localename = locale.GetCanonicalName() + _(".") + locale.GetSystemEncodingName();
		wxLogInfo(_("wx: Setting locale to \"") + localename + _("\""));
		setenv("LC_ALL", SC::S2A(localename).c_str(), 1);
	}
#endif

}
예제 #3
0
bool MyApp::OnInit()
{
    m_locale.Init();
#ifdef APP_LOCALE_DIR
    m_locale.AddCatalogLookupPathPrefix(wxT(APP_LOCALE_DIR));
#endif
    m_locale.AddCatalog(wxT(APP_CATALOG));

    wxInitAllImageHandlers();
    MyFrame* frame_1 = new MyFrame(NULL, wxID_ANY, wxEmptyString);
    SetTopWindow(frame_1);
    frame_1->Show();
    return true;
}
예제 #4
0
파일: main.cpp 프로젝트: EasyRPG/Editor-wx
bool AppEditor::OnInit()
{
    m_locale.Init();
#ifdef APP_LOCALE_DIR
    m_locale.AddCatalogLookupPathPrefix(wxT(APP_LOCALE_DIR));
#endif
    m_locale.AddCatalog(wxT(APP_CATALOG));

    wxInitAllImageHandlers();
    FrameEditor* frmEditor = new FrameEditor(NULL, wxID_ANY, wxEmptyString);
    SetTopWindow(frmEditor);
    frmEditor->Show();
    return true;
}
예제 #5
0
bool MyApp::OnInit()
{
    m_locale.Init();
#ifdef APP_LOCALE_DIR
    m_locale.AddCatalogLookupPathPrefix(wxT(APP_LOCALE_DIR));
#endif
    m_locale.AddCatalog(wxT(APP_CATALOG));

    wxInitAllImageHandlers();
    WMain_wxg* wmain = new WMain_wxg(NULL, wxID_ANY, wxEmptyString);
    SetTopWindow(wmain);
    wmain->Show();
    return true;
}
예제 #6
0
파일: main.cpp 프로젝트: fujii/digdic
/**
 * 初期処理
 */
bool DicApp::OnInit()
{
	// カレントフォルダを実行ファイルの場所にする。
	::wxSetWorkingDirectory(::wxPathOnly(argv[0]));

	// メッセージカタログの設定をする。
	m_locale.Init(wxLANGUAGE_DEFAULT);
	m_locale.AddCatalogLookupPathPrefix(wxT("locale"));
	m_locale.AddCatalog(wxT("digdic"));
	
#if 0
	// 設定ファイルの設定をする。
	wxString iniDir = wxStandardPaths::Get().GetUserDataDir();
	wxFileName::Mkdir(iniDir, 0777, wxPATH_MKDIR_FULL);
	wxFileName fn = wxFileName(iniDir, GetAppName(), wxT("ini"));
	DicShare::iniFile = fn.GetFullPath();
	wxFileConfig* config = new wxFileConfig(
		wxEmptyString,
		wxEmptyString,
		DicShare::iniFile,
		wxEmptyString,
		wxCONFIG_USE_LOCAL_FILE,
		*wxConvCurrent);
#else
	// レジストリを使う。
	wxConfig* config = new wxConfig(
		wxT("digdic"),
		wxT("digdic"),
		wxEmptyString,
		wxEmptyString,
		wxCONFIG_USE_LOCAL_FILE);
#endif
	wxConfigBase::Set(config);

	// 共通の設定を読み込む。
	DicShare::LoadConfig();
	
    wxInitAllImageHandlers();
    DicMainFrame* main_frame = new DicMainFrame(0, -1, wxT(""));
    SetTopWindow(main_frame);
    main_frame->Show();
    return true;
}
예제 #7
0
파일: main.cpp 프로젝트: aircool00/v0.82
        bool OnInit()
        {
            //i18n/l10n:
            //20120603: Change suggested by Juan Pizarro to solve the i18n bug in some Windows and Linux machines:
            //if ( !locale.Init(wxLANGUAGE_DEFAULT, wxLOCALE_CONV_ENCODING) )
#if defined (linux)
            wxLogNull logNo;
#endif
            if ( !locale.Init(wxLANGUAGE_ENGLISH, wxLOCALE_CONV_ENCODING) )
                wxLogWarning(_("Error #1: This language is not supported by the system."));

            wxString lanPath(wxStandardPaths::Get().GetExecutablePath().BeforeLast(wxFileName::GetPathSeparator()) +
                             wxFileName::GetPathSeparator() + wxString("GUI") +
                             wxFileName::GetPathSeparator() + wxString("Texts") //##Unhardcode this in the future? I'm not sure...
                            );
            wxLocale::AddCatalogLookupPathPrefix(lanPath);
            wxString initialCatalogName("en.mo"); //This basic English catalog must exist.
            //wxString initialCatalogName("es.mo"); //##Debug...
            if (!locale.AddCatalog(initialCatalogName))
            {
                //##Future: See if future wxLocale implementations solve this problem:
                wxLogWarning(   _("Error #1: The installation path\n\n\"") + wxStandardPaths::Get().GetExecutablePath() +
                                _("\"\n\ncontains non-English chars.\n") +
                                _("Please try to install Minibloq on a location without this kind of chars. ") +
                                _("Otherwise, the program will run, but the translation system will not work properly.")
                            );
                //wxLogWarning(_("Error #2: Can't load ") + initialCatalogName);
            }

            MainFrame* frame = NULL;
            wxString caption = wxString("miniBloq v0.82.Beta");
            wxPoint framePosition = wxDefaultPosition;
            wxSize frameSize = wxDefaultSize;
            long style = wxDEFAULT_FRAME_STYLE;

            //Default values:
            initialFrameX = 0;
            initialFrameY = 0;
            initialFrameHeight = 600;
            initialFrameWidth = 800;
            maximized = true;
            centered = true;
            strBoard = wxString("");

            //Try to read the configuration file:
            readConfig();

            //Priorities:
            //  maximized has priority over all the other pos and size settings.
            //  centered has priority over x and y settings.
            if (maximized)
                style = style | wxMAXIMIZE;
            if ( (initialFrameWidth > 0) && (initialFrameHeight > 0) )
            {
                framePosition = wxPoint(initialFrameX, initialFrameY);
                frameSize = wxSize(initialFrameWidth, initialFrameHeight);
            }
            frame = new MainFrame(  NULL,
                                    wxID_ANY,
                                    locale,
                                    lanPath,
                                    initialCatalogName,
                                    caption,
                                    strBoard,
                                    framePosition,
                                    frameSize,
                                    style
                                  );
            /*## Future: Full screen:
            wxFrame* frame = new MainFrame(NULL,
                                         wxID_ANY,
                                         wxString("Minibloq v1.0"),
                                         wxDefaultPosition,
                                         wxSize(1280, 800),
                                         wxCLIP_CHILDREN);
            */
            if (frame)
            {
                if (centered)
                    frame->Centre();
                frame->setCentered(centered);

                SetTopWindow(frame);
                frame->Show();
                if (maximized)
                {
                    frame->Maximize();
                }
                if (argc > 0)
                {
                    wxString fileName = argv[1];
                    if (wxFile::Exists(fileName))
                    {
                        frame->loadFileComponent(fileName);
                    }
                }
            }

            return true;
        }
예제 #8
0
bool MadEditApp::OnInit()
{
    xm::EncodingManager::PreInit();

    xm::RemoteAccessInit();

	wxm::AppPath::Instance().Init(GetAppName());

    // parse commandline to filelist
    wxm::FileList filelist;
    for(int i=1; i<argc; i++)
    {
        wxFileName filename(argv[i]);
        filename.MakeAbsolute();
        filelist.Append(filename.GetFullPath());
    }

    // init wxConfig
	wxFileConfig *cfg=new wxFileConfig(wxEmptyString, wxEmptyString, wxm::AppPath::Instance().ConfigPath(), 
	                                   wxEmptyString, wxCONFIG_USE_RELATIVE_PATH|wxCONFIG_USE_NO_ESCAPE_CHARACTERS);
    cfg->SetExpandEnvVars(false);
    cfg->SetRecordDefaults(true);
    wxFileConfig::Set(cfg);

    bool bSingleInstance=true;
    cfg->Read(wxT("/wxMEdit/SingleInstance"), &bSingleInstance, true);

    // check SingleInstance and send filelist to previous instance
    if(bSingleInstance && OpenFilesInPrevInst(filelist.String()))
        return false;

#ifdef __WXGTK__
    bool bDisableWarningMessage = true;
    cfg->Read(wxT("/wxMEdit/DisableWarningMessage"), &bDisableWarningMessage, true);
    if(bDisableWarningMessage)
    {
        // redirect "IPP request failed" message to /dev/null
        int fdnull = open ("/dev/null", O_WRONLY, 0);
        if(fdnull >= 0)
        {
            dup2(fdnull, STDERR_FILENO);
        }
    }
#endif


    // init locale
    wxString strlang;
    cfg->Read(wxT("/wxMEdit/Language"), &strlang);
    int lang=g_LanguageValue[0];
    if(!strlang.IsEmpty())
    {
        strlang.MakeLower();
        for(size_t idx=1; idx<g_LanguageCount; idx++)
        {
            if(strlang == wxString(g_LanguageString[idx]).Lower())
            {
                lang=g_LanguageValue[idx];
                break;
            }
        }
    }

    wxm::AppPath& path = wxm::AppPath::Instance();
    g_Locale.Init(lang);
    g_Locale.AddCatalogLookupPathPrefix(wxT("./locale/"));
    g_Locale.AddCatalogLookupPathPrefix(path.AppDir() + wxT("locale/"));
    if (path.AppDir() != path.HomeDir())
        g_Locale.AddCatalogLookupPathPrefix(path.HomeDir() + wxT("locale/"));
#ifndef __WXMSW__
# ifdef DATA_DIR
    g_Locale.AddCatalogLookupPathPrefix(wxT(DATA_DIR"/locale/"));
# endif
#endif

    g_Locale.AddCatalog(wxT("wxmedit"));

    // set colors
    wxm::SetL10nHtmlColors();

    wxm::UpdatePeriods::Instance().Initialize();

#if defined(__WXMSW__) || defined(__WXGTK__)
    bool maximize=false;
    cfg->Read(wxT("/wxMEdit/WindowMaximize"), &maximize, false);
#endif
    wxPoint pos=wxDefaultPosition;
    wxSize size;
    wxRect rect = wxGetClientDisplayRect(); // FIXME: multi-monitor
    size.x = std::min(rect.width, wxm::DEFAULT_WINDOW_WIDTH);
    size.y = std::min(rect.height, wxm::DEFAULT_WINDOW_HEIGHT);

    long x=0,y=0,w=0,h=0;
    cfg->Read(wxT("/wxMEdit/WindowLeft"), &x);
    cfg->Read(wxT("/wxMEdit/WindowTop"), &y);
    cfg->Read(wxT("/wxMEdit/WindowWidth"), &w);
    cfg->Read(wxT("/wxMEdit/WindowHeight"), &h);

    if(x+w>0 && y+h>0)
    //if(w>0 && h>0)
    {
        size.x=w;
        size.y=h;

        pos.x=x;
        pos.y=y;
    }

    // load FontWidth buffers
    cfg->Read(wxT("/wxMEdit/FontWidthBufferMaxCount"), &FontWidthManager::MaxCount, 10);
    if(FontWidthManager::MaxCount < 4) FontWidthManager::MaxCount=4;
    else if(FontWidthManager::MaxCount>40) FontWidthManager::MaxCount=40;
    FontWidthManager::Init(wxm::AppPath::Instance().HomeDir());


    // create the main frame
    MadEditFrame *myFrame = new MadEditFrame(nullptr, 1 , wxEmptyString, pos, size);
    SetTopWindow(myFrame);

#if defined(__WXMSW__) || defined(__WXGTK__)
    if (maximize)
        myFrame->Maximize(true);
#endif

    myFrame->Show(true);


#if defined(__WXGTK__) && wxMAJOR_VERSION == 2
    if(bSingleInstance)
    {
        GtkPizza *pizza = GTK_PIZZA(myFrame->m_mainWidget);
        Window win=GDK_WINDOW_XWINDOW(pizza->bin_window);
        XSetSelectionOwner(g_Display, g_MadEdit_atom, win, CurrentTime);
        gdk_window_add_filter(nullptr, my_gdk_filter, nullptr);
    }
#endif

    wxm::AutoCheckUpdates(cfg);

    // reload files previously opened
    wxString files;
    cfg->Read(wxT("/wxMEdit/ReloadFilesList"), &files);
    files += filelist.String();

    if(!files.IsEmpty())
    {
        // use OnReceiveMessage() to open the files
        OnReceiveMessage(files.c_str(), (files.size()+1)*sizeof(wxChar));
    }

    if(myFrame->OpenedFileCount()==0)
    {
        myFrame->OpenFile(wxEmptyString, false);
    }

    return true;
}
예제 #9
0
bool AddLocaleCatalog( wxString catalog )
{
      return locale_def_lang.AddCatalog( catalog );
}
예제 #10
0
// `Main program' equivalent, creating windows and returning main app frame
bool MyApp::OnInit()
{
    if ( !wxApp::OnInit() )
        return false;

    if ( m_lang == wxLANGUAGE_UNKNOWN )
    {
        int lng = wxGetSingleChoiceIndex
                  (
                    _("Please choose language:"),
                    _("Language"),
                    WXSIZEOF(langNames),
                    langNames
                  );
        m_lang = lng == -1 ? wxLANGUAGE_DEFAULT : langIds[lng];
    }

    // don't use wxLOCALE_LOAD_DEFAULT flag so that Init() doesn't return
    // false just because it failed to load wxstd catalog
    if ( !m_locale.Init(m_lang, wxLOCALE_DONT_LOAD_DEFAULT) )
    {
        wxLogWarning(_("This language is not supported by the system."));

        // continue nevertheless
    }

    // normally this wouldn't be necessary as the catalog files would be found
    // in the default locations, but when the program is not installed the
    // catalogs are in the build directory where we wouldn't find them by
    // default
    wxLocale::AddCatalogLookupPathPrefix(".");

    // Initialize the catalogs we'll be using
    const wxLanguageInfo* pInfo = wxLocale::GetLanguageInfo(m_lang);
    if (!m_locale.AddCatalog("internat"))
    {
        wxLogError(_("Couldn't find/load the 'internat' catalog for locale '%s'."),
                   pInfo ? pInfo->GetLocaleName() : _("unknown"));
    }

    // Now try to add wxstd.mo so that loading "NOTEXIST.ING" file will produce
    // a localized error message:
    m_locale.AddCatalog("wxstd");
        // NOTE: it's not an error if we couldn't find it!

    // this catalog is installed in standard location on Linux systems and
    // shows that you may make use of the standard message catalogs as well
    //
    // if it's not installed on your system, it is just silently ignored
#ifdef __LINUX__
    {
        wxLogNull noLog;
        m_locale.AddCatalog("fileutils");
    }
#endif

    // Create the main frame window
    MyFrame *frame = new MyFrame(m_locale);

    // Show the frame
    frame->Show(true);

    return true;
}
예제 #11
0
파일: main.cpp 프로젝트: id-fga/minibloq
        bool OnInit()
        {

#if DEBUG
            wxLogWarning("MODO DEBUG");
#else
            wxSetAssertHandler(NULL);
#endif

            //i18n/l10n:
            //20120603: Change suggested by Juan Pizarro to solve the i18n bug in some Windows and Linux machines:
            //if ( !locale.Init(wxLANGUAGE_DEFAULT, wxLOCALE_CONV_ENCODING) )

#if !defined(linux)
            wxLogWarning("Esta version esta desarrollada exclusivamente para Linux");
            return true;
#endif


/*
#if defined (linux)
            wxLogNull logNo;
#endif
*/
            /*
            if ( !locale.Init(wxLANGUAGE_ENGLISH, wxLOCALE_CONV_ENCODING) )
                wxLogWarning(_("Error #1: This language is not supported by the system."));
            */

            /*
            wxString lanPath(wxStandardPaths::Get().GetExecutablePath().BeforeLast(wxFileName::GetPathSeparator()) +
                             wxFileName::GetPathSeparator() + wxString("GUI") +
                             wxFileName::GetPathSeparator() + wxString("Texts") //##Unhardcode this in the future? I'm not sure...
                            );
            */


            //wxString lanPath = wxStandardPaths::Get().GetExecutablePath().BeforeLast(wxFileName::GetPathSeparator()) + "/../../GUI/Texts/";
            //wxLocale::AddCatalogLookupPathPrefix(lanPath);

	    wxString lanPath = "/usr/share";
	    locale.AddCatalogLookupPathPrefix(lanPath);


            //Por defecto debe levantar en Castellano
            //wxString initialCatalogName("es.mo");

	    wxString initialCatalogName = "Minibloq.mo";

            //wxString initialCatalogName("es.mo"); //##Debug...
            if (!locale.AddCatalog(initialCatalogName))
            {
                //##Future: See if future wxLocale implementations solve this problem:
                wxLogWarning(   _("Error #1: The installation path\n\n\"") + wxStandardPaths::Get().GetExecutablePath() +
                                _("\"\n\ncontains non-English chars.\n") +
                                _("Please try to install Minibloq on a location without this kind of chars. ") +
                                _("Otherwise, the program will run, but the translation system will not work properly.")
                            );
                //wxLogWarning(_("Error #2: Can't load ") + initialCatalogName);
                printf("NO ENCUENTRO EL CATALOGO\n");
            }

            MainFrame* frame = NULL;

            wxString caption = wxString(wxString("miniBloq ") + MINIBLOQ_VERSION);
            wxPoint framePosition = wxDefaultPosition;
            wxSize frameSize = wxDefaultSize;
            long style = wxDEFAULT_FRAME_STYLE;

            //Default values:
            initialFrameX = 0;
            initialFrameY = 0;
            initialFrameHeight = 600;
            initialFrameWidth = 800;
            maximized = true;
            centered = true;
            strBoard = wxString("");

            //Try to read the configuration file:
            readConfig();

            //Priorities:
            //  maximized has priority over all the other pos and size settings.
            //  centered has priority over x and y settings.
            if (maximized)
                style = style | wxMAXIMIZE;
            if ( (initialFrameWidth > 0) && (initialFrameHeight > 0) )
            {
                framePosition = wxPoint(initialFrameX, initialFrameY);
                frameSize = wxSize(initialFrameWidth, initialFrameHeight);
            }

            //TODO: Chequeo de errores
	    wxString execPath = wxStandardPaths::Get().GetExecutablePath().BeforeLast(wxFileName::GetPathSeparator()); 
	    wxString splashImg = execPath + "/../../GUI/Images/minibloqSplash.png";

            wxBitmap splashPng;
            splashPng.LoadFile(splashImg);
            wxSplashScreen* splash = new wxSplashScreen(splashPng,
                                                        wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT,
                                                        3000,
                                                        NULL,
                                                        -1,
                                                        wxDefaultPosition,
                                                        wxDefaultSize,
                                                        wxBORDER_SIMPLE|wxSTAY_ON_TOP);

            wxYield();


            frame = new MainFrame(  NULL,
                                    wxID_ANY,
                                    locale,
                                    lanPath,
                                    initialCatalogName,
                                    caption,
                                    strBoard,
                                    framePosition,
                                    frameSize,
                                    style
                                  );
            /*## Future: Full screen:
            wxFrame* frame = new MainFrame(NULL,
                                         wxID_ANY,
                                         wxString("Minibloq v1.0"),
                                         wxDefaultPosition,
                                         wxSize(1280, 800),
                                         wxCLIP_CHILDREN);
            */
            if (frame)
            {
                if (centered)
                    frame->Centre();
                frame->setCentered(centered);

                SetTopWindow(frame);
                frame->Show();
                if (maximized)
                {
                    frame->Maximize();
                }
                if (argc > 0)
                {
                    wxString fileName = argv[1];
                    if (wxFile::Exists(fileName))
                    {
                        frame->loadFileComponent(fileName);
                    }
                }
            }

            return true;
        }