Skip to content

Commit 472e417

Browse files
allow en us locale as default
1 parent 504dde4 commit 472e417

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

Assets/UXF/Scripts/DataHandling/FileSaver.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using System.IO;
77
using System.Threading;
88
using System.Linq;
9-
9+
using System.Globalization;
1010

1111
namespace UXF
1212
{
@@ -19,6 +19,13 @@ public class FileSaver : LocalFileDataHander
1919
[Tooltip("Enable to sort session files into folders. The trial_results CSV is never put into a folder.")]
2020
public bool sortDataIntoFolders = true;
2121

22+
/// <summary>
23+
/// Enable to force the data to save with an english-US format (i.e. `,` to serapate values,
24+
/// and `.` to separate decimal points).
25+
/// </summary>
26+
[Tooltip("Enable to force the data to save with an english-US format (i.e. `,` to serapate values, and `.` to separate decimal points).")]
27+
public bool forceENUSLocale = true;
28+
2229
/// <summary>
2330
/// Enable to print debug messages to the console.
2431
/// </summary>
@@ -45,12 +52,21 @@ public class FileSaver : LocalFileDataHander
4552
/// </summary>
4653
public override void SetUp()
4754
{
55+
if (forceENUSLocale)
56+
{
57+
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
58+
}
59+
4860
quitting = false;
4961
Directory.CreateDirectory(base.StoragePath);
5062

5163
if (!IsActive)
5264
{
5365
parallelThread = new Thread(Worker);
66+
if (forceENUSLocale)
67+
{
68+
parallelThread.CurrentCulture = new CultureInfo("en-US");
69+
}
5470
parallelThread.Start();
5571
}
5672
else
@@ -150,7 +166,7 @@ public override string HandleDataTable(UXFDataTable table, string experiment, st
150166
if (verboseDebug) Utilities.UXFDebugLogFormat("Queuing save of file: {0}", savePath);
151167

152168
ManageInWorker(() => { File.WriteAllLines(savePath, lines); });
153-
return GetRelativePath(StoragePath, savePath);;
169+
return GetRelativePath(StoragePath, savePath);
154170
}
155171

156172
public override string HandleJSONSerializableObject(List<object> serializableObject, string experiment, string ppid, int sessionNum, string dataName, UXFDataType dataType, int optionalTrialNum = 0)

Assets/UXF/Tests/Editor/TestLocale.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Tuple<Session, FileSaver> CreateSession(string ppidExtra)
7070
sessionLogger.Initialise();
7171

7272
fileSaver.verboseDebug = false;
73+
fileSaver.forceENUSLocale = false;
7374

7475
string experimentName = "unit_test";
7576
string ppid = "test_locale_" + ppidExtra;

0 commit comments

Comments
 (0)