mirror of
https://github.com/bitwarden/server
synced 2025-12-29 06:33:43 +00:00
* Added PreValidate endpoint on Account controller * Fixed IHttpClientFactory implementation * Core localization and org sproc fix * Pass culture, fixed sso middleware bug
38 lines
1.6 KiB
C#
38 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Reflection;
|
|
using Bit.Core.Resources;
|
|
using Microsoft.AspNetCore.Mvc.Localization;
|
|
using Microsoft.Extensions.Localization;
|
|
|
|
namespace Bit.Core.Services
|
|
{
|
|
public class I18nViewLocalizer : IViewLocalizer
|
|
{
|
|
private readonly IStringLocalizer _stringLocalizer;
|
|
private readonly IHtmlLocalizer _htmlLocalizer;
|
|
|
|
public I18nViewLocalizer(IStringLocalizerFactory stringFactory,
|
|
IHtmlLocalizerFactory htmlFactory)
|
|
{
|
|
var assemblyName = new AssemblyName(typeof(SharedResources).GetTypeInfo().Assembly.FullName);
|
|
_stringLocalizer = stringFactory.Create("SharedResources", assemblyName.Name);
|
|
_htmlLocalizer = htmlFactory.Create("SharedResources", assemblyName.Name);
|
|
}
|
|
|
|
public LocalizedHtmlString this[string name] => _htmlLocalizer[name];
|
|
public LocalizedHtmlString this[string name, params object[] args] => _htmlLocalizer[name, args];
|
|
|
|
public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures) =>
|
|
_stringLocalizer.GetAllStrings(includeParentCultures);
|
|
|
|
public LocalizedString GetString(string name) => _stringLocalizer[name];
|
|
public LocalizedString GetString(string name, params object[] arguments) =>
|
|
_stringLocalizer[name, arguments];
|
|
|
|
[Obsolete("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")]
|
|
public IHtmlLocalizer WithCulture(CultureInfo culture) => _htmlLocalizer.WithCulture(culture);
|
|
}
|
|
}
|