diff --git a/src/Microsoft.Framework.Localization.Abstractions/IStringLocalizer.cs b/src/Microsoft.Framework.Localization.Abstractions/IStringLocalizer.cs
index 4dddf75f25..aad6b9bb3e 100644
--- a/src/Microsoft.Framework.Localization.Abstractions/IStringLocalizer.cs
+++ b/src/Microsoft.Framework.Localization.Abstractions/IStringLocalizer.cs
@@ -25,22 +25,7 @@ namespace Microsoft.Framework.Localization
/// The values to format the string with.
/// The formatted string resource as a .
LocalizedString this[string name, params object[] arguments] { get; }
-
- ///
- /// Gets the string resource with the given name.
- ///
- /// The name of the string resource.
- /// The string resource as a .
- LocalizedString GetString(string name);
-
- ///
- /// Gets the string resource with the given name and formatted with the supplied arguments.
- ///
- /// The name of the string resource.
- /// The values to format the string with.
- /// The formatted string resource as a .
- LocalizedString GetString(string name, params object[] arguments);
-
+
///
/// Creates a new for a specific .
///
diff --git a/src/Microsoft.Framework.Localization.Abstractions/IStringLocalizerExtensions.cs b/src/Microsoft.Framework.Localization.Abstractions/IStringLocalizerExtensions.cs
new file mode 100644
index 0000000000..f38388a371
--- /dev/null
+++ b/src/Microsoft.Framework.Localization.Abstractions/IStringLocalizerExtensions.cs
@@ -0,0 +1,29 @@
+// 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.
+
+namespace Microsoft.Framework.Localization
+{
+ public static class IStringLocalizerExtensions
+ {
+ ///
+ /// Gets the string resource with the given name.
+ ///
+ /// The name of the string resource.
+ /// The string resource as a .
+ public static LocalizedString GetString(this IStringLocalizer stringLocalizer, string name)
+ {
+ return stringLocalizer[name];
+ }
+
+ ///
+ /// Gets the string resource with the given name and formatted with the supplied arguments.
+ ///
+ /// The name of the string resource.
+ /// The values to format the string with.
+ /// The formatted string resource as a .
+ public static LocalizedString GetString(this IStringLocalizer stringLocalizer, string name, params object[] arguments)
+ {
+ return stringLocalizer[name, arguments];
+ }
+ }
+}
diff --git a/src/Microsoft.Framework.Localization/ResourceManagerStringLocalizer.cs b/src/Microsoft.Framework.Localization/ResourceManagerStringLocalizer.cs
index f17517a168..ae0772ac64 100644
--- a/src/Microsoft.Framework.Localization/ResourceManagerStringLocalizer.cs
+++ b/src/Microsoft.Framework.Localization/ResourceManagerStringLocalizer.cs
@@ -51,26 +51,26 @@ namespace Microsoft.Framework.Localization
/// The base name of the embedded resource in the that contains the strings.
///
protected string ResourceBaseName { get; }
-
- ///
- public virtual LocalizedString this[[NotNull] string name] => GetString(name);
///
- public virtual LocalizedString this[[NotNull] string name, params object[] arguments] => GetString(name, arguments);
-
- ///
- public virtual LocalizedString GetString([NotNull] string name)
+ public virtual LocalizedString this[[NotNull] string name]
{
- var value = GetStringSafely(name, null);
- return new LocalizedString(name, value ?? name, resourceNotFound: value == null);
+ get
+ {
+ var value = GetStringSafely(name, null);
+ return new LocalizedString(name, value ?? name, resourceNotFound: value == null);
+ }
}
///
- public virtual LocalizedString GetString([NotNull] string name, params object[] arguments)
+ public virtual LocalizedString this[[NotNull] string name, params object[] arguments]
{
- var format = GetStringSafely(name, null);
- var value = string.Format(format ?? name, arguments);
- return new LocalizedString(name, value, resourceNotFound: format == null);
+ get
+ {
+ var format = GetStringSafely(name, null);
+ var value = string.Format(format ?? name, arguments);
+ return new LocalizedString(name, value, resourceNotFound: format == null);
+ }
}
///
diff --git a/src/Microsoft.Framework.Localization/ResourceManagerWithCultureStringLocalizer.cs b/src/Microsoft.Framework.Localization/ResourceManagerWithCultureStringLocalizer.cs
index 8e9027af76..c8d2f36dbb 100644
--- a/src/Microsoft.Framework.Localization/ResourceManagerWithCultureStringLocalizer.cs
+++ b/src/Microsoft.Framework.Localization/ResourceManagerWithCultureStringLocalizer.cs
@@ -36,24 +36,24 @@ namespace Microsoft.Framework.Localization
}
///
- public override LocalizedString this[[NotNull] string name] => GetString(name);
-
- ///
- public override LocalizedString this[[NotNull] string name, params object[] arguments] => GetString(name, arguments);
-
- ///
- public override LocalizedString GetString([NotNull] string name)
+ public override LocalizedString this[[NotNull] string name]
{
- var value = GetStringSafely(name, _culture);
- return new LocalizedString(name, value ?? name);
+ get
+ {
+ var value = GetStringSafely(name, _culture);
+ return new LocalizedString(name, value ?? name);
+ }
}
///
- public override LocalizedString GetString([NotNull] string name, params object[] arguments)
+ public override LocalizedString this[[NotNull] string name, params object[] arguments]
{
- var format = GetStringSafely(name, _culture);
- var value = string.Format(_culture, format ?? name, arguments);
- return new LocalizedString(name, value ?? name, resourceNotFound: format == null);
+ get
+ {
+ var format = GetStringSafely(name, _culture);
+ var value = string.Format(_culture, format ?? name, arguments);
+ return new LocalizedString(name, value ?? name, resourceNotFound: format == null);
+ }
}
///