Skip to content

Commit

Permalink
added task safe translate which help avoid deadlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
p0k0 committed Oct 14, 2019
1 parent 6e33e78 commit 785d352
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/I18Next.Net.Extensions/I18NextStringLocalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures)
{
var language = _language ?? _instance.Language;

var result = _instance.Backend.LoadNamespaceAsync(language, _instance.DefaultNamespace).Result;
var result = _instance.Backend.LoadNamespaceAsync(language, _instance.DefaultNamespace)
.ConfigureAwait(false).GetAwaiter().GetResult();

return result.GetAllValues().Select(t => new LocalizedString(t.Key, t.Value));
}
Expand Down
6 changes: 3 additions & 3 deletions src/I18Next.Net/I18NextNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ public string Language

public string T(string key, object args = null)
{
return Ta(_language, key, args).Result;
return Ta(_language, key, args).ConfigureAwait(false).GetAwaiter().GetResult();
}

public string T(string language, string key, object args = null)
{
return Ta(language, key, args).Result;
return Ta(language, key, args).ConfigureAwait(false).GetAwaiter().GetResult();
}

public string T(string language, string defaultNamespace, string key, object args = null)
{
return Ta(language, defaultNamespace, key, args).Result;
return Ta(language, defaultNamespace, key, args).ConfigureAwait(false).GetAwaiter().GetResult();
}

public Task<string> Ta(string key, object args = null)
Expand Down

0 comments on commit 785d352

Please sign in to comment.