Merge lp:~widelands-dev/widelands/bug-1798297-locale-C into lp:widelands

Proposed by GunChleoc on 2018-11-06
Status: Merged
Merged at revision: 8935
Proposed branch: lp:~widelands-dev/widelands/bug-1798297-locale-C
Merge into: lp:widelands
Diff against target: 35 lines (+16/-5)
1 file modified
src/base/i18n.cc (+16/-5)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1798297-locale-C
Reviewer Review Type Date Requested Status
Widelands Developers 2018-11-06 Pending
Review via email: mp+358364@code.launchpad.net

Commit message

Fix fetching of translations when user locale is set to C. If the desired Widelands locale does not exist, try to fall back to en_US.utf8 to make libintl happy.

To post a comment you must log in.
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4193. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/452673990.
Appveyor build 3989. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1798297_locale_C-3989.

8909. By GunChleoc on 2018-11-16

Merged trunk.

bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4235. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/455848130.
Appveyor build 4031. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1798297_locale_C-4031.

Arty (artydent) wrote :

Code LGTM, just some minor indentation irregularities (see comments below).

Not tested because I don't have a working Linux system atm.

GunChleoc (gunchleoc) wrote :

I tested this pretty thoroughly on Linux, so it should be fine.

Bunnybot will take care of the indentation.

Thanks for the review! :)

@bunnybot merge

bunnybot (widelandsofficial) wrote :

Refusing to merge, since Travis is not green. Use @bunnybot merge force for merging anyways.

Travis build 4235. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/455848130.

GunChleoc (gunchleoc) wrote :

Transient failure on Travis

@bunnybot merge force

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/base/i18n.cc'
--- src/base/i18n.cc 2018-08-12 06:47:11 +0000
+++ src/base/i18n.cc 2018-11-16 06:30:53 +0000
@@ -290,15 +290,26 @@
290 found = alt_str.find(',', 0);290 found = alt_str.find(',', 0);
291 }291 }
292 if (leave_while) {292 if (leave_while) {
293 setenv("LANG", locale.c_str(), 1);293 setenv("LC_ALL", locale.c_str(), 1);
294 setenv("LANG", locale.c_str(), 1);
294 setenv("LANGUAGE", locale.c_str(), 1);295 setenv("LANGUAGE", locale.c_str(), 1);
295 } else {296 } else {
296 log("No corresponding locale found - trying to set it via LANGUAGE=%s, LANG=%s\n",297 log("No corresponding locale found\n");
297 lang.c_str(), lang.c_str());298 log(" - Set LANGUAGE, LANG and LC_ALL to '%s'\n",
299 lang.c_str());
300
298 setenv("LANGUAGE", lang.c_str(), 1);301 setenv("LANGUAGE", lang.c_str(), 1);
299 setenv("LANG", lang.c_str(), 1);302 setenv("LANG", lang.c_str(), 1);
300 SETLOCALE(LC_MESSAGES, ""); // set locale according to the env. variables303 setenv("LC_ALL", lang.c_str(), 1);
301 // --> see $ man 3 setlocale304
305 try {
306 SETLOCALE(LC_MESSAGES, "en_US.utf8"); // set locale according to the env. variables
307 // --> see $ man 3 setlocale
308 log(" - Set system locale to 'en_US.utf8' to make '%s' accessible to libintl\n", lang.c_str());
309 } catch (std::exception&) {
310 SETLOCALE(LC_MESSAGES, ""); // set locale according to the env. variables
311 // --> see $ man 3 setlocale
312 }
302 // assume that it worked313 // assume that it worked
303 // maybe, do another check with the return value (?)314 // maybe, do another check with the return value (?)
304 locale = lang;315 locale = lang;