Author: ai0867
Date: Thu Oct 13 20:25:06 2011
New Revision: 51464
URL: http://svn.gna.org/viewcvs/wesnoth?rev=51464&view=rev
Log:
Add option --language/-L to select language for that session.
Modified:
trunk/changelog
trunk/src/commandline_options.cpp
trunk/src/commandline_options.hpp
trunk/src/game_controller_abstract.cpp
Modified: trunk/changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=51464&r1=51463&r2=51464&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Thu Oct 13 20:25:06 2011
@@ -54,6 +54,7 @@
* Fixed preload event not being fired (bug #18695)
* Make the create unit dialog give the created unit a valid gender for
that unit type. (bug #18704)
+ * Add --language/-L commandline option to set the language for that session
Version 1.9.9:
* AI:
Modified: trunk/src/commandline_options.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/commandline_options.cpp?rev=51464&r1=51463&r2=51464&view=diff
==============================================================================
--- trunk/src/commandline_options.cpp (original)
+++ trunk/src/commandline_options.cpp Thu Oct 13 20:25:06 2011
@@ -61,6 +61,7 @@
gunzip(),
gzip(),
help(),
+ language(),
log(),
load(),
logdomains(),
@@ -132,6 +133,7 @@
("gunzip", po::value<std::string>(), "decompresses a file
(<arg>.gz) in gzip format and stores it without the .gz suffix. <arg>.gz will
be removed.")
("gzip", po::value<std::string>(), "compresses a file (<arg>)
in gzip format, stores it as <arg>.gz and removes <arg>.")
("help,h", "prints this message and exits.")
+ ("language,L", po::value<std::string>(), "uses language <arg>
(symbol) this session. Example: --language ang_GB@latin")
("load,l", po::value<std::string>(), "loads the save <arg> from
the standard save game directory. When launching the map editor via -e, the map
<arg> is loaded, relative to the current directory. If it is a directory, the
editor will start with a load map dialog opened there.")
("new-syntax", "enables the new campaign syntax parsing.")
("nocache", "disables caching of game data.")
@@ -274,6 +276,8 @@
help = true;
if (vm.count("label"))
multiplayer_label = vm["label"].as<std::string>();
+ if (vm.count("language"))
+ language = vm["language"].as<std::string>();
if (vm.count("load"))
load = vm["load"].as<std::string>();
if (vm.count("log-error"))
Modified: trunk/src/commandline_options.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/commandline_options.hpp?rev=51464&r1=51463&r2=51464&view=diff
==============================================================================
--- trunk/src/commandline_options.hpp (original)
+++ trunk/src/commandline_options.hpp Thu Oct 13 20:25:06 2011
@@ -67,6 +67,8 @@
boost::optional<std::string> gzip;
/// True if --help was given on the command line. Prints help and exits.
bool help;
+ /// Non-empty if --lang was given on the command line. Sets the
language for this session.
+ boost::optional<std::string> language;
/// Contains parsed arguments of --log-* (e.g. --log-debug).
/// Vector of pairs (severity, log domain).
boost::optional<std::vector<boost::tuple<int, std::string> > > log;
Modified: trunk/src/game_controller_abstract.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_controller_abstract.cpp?rev=51464&r1=51463&r2=51464&view=diff
==============================================================================
--- trunk/src/game_controller_abstract.cpp (original)
+++ trunk/src/game_controller_abstract.cpp Thu Oct 13 20:25:06 2011
@@ -15,6 +15,7 @@
#include "game_controller_abstract.hpp"
+#include "foreach.hpp"
#include "game_display.hpp"
#include "gettext.hpp"
#include "hotkeys.hpp"
@@ -76,7 +77,23 @@
if(!::load_language_list())
return false;
- ::set_language(get_locale());
+ language_def locale;
+ if(cmdline_opts_.language) {
+ std::vector<language_def> langs = get_languages();
+ foreach(const language_def & def, langs) {
+ if(def.localename == *cmdline_opts_.language) {
+ locale = def;
+ break;
+ }
+ }
+ if(locale.localename.empty()) {
+ std::cerr << "Language symbol '" <<
*cmdline_opts_.language << "' not found.\n";
+ return false;
+ }
+ } else {
+ locale = get_locale();
+ }
+ ::set_language(locale);
if(!cmdline_opts_.nogui) {
std::string wm_title_string = _("The Battle for Wesnoth");
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits