Skip to content

Commit d6f0d91

Browse files
committed
Fix crash when Translations.ini is missing or has no translation definitions section
1 parent eb624ce commit d6f0d91

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/TSMapEditor/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace TSMapEditor
44
{
55
public static class Constants
66
{
7-
public const string ReleaseVersion = "1.7.4";
7+
public const string ReleaseVersion = "1.7.5";
88

99
public static int CellSizeX = 48;
1010
public static int CellSizeY = 24;

src/TSMapEditor/Misc/Translator.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,19 +235,24 @@ public static void LoadTranslations()
235235
if (iniFile != null)
236236
{
237237
var translationsSection = iniFile.GetSectionKeys("Translations");
238-
foreach (var key in translationsSection)
238+
239+
if (translationsSection != null)
239240
{
240-
var translationSectionName = iniFile.GetStringValue("Translations", key, string.Empty);
241-
if (string.IsNullOrWhiteSpace(translationSectionName))
242-
continue;
241+
foreach (var key in translationsSection)
242+
{
243+
var translationSectionName = iniFile.GetStringValue("Translations", key, string.Empty);
244+
if (string.IsNullOrWhiteSpace(translationSectionName))
245+
continue;
243246

244-
var iniSection = iniFile.GetSection(translationSectionName);
247+
var iniSection = iniFile.GetSection(translationSectionName);
245248

246-
var translation = new Translation(iniSection, Translations.Count);
247-
AddTranslation(translation);
249+
var translation = new Translation(iniSection, Translations.Count);
250+
AddTranslation(translation);
251+
}
248252
}
249253
}
250-
else
254+
255+
if (Translations.Count == 0)
251256
{
252257
var englishTranslation = new Translation("English", "en", "English", Translations.Count, true);
253258
AddTranslation(englishTranslation);

0 commit comments

Comments
 (0)