Skip to content

Commit 2a9da62

Browse files
committedSep 10, 2015
Improve locale directory detection
Use in-place locale directory if that exists, and static one (RUN_IN_PLACE or CUSTOM_LOCALEDIR) doesn't exist. Report to errorstream if neither static nor in-place locale dirs exist, and report successfully found paths to infostreem. Fixes two bugs: -> Regression of commit [1] where if we use RUN_IN_PLACE=false, but don't make install, locales aren't found. One might think this is no regression, as its no bug, but all other paths (mainmenu, etc.) are detected properly. -> Regression of commit [1] where locales don't work on windows. References: [1]: Commit 645e208 "Use CUSTOM_LOCALEDIR if specified" by @ShadowNinja
1 parent 183d0d5 commit 2a9da62

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed
 

Diff for: ‎src/porting.cpp

+24-3
Original file line numberDiff line numberDiff line change
@@ -512,14 +512,35 @@ void initializePaths()
512512
errorstream << "Failed to get one or more system-wide path" << std::endl;
513513

514514
#endif
515+
516+
infostream << "Detected share path: " << path_share << std::endl;
517+
infostream << "Detected user path: " << path_user << std::endl;
518+
519+
bool found_localedir = false;
515520
#ifdef STATIC_LOCALEDIR
516-
path_locale = STATIC_LOCALEDIR[0] ? STATIC_LOCALEDIR : getDataPath("locale");
521+
if (STATIC_LOCALEDIR[0] && fs::PathExists(STATIC_LOCALEDIR)) {
522+
found_localedir = true;
523+
path_locale = STATIC_LOCALEDIR;
524+
infostream << "Using locale directory " << STATIC_LOCALEDIR << std::endl;
525+
} else {
526+
path_locale = getDataPath("locale");
527+
if (fs::PathExists(path_locale)) {
528+
found_localedir = true;
529+
infostream << "Using in-place locale directory " << path_locale
530+
<< " even though a static one was provided "
531+
<< "(RUN_IN_PLACE or CUSTOM_LOCALEDIR)." << std::endl;
532+
}
533+
}
517534
#else
518535
path_locale = getDataPath("locale");
536+
if (fs::PathExists(path_locale)) {
537+
found_localedir = true;
538+
}
519539
#endif
540+
if (!found_localedir) {
541+
errorstream << "Couldn't find a locale directory!" << std::endl;
542+
}
520543

521-
infostream << "Detected share path: " << path_share << std::endl;
522-
infostream << "Detected user path: " << path_user << std::endl;
523544
}
524545

525546

0 commit comments

Comments
 (0)
Please sign in to comment.