- default to english is a selected language is missing
This commit is contained in:
parent
ccb86ef373
commit
043cd5789c
|
@ -46,10 +46,11 @@ Lang &Lang::getInstance() {
|
|||
return lang;
|
||||
}
|
||||
|
||||
void Lang::loadStrings(const string &uselanguage, bool loadFonts) {
|
||||
void Lang::loadStrings(const string &uselanguage, bool loadFonts,
|
||||
bool fallbackToDefault) {
|
||||
bool languageChanged = (uselanguage != this->language);
|
||||
this->language= uselanguage;
|
||||
loadStrings(uselanguage, strings, true);
|
||||
loadStrings(uselanguage, strings, true, fallbackToDefault);
|
||||
|
||||
if(languageChanged == true) {
|
||||
Font::resetToDefaults();
|
||||
|
@ -155,14 +156,15 @@ void Lang::loadStrings(const string &uselanguage, bool loadFonts) {
|
|||
// end win32
|
||||
#endif
|
||||
|
||||
if(loadFonts) {
|
||||
if(loadFonts == true) {
|
||||
CoreData &coreData= CoreData::getInstance();
|
||||
coreData.loadFonts();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Lang::loadStrings(const string &uselanguage, Properties &properties, bool fileMustExist) {
|
||||
void Lang::loadStrings(const string &uselanguage, Properties &properties, bool fileMustExist,
|
||||
bool fallbackToDefault) {
|
||||
properties.clear();
|
||||
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
|
||||
//string languageFile = data_path + "data/lang/" + uselanguage + ".lng";
|
||||
|
@ -170,6 +172,13 @@ void Lang::loadStrings(const string &uselanguage, Properties &properties, bool f
|
|||
if(fileMustExist == false && fileExists(languageFile) == false) {
|
||||
return;
|
||||
}
|
||||
else if(fileExists(languageFile) == false && fallbackToDefault == true) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s]\n",__FILE__,__FUNCTION__,__LINE__,languageFile.c_str());
|
||||
//throw runtime_error("File NOT FOUND, can't open file: [" + languageFile + "]");
|
||||
printf("Language file NOT FOUND, can't open file: [%s] switching to default language: %s\n",languageFile.c_str(),DEFAULT_LANGUAGE);
|
||||
|
||||
languageFile = getGameCustomCoreDataPath(data_path, "data/lang/" + string(DEFAULT_LANGUAGE) + ".lng");
|
||||
}
|
||||
is_utf8_language = valid_utf8_file(languageFile.c_str());
|
||||
properties.load(languageFile);
|
||||
}
|
||||
|
|
|
@ -37,12 +37,12 @@ private:
|
|||
|
||||
private:
|
||||
Lang();
|
||||
void loadStrings(const string &language, Properties &properties, bool fileMustExist);
|
||||
void loadStrings(const string &language, Properties &properties, bool fileMustExist,bool fallbackToDefault=false);
|
||||
|
||||
public:
|
||||
static Lang &getInstance();
|
||||
|
||||
void loadStrings(const string &uselanguage, bool loadFonts=true);
|
||||
void loadStrings(const string &uselanguage, bool loadFonts=true, bool fallbackToDefault=false);
|
||||
void loadScenarioStrings(const string &scenarioDir, const string &scenarioName);
|
||||
|
||||
string get(const string &s,string uselanguage="", bool fallbackToDefault=false);
|
||||
|
|
|
@ -2869,7 +2869,7 @@ int glestMain(int argc, char** argv) {
|
|||
}
|
||||
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
lang.loadStrings(language,false);
|
||||
lang.loadStrings(language,false, true);
|
||||
|
||||
if( lang.hasString("FONT_HEIGHT_TEXT")) {
|
||||
Font::langHeightText = config.getString("FONT_HEIGHT_TEXT",Font::langHeightText.c_str());
|
||||
|
|
Loading…
Reference in New Issue