Init locale

This commit is contained in:
Alexander Kojevnikov 2012-08-10 10:59:01 -07:00
parent c588131005
commit d9ed0de8ab
5 changed files with 32 additions and 9 deletions

View File

@ -29,7 +29,7 @@ wxString SpekPlatform::ConfigPath(const wxString& app_name)
#ifdef OS_WIN
wxFileName file_name(wxStandardPaths::Get().GetUserConfigDir());
#else
wxFileName file_name(wxGetHomeDir());
wxFileName file_name(wxGetHomeDir(), wxEmptyString);
file_name.AppendDir(wxT(".config"));
#endif
file_name.AppendDir(app_name);

View File

@ -28,7 +28,26 @@ SpekPreferences& SpekPreferences::Get()
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"));
this->config = new wxFileConfig(

View File

@ -20,12 +20,14 @@
#define SPEK_PREFERENCES_HH_
#include <wx/fileconf.h>
#include <wx/intl.h>
class SpekPreferences
{
public:
static SpekPreferences& Get();
void Init();
bool GetCheckUpdate();
void SetCheckUpdate(bool value);
long GetLastUpdate();
@ -38,6 +40,7 @@ private:
SpekPreferences(const SpekPreferences&);
void operator=(const SpekPreferences&);
wxLocale *locale;
wxFileConfig *config;
};

View File

@ -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
* it under the terms of the GNU General Public License as published by
@ -19,6 +19,8 @@
#include <wx/cmdline.h>
#include <wx/log.h>
#include "spek-preferences.hh"
#include "spek-window.hh"
class Spek: public wxApp
@ -33,6 +35,8 @@ IMPLEMENT_APP(Spek)
bool Spek::OnInit()
{
SpekPreferences::Get().Init();
if (!wxApp::OnInit()) {
return false;
}
@ -46,7 +50,8 @@ bool Spek::OnInit()
void Spek::OnInitCmdLine(wxCmdLineParser& parser)
{
wxCmdLineEntryDesc desc[] = {{
wxCMD_LINE_SWITCH, wxT("h"),
wxCMD_LINE_SWITCH,
wxT("h"),
wxT("help"), _("Show this help message"),
wxCMD_LINE_VAL_NONE,
wxCMD_LINE_OPTION_HELP

View File

@ -26,10 +26,6 @@ namespace Spek {
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 ();
var file_name = files == null ? null : files[0];
if (file_name != null && file_name.has_prefix ("file://")) {