Skip to content

Commit cdef1c2

Browse files
committed
Bugfix: Fix inconsistency of ReloadLocales with LoadLocales
1 parent 1f35703 commit cdef1c2

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

services/ModReloadService.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,32 @@ public static void ReloadLocales(IMod pMod)
3737
string locale_path = localizable_mod.GetLocaleFilesDirectory(pMod.GetDeclaration());
3838
if (!Directory.Exists(locale_path)) return;
3939

40-
var files = Directory.GetFiles(locale_path);
40+
var files = Directory.GetFiles(locale_path, "*", SearchOption.AllDirectories);
41+
char csv_separator = ',';
42+
if (pMod is ICsvSepCustomized sep_customized)
43+
csv_separator = sep_customized.GetCsvSeparator();
44+
4145
foreach (var locale_file in files)
4246
{
4347
LogService.LogInfo(
4448
$"Reload {locale_file} as {Path.GetFileNameWithoutExtension(locale_file)}");
45-
LM.LoadLocale(Path.GetFileNameWithoutExtension(locale_file), locale_file);
49+
try
50+
{
51+
if (locale_file.EndsWith(".json", StringComparison.OrdinalIgnoreCase))
52+
{
53+
LM.LoadLocale(Path.GetFileNameWithoutExtension(locale_file), locale_file);
54+
}
55+
else if (locale_file.EndsWith(".csv", StringComparison.OrdinalIgnoreCase))
56+
{
57+
LM.LoadLocales(locale_file, csv_separator);
58+
}
59+
}
60+
catch (FormatException e)
61+
{
62+
LogService.LogWarning(e.Message);
63+
}
4664
}
4765

4866
LM.ApplyLocale();
4967
}
50-
}
68+
}

0 commit comments

Comments
 (0)