spek

Acoustic spectrum analyser
git clone http://git.hanabi.in/repos/spek.git
Log | Files | Refs | README

commit d9ed0de8abe3bdab88f5e75ceaf6ded22a6c80e7
parent c588131005232d911a1f03c40bbc9080ccfd6aa5
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date:   Fri, 10 Aug 2012 10:59:01 -0700

Init locale

Diffstat:
Msrc/spek-platform.cc | 2+-
Msrc/spek-preferences.cc | 21++++++++++++++++++++-
Msrc/spek-preferences.hh | 3+++
Msrc/spek.cc | 11++++++++---
Msrc/spek.vala | 4----
5 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/src/spek-platform.cc b/src/spek-platform.cc @@ -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); diff --git a/src/spek-preferences.cc b/src/spek-preferences.cc @@ -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( diff --git a/src/spek-preferences.hh b/src/spek-preferences.hh @@ -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; }; diff --git a/src/spek.cc b/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 * 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 diff --git a/src/spek.vala b/src/spek.vala @@ -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://")) {