1
0
mirror of https://github.com/bitwarden/server synced 2025-12-22 11:13:27 +00:00
Files
server/src/Core/Services/Implementations/I18nService.cs
Justin Baur 231eb84e69 Turn On ImplicitUsings (#2079)
* Turn on ImplicitUsings

* Fix formatting

* Run linter
2022-06-29 19:46:41 -04:00

38 lines
1.0 KiB
C#

using System.Reflection;
using Bit.Core.Resources;
using Microsoft.Extensions.Localization;
namespace Bit.Core.Services
{
public class I18nService : II18nService
{
private readonly IStringLocalizer _localizer;
public I18nService(IStringLocalizerFactory factory)
{
var assemblyName = new AssemblyName(typeof(SharedResources).GetTypeInfo().Assembly.FullName);
_localizer = factory.Create("SharedResources", assemblyName.Name);
}
public LocalizedString GetLocalizedHtmlString(string key)
{
return _localizer[key];
}
public LocalizedString GetLocalizedHtmlString(string key, params object[] args)
{
return _localizer[key, args];
}
public string Translate(string key, params object[] args)
{
return string.Format(GetLocalizedHtmlString(key).ToString(), args);
}
public string T(string key, params object[] args)
{
return Translate(key, args);
}
}
}