internal static void ExportTerms(int languageIndex, String code)
 {
     System.IO.Directory.CreateDirectory($@"{UnityModManager.modsPath}/{typeof(Main).Namespace}/{OUT}{code}");
     foreach (var category in languageSourceData.GetCategories())
     {
         if (!category.Contains(":"))
         {
             var fixedCategory  = FixCategory(category);
             var outputFilename = $@"{UnityModManager.modsPath}/{typeof(Main).Namespace}/{OUT}{code}/{fixedCategory}{EXT}";
             using (var sw = new StreamWriter(outputFilename))
                 foreach (var termName in languageSourceData.GetTermsList(category))
                 {
                     var term = languageSourceData.GetTermData(termName);
                     sw.WriteLine($"{term.Term}\t{term.Languages[languageIndex]?.Replace("\n", @"\n")}");
                 }
         }
     }
 }
        private void ParseSchedule()
        {
            LanguageSourceData sourceData = I2.Loc.LocalizationManager.Sources[0];

            categoriesList       = new List <string>();
            categoriesList       = sourceData.GetCategories();
            streamCategoriesList = categoriesList.FindAll(x => x.StartsWith(categoryMainName));

            foreach (string streamCategory in streamCategoriesList)
            {
                termsList.AddRange(sourceData.GetTermsList(streamCategory));
            }

            termsList.Sort();

            string key;
            string category;

            foreach (string term in termsList)
            {
                key      = "";
                category = "";

                LanguageSourceData.DeserializeFullTerm(term, out key, out category);

                string[] subCategories = category.Split('/');

                int streamId = 0;

                foreach (string item in subCategories)
                {
                    if (item.StartsWith(categoryStreamName))
                    {
                        int.TryParse(item.Substring(categoryStreamName.Length), out streamId);
                    }
                }

                ExpoScheduledStreamItem scheduledItem = scheduledItems.Find(x => x.category == category);
                bool isNew = false;
                if (scheduledItem == null)
                {
                    isNew = true;

                    scheduledItem = new ExpoScheduledStreamItem();

                    scheduledItem.StreamId = streamId;
                    scheduledItem.category = category;
                }

                if (key == keyRoom)
                {
                    // Room name is equal to Timetable Tab names
                    scheduledItem.Room = sourceData.GetTranslation(term);
                }
                else if (key == keyDayId)
                {
                    int dayIdParse = 0;
                    if (!int.TryParse(sourceData.GetTranslation(term), out dayIdParse))
                    {
                        dayIdParse = 0;
                    }

                    scheduledItem.DayId = dayIdParse;
                }
                else if (key == keyStartTime)
                {
                    string dateString = sourceData.GetTranslation(term);

                    dateString = dateString.Replace("GMT", "").Replace(" (PDT)", "").Replace(" (PST)", "").Replace(" (PT)", "");
                    dateString = dateString.Insert(dateString.Length - 2, ":");

                    scheduledItem.StartTime       = System.DateTime.ParseExact(dateString, dateFormat, System.Globalization.CultureInfo.InvariantCulture);
                    scheduledItem.StartTimeString = scheduledItem.StartTime.ToString();

                    scheduledItem.Date       = scheduledItem.StartTime.ToLocalTime().Date;
                    scheduledItem.DateString = scheduledItem.Date.ToShortDateString();
                }
                else if (key == keyEndTime)
                {
                    string dateString = sourceData.GetTranslation(term);

                    dateString = dateString.Replace("GMT", "").Replace(" (PDT)", "").Replace(" (PST)", "").Replace(" (PT)", "");
                    dateString = dateString.Insert(dateString.Length - 2, ":");

                    scheduledItem.EndTime       = System.DateTime.ParseExact(dateString, dateFormat, System.Globalization.CultureInfo.InvariantCulture);
                    scheduledItem.EndTimeString = scheduledItem.EndTime.ToString();
                }
                else if (key == keyTitle)
                {
                    scheduledItem.Title = sourceData.GetTranslation(term);
                }
                else if (key == keyDescription)
                {
                    scheduledItem.Description = sourceData.GetTranslation(term);
                }
                else if (key == keySpeakersName)
                {
                    scheduledItem.SpeakersName = sourceData.GetTranslation(term);
                }
                else if (key == keySpeakersPosition)
                {
                    scheduledItem.SpeakersPosition = sourceData.GetTranslation(term);
                }
                else if (key == keySpeakersPhoto)
                {
                    scheduledItem.SpeakersPhoto = sourceData.GetTranslation(term);
                }
                else if (key == keyFormat)
                {
                    scheduledItem.Format = sourceData.GetTranslation(term);
                }
                else if (key == keyURL)
                {
                    scheduledItem.URL = sourceData.GetTranslation(term);
                }

                if (isNew)
                {
                    scheduledItems.Add(scheduledItem);
                }
            }

            scheduledItems = scheduledItems.OrderBy(x => x.StartTime).ToList();
        }