1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#include "LocalisationModule.h"
#include "i18n.h"
#include "ipreferencesystem.h"
#include "registry/registry.h"
#include "module/StaticModule.h"
#include "LocalisationProvider.h"
namespace settings
{
const std::string& LocalisationModule::getName() const
{
static std::string _name("LocalisationModule");
return _name;
}
const StringSet& LocalisationModule::getDependencies() const
{
static StringSet _dependencies;
if (_dependencies.empty())
{
_dependencies.insert(MODULE_PREFERENCESYSTEM);
_dependencies.insert(MODULE_XMLREGISTRY);
}
return _dependencies;
}
void LocalisationModule::initialiseModule(const IApplicationContext& ctx)
{
// Construct the list of available languages
ComboBoxValueList langs;
LocalisationProvider::Instance()->foreachAvailableLanguage([&](const LocalisationProvider::Language& lang)
{
langs.emplace_back(lang.twoDigitCode + " - " + lang.displayName);
});
auto registryKey = LocalisationProvider::RKEY_LANGUAGE;
// Load the currently selected index into the registry
registry::setValue(registryKey, LocalisationProvider::Instance()->getCurrentLanguageIndex());
GlobalRegistry().setAttribute(registryKey, "volatile", "1"); // don't save this to user.xml
// Add Preferences
IPreferencePage& page = GlobalPreferenceSystem().getPage(_("Settings/Language"));
page.appendCombo(_("Language"), registryKey, langs);
page.appendLabel(_("<b>Note:</b> You'll need to restart DarkRadiant\nafter changing the language setting."));
}
void LocalisationModule::shutdownModule()
{
LocalisationProvider::Instance()->saveLanguageSetting();
}
module::StaticModuleRegistration<LocalisationModule> localisationModule;
}
|