track resx language

This commit is contained in:
Tim Young 2017-10-31 09:00:05 -05:00
parent 737ee16718
commit d2f3423a5a

View File

@ -24,6 +24,8 @@ namespace EduNetworkBuilder
string[,] LanguageChoices = { { NB.Translate("NB_NBEn"), "en" }, { NB.Translate("NB_NBFr"), "fr" } }; string[,] LanguageChoices = { { NB.Translate("NB_NBEn"), "en" }, { NB.Translate("NB_NBFr"), "fr" } };
string FormChosenDir = ""; string FormChosenDir = "";
List<TranslationResxFile> TranslationResxFiles = new List<TranslationResxFile>(); List<TranslationResxFile> TranslationResxFiles = new List<TranslationResxFile>();
string EnglishTargetFile = "edustrings.resx";
public TranslationWindow(Network ToEdit) public TranslationWindow(Network ToEdit)
{ {
@ -244,7 +246,6 @@ namespace EduNetworkBuilder
//**********************************************************************// //**********************************************************************//
bool TryToChooseFormDir(string Choice) bool TryToChooseFormDir(string Choice)
{ {
string targetfile = "edustrings.resx";
if (Choice == null || Choice == "") return false; if (Choice == null || Choice == "") return false;
//We want to have a file named edustrings.resx there //We want to have a file named edustrings.resx there
@ -252,7 +253,7 @@ namespace EduNetworkBuilder
//If these exist, we are OK. Otherwise, see if there is a "languages" dir and try that if it does exist //If these exist, we are OK. Otherwise, see if there is a "languages" dir and try that if it does exist
string toCheck = Path.GetFileName(Choice).ToLower(); string toCheck = Path.GetFileName(Choice).ToLower();
if (File.Exists(Choice)) if (File.Exists(Choice))
if (toCheck == targetfile) if (toCheck == EnglishTargetFile)
{ {
FormChosenDir = Path.GetDirectoryName(Choice); FormChosenDir = Path.GetDirectoryName(Choice);
LoadResxFiles(); LoadResxFiles();
@ -266,12 +267,12 @@ namespace EduNetworkBuilder
if(Directory.Exists(Choice)) if(Directory.Exists(Choice))
{ {
//It is a directory. See if it has the correct file in it. //It is a directory. See if it has the correct file in it.
if (TryToChooseFormDir(Path.Combine(Choice, targetfile))) if (TryToChooseFormDir(Path.Combine(Choice, EnglishTargetFile)))
{ {
return true; //It was successful return true; //It was successful
} }
//If we get here, it did not have the file. See if there is a "languages" directory //If we get here, it did not have the file. See if there is a "languages" directory
if (TryToChooseFormDir(Path.Combine(Choice, "languages", targetfile))) if (TryToChooseFormDir(Path.Combine(Choice, "languages", EnglishTargetFile)))
{ {
return true; //It was successful return true; //It was successful
} }
@ -324,11 +325,18 @@ namespace EduNetworkBuilder
{ {
public string filename; public string filename;
List<TranslationItem> Items = new List<TranslationItem>(); List<TranslationItem> Items = new List<TranslationItem>();
public string language = "";
public TranslationResxFile(string File) public TranslationResxFile(string File)
{ {
filename = File; filename = File;
Load(); Load();
if (filename == "edustrings.resx")
{
language = "en";
}
else
language = filename.Substring(0, 2);
} }
void Load() void Load()