← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1636586-editor-player-menu-i18n into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1636586-editor-player-menu-i18n into lp:widelands.

Commit message:
Fixed mix of localized / unlocalized default player names in editor. Default names are now saved as empty strings.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1636586 in widelands: "Inconsistent localization of player names in Editor player menu"
  https://bugs.launchpad.net/widelands/+bug/1636586

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1636586-editor-player-menu-i18n/+merge/345464
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1636586-editor-player-menu-i18n into lp:widelands.
=== modified file 'src/map_io/map_player_names_and_tribes_packet.cc'
--- src/map_io/map_player_names_and_tribes_packet.cc	2018-04-07 16:59:00 +0000
+++ src/map_io/map_player_names_and_tribes_packet.cc	2018-05-12 17:37:31 +0000
@@ -62,7 +62,13 @@
 			iterate_player_numbers(p, nr_players) {
 				Section& s = prof.get_safe_section(
 				   (boost::format("player_%u") % static_cast<unsigned int>(p)).str());
-				map->set_scenario_player_name(p, s.get_string("name", ""));
+
+				// Replace empty or standard player names with localized standard player name
+				std::string player_name = s.get_string("name", "");
+				if (player_name.empty() || player_name == (boost::format("Player %u") % static_cast<unsigned int>(p)).str()) {
+					player_name = (boost::format(_("Player %u")) % static_cast<unsigned int>(p)).str();
+				}
+				map->set_scenario_player_name(p, player_name);
 				map->set_scenario_player_tribe(p, s.get_string("tribe", ""));
 				map->set_scenario_player_ai(p, s.get_string("ai", ""));
 				map->set_scenario_player_closeable(p, s.get_bool("closeable", false));
@@ -90,8 +96,11 @@
 		// Make sure that no player name is empty, and trim leading/trailing whitespaces.
 		std::string player_name = map.get_scenario_player_name(p);
 		boost::trim(player_name);
-		if (player_name.empty()) {
-			player_name = (boost::format(_("Player %u")) % static_cast<unsigned int>(p)).str();
+
+		// Save default player names as empty
+		if (player_name == (boost::format("Player %u") % static_cast<unsigned int>(p)).str() ||
+			player_name == (boost::format(_("Player %u")) % static_cast<unsigned int>(p)).str()) {
+			player_name = "";
 		}
 
 		Section& s = prof.create_section(section_key.c_str());


Follow ups