Fix detection of in-place path_locale when RUN_IN_PLACE=0
authorsfan5 <sfan5@live.de>
Sat, 25 Apr 2020 13:44:32 +0000 (15:44 +0200)
committersfan5 <sfan5@live.de>
Mon, 27 Apr 2020 15:50:05 +0000 (17:50 +0200)
broken by 2349d31bae1bfc4d58fd88efbc88261e69b11dad (side effect)
fixes #9745

src/gettext.cpp
src/porting.cpp

index 81621ba891d10c29326ff7cd85520cb8c887cc12..6818004df158eb513abb659e47cc7d9f4b5c0007 100644 (file)
@@ -217,7 +217,10 @@ void init_gettext(const char *path, const std::string &configured_language,
 #endif
 #endif
 
-       static std::string name = lowercase(PROJECT_NAME);
+       std::string name = lowercase(PROJECT_NAME);
+       infostream << "Gettext: domainname=\"" << name
+               << "\" path=\"" << path << "\"" << std::endl;
+
        bindtextdomain(name.c_str(), path);
        textdomain(name.c_str());
 
index 76fd592d6083d81c171a3496156ac40df5535402..c0381ad063e310a5bd3fa59c7da717cb72cfc3c0 100644 (file)
@@ -598,18 +598,18 @@ void initializePaths()
 #if USE_GETTEXT
        bool found_localedir = false;
 #  ifdef STATIC_LOCALEDIR
-       if (STATIC_LOCALEDIR[0] && fs::PathExists(STATIC_LOCALEDIR)) {
+       /* STATIC_LOCALEDIR may be a generalized path such as /usr/share/locale that
+        * doesn't necessarily contain our locale files, so check data path first. */
+       path_locale = getDataPath("locale");
+       if (fs::PathExists(path_locale)) {
+               found_localedir = true;
+               infostream << "Using in-place locale directory " << path_locale
+                       << " even though a static one was provided." << std::endl;
+       } else if (STATIC_LOCALEDIR[0] && fs::PathExists(STATIC_LOCALEDIR)) {
                found_localedir = true;
                path_locale = STATIC_LOCALEDIR;
-               infostream << "Using locale directory " << STATIC_LOCALEDIR << std::endl;
-       } else {
-               path_locale = getDataPath("locale");
-               if (fs::PathExists(path_locale)) {
-                       found_localedir = true;
-                       infostream << "Using in-place locale directory " << path_locale
-                               << " even though a static one was provided "
-                               << "(RUN_IN_PLACE or CUSTOM_LOCALEDIR)." << std::endl;
-               }
+               infostream << "Using static locale directory " << STATIC_LOCALEDIR
+                       << std::endl;
        }
 #  else
        path_locale = getDataPath("locale");