// 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.Collections;
using System.Collections.Generic;
using System.Globalization;
using Microsoft.Framework.Internal;
namespace Microsoft.Framework.Localization
{
///
/// Provides strings for .
///
/// The to provide strings for.
public class StringLocalizer : IStringLocalizer
{
private IStringLocalizer _localizer;
///
/// Creates a new .
///
/// The to use.
public StringLocalizer([NotNull] IStringLocalizerFactory factory)
{
_localizer = factory.Create(typeof(TResourceSource));
}
///
public virtual IStringLocalizer WithCulture(CultureInfo culture) => _localizer.WithCulture(culture);
///
public virtual LocalizedString this[[NotNull] string key] => _localizer[key];
///
public virtual LocalizedString this[[NotNull] string key, params object[] arguments] =>
_localizer[key, arguments];
///
public virtual LocalizedString GetString([NotNull] string key) => _localizer.GetString(key);
///
public virtual LocalizedString GetString([NotNull] string key, params object[] arguments) =>
_localizer.GetString(key, arguments);
///
public IEnumerator GetEnumerator() => _localizer.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => _localizer.GetEnumerator();
}
}