ResourceManagerStringLocalizer Class¶
An Microsoft.Extensions.Localization.IStringLocalizer that uses the System.Resources.ResourceManager and
System.Resources.ResourceReader to provide localized strings.
- Namespace
Microsoft.Extensions.Localization- Assemblies
- Microsoft.Extensions.Localization
Syntax¶
public class ResourceManagerStringLocalizer : IStringLocalizer
-
class
Microsoft.Extensions.Localization.ResourceManagerStringLocalizer
Constructors¶
-
ResourceManagerStringLocalizer(System.Resources.ResourceManager, Microsoft.Extensions.Localization.Internal.AssemblyWrapper, System.String, Microsoft.Extensions.Localization.IResourceNamesCache)¶ Intended for testing purposes only.
public ResourceManagerStringLocalizer(ResourceManager resourceManager, AssemblyWrapper resourceAssemblyWrapper, string baseName, IResourceNamesCache resourceNamesCache)
-
ResourceManagerStringLocalizer(System.Resources.ResourceManager, System.Reflection.Assembly, System.String, Microsoft.Extensions.Localization.IResourceNamesCache) Creates a new
Microsoft.Extensions.Localization.ResourceManagerStringLocalizer.Arguments: - resourceManager (System.Resources.ResourceManager) – The
System.Resources.ResourceManagerto read strings from. - resourceAssembly (System.Reflection.Assembly) – The
System.Reflection.Assemblythat contains the strings as embedded resources. - baseName (System.String) – The base name of the embedded resource in the
System.Reflection.Assemblythat contains the strings. - resourceNamesCache (Microsoft.Extensions.Localization.IResourceNamesCache) – Cache of the list of strings for a given resource assembly name.
public ResourceManagerStringLocalizer(ResourceManager resourceManager, Assembly resourceAssembly, string baseName, IResourceNamesCache resourceNamesCache)
- resourceManager (System.Resources.ResourceManager) – The
-
Methods¶
-
GetAllStrings(System.Boolean)¶ Return type: System.Collections.Generic.IEnumerable<Microsoft.Extensions.Localization.LocalizedString> public virtual IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures)
-
GetAllStrings(System.Boolean, System.Globalization.CultureInfo) Returns all strings in the specified culture.
Arguments: culture (System.Globalization.CultureInfo) – The System.Globalization.CultureInfoto get strings for.Return type: System.Collections.Generic.IEnumerable<Microsoft.Extensions.Localization.LocalizedString> Returns: The strings. protected IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures, CultureInfo culture)
-
GetStringSafely(System.String, System.Globalization.CultureInfo)¶ Gets a resource string from the
Microsoft.Extensions.Localization.ResourceManagerStringLocalizer._resourceManagerand returns <code>null</code> instead of throwing exceptions if a match isn’t found.Arguments: - name (System.String) – The name of the string resource.
- culture (System.Globalization.CultureInfo) – The
System.Globalization.CultureInfoto get the string for.
Return type: System.String
Returns: The resource string, or <code>null</code> if none was found.
protected string GetStringSafely(string name, CultureInfo culture)
-
WithCulture(System.Globalization.CultureInfo)¶ Creates a new
Microsoft.Extensions.Localization.ResourceManagerStringLocalizerfor a specificSystem.Globalization.CultureInfo.Arguments: culture (System.Globalization.CultureInfo) – The System.Globalization.CultureInfoto use.Return type: Microsoft.Extensions.Localization.IStringLocalizer Returns: A culture-specific Microsoft.Extensions.Localization.ResourceManagerStringLocalizer.public IStringLocalizer WithCulture(CultureInfo culture)
-
Properties¶
-
Microsoft.Extensions.Localization.ResourceManagerStringLocalizer.Item[System.String]¶ Return type: Microsoft.Extensions.Localization.LocalizedString public virtual LocalizedString this[string name] { get; }
-
Microsoft.Extensions.Localization.ResourceManagerStringLocalizer.Item[System.String, System.Object[]] Return type: Microsoft.Extensions.Localization.LocalizedString public virtual LocalizedString this[string name, params object[] arguments] { get; }
-