summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrzys-h <krzys_h@interia.pl>2014-10-31 21:23:10 +0100
committerkrzys-h <krzys_h@interia.pl>2014-10-31 21:23:10 +0100
commit25d5d105fdf0aa68509a9627eca3b0588f95c957 (patch)
tree15f404b0d0c6ca8af0723a160e354137bb7a8fb5
parentd0a2d662700ac8cf8441aaee64ec070a959d5794 (diff)
downloadcolobot-25d5d105fdf0aa68509a9627eca3b0588f95c957.tar.gz
colobot-25d5d105fdf0aa68509a9627eca3b0588f95c957.tar.bz2
colobot-25d5d105fdf0aa68509a9627eca3b0588f95c957.zip
Fallback to English files if translated ones are not available
-rw-r--r--src/object/level/parserparam.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/object/level/parserparam.cpp b/src/object/level/parserparam.cpp
index ee080b2..1f81f0e 100644
--- a/src/object/level/parserparam.cpp
+++ b/src/object/level/parserparam.cpp
@@ -22,6 +22,7 @@
#include "app/app.h"
#include "common/logger.h"
+#include "common/resources/resourcemanager.h"
#include "object/level/parser.h"
#include "object/robotmain.h"
@@ -174,10 +175,19 @@ std::string CLevelParserParam::InjectLevelDir(std::string path, const std::strin
{
newPath = defaultDir + (!defaultDir.empty() ? "/" : "") + newPath;
}
- //TODO: Fallback to English
+
+ std::string langPath = newPath;
std::string langStr(1, CApplication::GetInstancePointer()->GetLanguageChar());
- boost::replace_all(newPath, "%lng%", langStr);
- return newPath;
+ boost::replace_all(langPath, "%lng%", langStr);
+ if(CResourceManager::Exists(langPath))
+ return langPath;
+
+ // Fallback to English if file doesn't exist
+ boost::replace_all(newPath, "%lng%", "E");
+ if(CResourceManager::Exists(newPath))
+ return newPath;
+
+ return langPath; // Return current language file if none of the files exist
}
std::string CLevelParserParam::ToPath(std::string path, const std::string defaultDir)