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

Proposed by GunChleoc
Status: Merged
Merged at revision: 8710
Proposed branch: lp:~widelands-dev/widelands/bug-1636586-editor-player-menu-i18n
Merge into: lp:widelands
Diff against target: 31 lines (+11/-3)
1 file modified
src/map_io/map_player_names_and_tribes_packet.cc (+11/-3)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1636586-editor-player-menu-i18n
Reviewer Review Type Date Requested Status
Notabilis diff Approve
Review via email: mp+345464@code.launchpad.net

Commit message

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

To post a comment you must log in.
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 3504. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/378151938.
Appveyor build 3309. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1636586_editor_player_menu_i18n-3309.

Revision history for this message
Notabilis (notabilis27) wrote :

Not tested but code is looking good.
One question: Why checking for both the localized and "plain" name variant when saving? In English they should resolve to the same name anyway (right?) and I don't see where the plain version can appear otherwise.

review: Approve (diff)
Revision history for this message
GunChleoc (gunchleoc) wrote :

You're right, the plain version is already taken care of during loading, so no need to check it when saving.

Thanks for the review!

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/map_io/map_player_names_and_tribes_packet.cc'
2--- src/map_io/map_player_names_and_tribes_packet.cc 2018-04-07 16:59:00 +0000
3+++ src/map_io/map_player_names_and_tribes_packet.cc 2018-05-15 03:58:57 +0000
4@@ -62,7 +62,13 @@
5 iterate_player_numbers(p, nr_players) {
6 Section& s = prof.get_safe_section(
7 (boost::format("player_%u") % static_cast<unsigned int>(p)).str());
8- map->set_scenario_player_name(p, s.get_string("name", ""));
9+
10+ // Replace empty or standard player names with localized standard player name
11+ std::string player_name = s.get_string("name", "");
12+ if (player_name.empty() || player_name == (boost::format("Player %u") % static_cast<unsigned int>(p)).str()) {
13+ player_name = (boost::format(_("Player %u")) % static_cast<unsigned int>(p)).str();
14+ }
15+ map->set_scenario_player_name(p, player_name);
16 map->set_scenario_player_tribe(p, s.get_string("tribe", ""));
17 map->set_scenario_player_ai(p, s.get_string("ai", ""));
18 map->set_scenario_player_closeable(p, s.get_bool("closeable", false));
19@@ -90,8 +96,10 @@
20 // Make sure that no player name is empty, and trim leading/trailing whitespaces.
21 std::string player_name = map.get_scenario_player_name(p);
22 boost::trim(player_name);
23- if (player_name.empty()) {
24- player_name = (boost::format(_("Player %u")) % static_cast<unsigned int>(p)).str();
25+
26+ // Save default player names as empty
27+ if (player_name == (boost::format(_("Player %u")) % static_cast<unsigned int>(p)).str()) {
28+ player_name = "";
29 }
30
31 Section& s = prof.create_section(section_key.c_str());

Subscribers

People subscribed via source and target branches

to status/vote changes: