Translated using Weblate (Japanese)
[oweals/minetest.git] / src / porting.cpp
index cb9f3270bea76533a9214d8dce50fd25701eccbb..d0dfc801fcbd5e47957a52f163f66f0ff1cf73b2 100644 (file)
@@ -136,6 +136,8 @@ void signal_handler_init(void)
 // Default to RUN_IN_PLACE style relative paths
 std::string path_share = "..";
 std::string path_user = "..";
+std::string path_locale = path_share + DIR_DELIM + "locale";
+
 
 std::string getDataPath(const char *subpath)
 {
@@ -503,7 +505,6 @@ void initializePaths()
                path_share = execpath;
                path_user  = execpath;
        }
-
 #else
        infostream << "Using system-wide paths (NOT RUN_IN_PLACE)" << std::endl;
 
@@ -514,6 +515,32 @@ void initializePaths()
 
        infostream << "Detected share path: " << path_share << std::endl;
        infostream << "Detected user path: " << path_user << std::endl;
+
+       bool found_localedir = false;
+#ifdef STATIC_LOCALEDIR
+       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;
+               }
+       }
+#else
+       path_locale = getDataPath("locale");
+       if (fs::PathExists(path_locale)) {
+               found_localedir = true;
+       }
+#endif
+       if (!found_localedir) {
+               errorstream << "Couldn't find a locale directory!" << std::endl;
+       }
+
 }