// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; using System.Globalization; namespace Microsoft.Extensions.Localization { /// /// Provides strings for . /// /// The to provide strings for. public class StringLocalizer : IStringLocalizer { private IStringLocalizer _localizer; /// /// Creates a new . /// /// The to use. public StringLocalizer(IStringLocalizerFactory factory) { if (factory == null) { throw new ArgumentNullException(nameof(factory)); } _localizer = factory.Create(typeof(TResourceSource)); } /// public virtual IStringLocalizer WithCulture(CultureInfo culture) => _localizer.WithCulture(culture); /// public virtual LocalizedString this[string name] { get { if (name == null) { throw new ArgumentNullException(nameof(name)); } return _localizer[name]; } } /// public virtual LocalizedString this[string name, params object[] arguments] { get { if (name == null) { throw new ArgumentNullException(nameof(name)); } return _localizer[name, arguments]; } } /// public IEnumerable GetAllStrings(bool includeParentCultures) => _localizer.GetAllStrings(includeParentCultures); } }