mirror of
https://github.com/alexkay/spek.git
synced 2025-06-20 08:44:18 +03:00
Init locale
This commit is contained in:
parent
c588131005
commit
d9ed0de8ab
@ -29,7 +29,7 @@ wxString SpekPlatform::ConfigPath(const wxString& app_name)
|
|||||||
#ifdef OS_WIN
|
#ifdef OS_WIN
|
||||||
wxFileName file_name(wxStandardPaths::Get().GetUserConfigDir());
|
wxFileName file_name(wxStandardPaths::Get().GetUserConfigDir());
|
||||||
#else
|
#else
|
||||||
wxFileName file_name(wxGetHomeDir());
|
wxFileName file_name(wxGetHomeDir(), wxEmptyString);
|
||||||
file_name.AppendDir(wxT(".config"));
|
file_name.AppendDir(wxT(".config"));
|
||||||
#endif
|
#endif
|
||||||
file_name.AppendDir(app_name);
|
file_name.AppendDir(app_name);
|
||||||
|
@ -28,7 +28,26 @@ SpekPreferences& SpekPreferences::Get()
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpekPreferences::SpekPreferences()
|
void SpekPreferences::Init()
|
||||||
|
{
|
||||||
|
if (this->locale) {
|
||||||
|
delete this->locale;
|
||||||
|
}
|
||||||
|
this->locale = new wxLocale();
|
||||||
|
|
||||||
|
int lang = wxLANGUAGE_DEFAULT;
|
||||||
|
wxString code = this->GetLanguage();
|
||||||
|
if (!code.IsEmpty()) {
|
||||||
|
const wxLanguageInfo *info = wxLocale::FindLanguageInfo(code);
|
||||||
|
if (info) {
|
||||||
|
lang = info->Language;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this->locale->Init(lang);
|
||||||
|
this->locale->AddCatalog(wxT(GETTEXT_PACKAGE));
|
||||||
|
}
|
||||||
|
|
||||||
|
SpekPreferences::SpekPreferences() : locale(NULL)
|
||||||
{
|
{
|
||||||
wxString path = SpekPlatform::ConfigPath(wxT("spek"));
|
wxString path = SpekPlatform::ConfigPath(wxT("spek"));
|
||||||
this->config = new wxFileConfig(
|
this->config = new wxFileConfig(
|
||||||
|
@ -20,12 +20,14 @@
|
|||||||
#define SPEK_PREFERENCES_HH_
|
#define SPEK_PREFERENCES_HH_
|
||||||
|
|
||||||
#include <wx/fileconf.h>
|
#include <wx/fileconf.h>
|
||||||
|
#include <wx/intl.h>
|
||||||
|
|
||||||
class SpekPreferences
|
class SpekPreferences
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static SpekPreferences& Get();
|
static SpekPreferences& Get();
|
||||||
|
|
||||||
|
void Init();
|
||||||
bool GetCheckUpdate();
|
bool GetCheckUpdate();
|
||||||
void SetCheckUpdate(bool value);
|
void SetCheckUpdate(bool value);
|
||||||
long GetLastUpdate();
|
long GetLastUpdate();
|
||||||
@ -38,6 +40,7 @@ private:
|
|||||||
SpekPreferences(const SpekPreferences&);
|
SpekPreferences(const SpekPreferences&);
|
||||||
void operator=(const SpekPreferences&);
|
void operator=(const SpekPreferences&);
|
||||||
|
|
||||||
|
wxLocale *locale;
|
||||||
wxFileConfig *config;
|
wxFileConfig *config;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
11
src/spek.cc
11
src/spek.cc
@ -1,6 +1,6 @@
|
|||||||
/* spek.vala
|
/* spek.cc
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010-2011 Alexander Kojevnikov <alexander@kojevnikov.com>
|
* Copyright (C) 2010-2012 Alexander Kojevnikov <alexander@kojevnikov.com>
|
||||||
*
|
*
|
||||||
* Spek is free software: you can redistribute it and/or modify
|
* Spek is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -19,6 +19,8 @@
|
|||||||
#include <wx/cmdline.h>
|
#include <wx/cmdline.h>
|
||||||
#include <wx/log.h>
|
#include <wx/log.h>
|
||||||
|
|
||||||
|
#include "spek-preferences.hh"
|
||||||
|
|
||||||
#include "spek-window.hh"
|
#include "spek-window.hh"
|
||||||
|
|
||||||
class Spek: public wxApp
|
class Spek: public wxApp
|
||||||
@ -33,6 +35,8 @@ IMPLEMENT_APP(Spek)
|
|||||||
|
|
||||||
bool Spek::OnInit()
|
bool Spek::OnInit()
|
||||||
{
|
{
|
||||||
|
SpekPreferences::Get().Init();
|
||||||
|
|
||||||
if (!wxApp::OnInit()) {
|
if (!wxApp::OnInit()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -46,7 +50,8 @@ bool Spek::OnInit()
|
|||||||
void Spek::OnInitCmdLine(wxCmdLineParser& parser)
|
void Spek::OnInitCmdLine(wxCmdLineParser& parser)
|
||||||
{
|
{
|
||||||
wxCmdLineEntryDesc desc[] = {{
|
wxCmdLineEntryDesc desc[] = {{
|
||||||
wxCMD_LINE_SWITCH, wxT("h"),
|
wxCMD_LINE_SWITCH,
|
||||||
|
wxT("h"),
|
||||||
wxT("help"), _("Show this help message"),
|
wxT("help"), _("Show this help message"),
|
||||||
wxCMD_LINE_VAL_NONE,
|
wxCMD_LINE_VAL_NONE,
|
||||||
wxCMD_LINE_OPTION_HELP
|
wxCMD_LINE_OPTION_HELP
|
||||||
|
@ -26,10 +26,6 @@ namespace Spek {
|
|||||||
Environment.set_variable ("LANGUAGE", Preferences.instance.language, true);
|
Environment.set_variable ("LANGUAGE", Preferences.instance.language, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Platform.locale_dir ());
|
|
||||||
Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
|
|
||||||
Intl.textdomain (Config.GETTEXT_PACKAGE);
|
|
||||||
|
|
||||||
Audio.init ();
|
Audio.init ();
|
||||||
var file_name = files == null ? null : files[0];
|
var file_name = files == null ? null : files[0];
|
||||||
if (file_name != null && file_name.has_prefix ("file://")) {
|
if (file_name != null && file_name.has_prefix ("file://")) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user