Browse Source

More stable localizer for tests.

pull/592/head
Sebastian 5 years ago
parent
commit
bfab313751
  1. 41
      backend/src/Squidex.Infrastructure/Translations/ResourcesLocalizer.cs

41
backend/src/Squidex.Infrastructure/Translations/ResourcesLocalizer.cs

@ -28,15 +28,26 @@ namespace Squidex.Infrastructure.Translations
this.resourceManager = resourceManager; this.resourceManager = resourceManager;
#if DEBUG #if DEBUG
if (File.Exists(MissingFileName)) missingTranslations = new HashSet<string>();
{
var missing = File.ReadAllLines(MissingFileName);
missingTranslations = new HashSet<string>(missing); for (var i = 0; i < 3; i++)
}
else
{ {
missingTranslations = new HashSet<string>(); lock (LockObject)
{
try
{
if (File.Exists(MissingFileName))
{
var missing = File.ReadAllLines(MissingFileName);
missingTranslations = new HashSet<string>(missing);
}
}
catch (IOException)
{
continue;
}
}
} }
#endif #endif
} }
@ -171,11 +182,21 @@ namespace Squidex.Infrastructure.Translations
if (translation == null) if (translation == null)
{ {
#if DEBUG #if DEBUG
lock (LockObject) for (var i = 0; i < 3; i++)
{ {
if (!missingTranslations.Add(key)) lock (LockObject)
{ {
File.AppendAllLines(MissingFileName, new[] { key }); try
{
if (!missingTranslations.Add(key))
{
File.AppendAllLines(MissingFileName, new[] { key });
}
}
catch (IOException)
{
continue;
}
} }
} }
#endif #endif

Loading…
Cancel
Save