From 7a0f8b39a5255ffd114db9cf548c07c4fea941fc Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Mon, 22 Oct 2012 18:11:51 +0000 Subject: [PATCH] - bugfix to ensure transifex purge ONLY deletes files in mapping --- source/glest_game/menu/menu_state_options.cpp | 70 +++++++++++++++---- 1 file changed, 57 insertions(+), 13 deletions(-) diff --git a/source/glest_game/menu/menu_state_options.cpp b/source/glest_game/menu/menu_state_options.cpp index 4f4e7ace..ff0974d1 100644 --- a/source/glest_game/menu/menu_state_options.cpp +++ b/source/glest_game/menu/menu_state_options.cpp @@ -986,6 +986,11 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){ } if(data_path != "") { + + string txnURLFileListMapping = Config::getInstance().getString("TranslationGetURLFileListMapping"); + vector languageFileMappings; + Tokenize(txnURLFileListMapping,languageFileMappings,"|"); + Config &config = Config::getInstance(); // Cleanup Scenarios @@ -1007,9 +1012,20 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){ string removeLngFile = scenarioPath + scenario + "/" + testLanguage; if(EndsWith(testLanguage,language + ".lng") == true) { - printf("About to delete file [%s]\n",removeLngFile.c_str()); - removeFile(removeLngFile); - foundFilesToDelete = true; + + for(unsigned int k = 0; k < languageFileMappings.size(); ++k) { + string mapping = languageFileMappings[k]; + replaceAll(mapping,"$language",language); + + //printf("Comparing found [%s] with [%s]\n",removeLngFile.c_str(),mapping.c_str()); + + if(EndsWith(removeLngFile,mapping) == true) { + printf("About to delete file [%s]\n",removeLngFile.c_str()); + removeFile(removeLngFile); + foundFilesToDelete = true; + break; + } + } } } } @@ -1033,28 +1049,56 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){ string removeLngFile = tutorialPath + tutorial + "/" + testLanguage; if(EndsWith(testLanguage,language + ".lng") == true) { - printf("About to delete file [%s]\n",removeLngFile.c_str()); - removeFile(removeLngFile); - foundFilesToDelete = true; + + + for(unsigned int k = 0; k < languageFileMappings.size(); ++k) { + string mapping = languageFileMappings[k]; + replaceAll(mapping,"$language",language); + + //printf("Comparing found [%s] with [%s]\n",removeLngFile.c_str(),mapping.c_str()); + + if(EndsWith(removeLngFile,mapping) == true) { + printf("About to delete file [%s]\n",removeLngFile.c_str()); + removeFile(removeLngFile); + foundFilesToDelete = true; + break; + } + } } } } } - // Cleanup main and hint language files string mainLngFile = data_path + "data/lang/" + language + ".lng"; if(fileExists(mainLngFile) == true) { - printf("About to delete file [%s]\n",mainLngFile.c_str()); - removeFile(mainLngFile); - foundFilesToDelete = true; + + for(unsigned int k = 0; k < languageFileMappings.size(); ++k) { + string mapping = languageFileMappings[k]; + replaceAll(mapping,"$language",language); + + if(EndsWith(mainLngFile,mapping) == true) { + printf("About to delete file [%s]\n",mainLngFile.c_str()); + removeFile(mainLngFile); + foundFilesToDelete = true; + break; + } + } } string hintLngFile = data_path + "data/lang/hint/hint_" + language + ".lng"; if(fileExists(hintLngFile) == true) { - printf("About to delete file [%s]\n",hintLngFile.c_str()); - removeFile(hintLngFile); - foundFilesToDelete = true; + for(unsigned int k = 0; k < languageFileMappings.size(); ++k) { + string mapping = languageFileMappings[k]; + replaceAll(mapping,"$language",language); + + if(EndsWith(hintLngFile,mapping) == true) { + printf("About to delete file [%s]\n",hintLngFile.c_str()); + removeFile(hintLngFile); + foundFilesToDelete = true; + break; + } + } } }