Show / Hide Table of Contents

Class JsonStringLocalizer

Represents a service that provides localized strings using .json Files in replace of .resx files.

Inheritance
System.Object
JsonStringLocalizer
Namespace: Celerik.NetCore.Util
Assembly: cs.temp.dll.dll
Syntax
public class JsonStringLocalizer : IStringLocalizer

Constructors

JsonStringLocalizer(Assembly, String)

Initializes a new instance of the class, using CultureInfo.CurrentCulture as the defined culture to resolve resource strings.

Declaration
public JsonStringLocalizer(Assembly assembly, string baseFileName)
Parameters
Type Name Description
Assembly assembly

The assembly where we get the resource files.

System.String baseFileName

The base file name of the resource files. It includes the ResourcesPath and the TypeName. E.g.: "Resources.UtilResources".

Exceptions
Type Condition
System.ArgumentNullException

If assembly is null, or baseFileName is null or empty.

JsonStringLocalizer(Assembly, String, CultureInfo)

Initializes a new instance of the class.

Declaration
public JsonStringLocalizer(Assembly assembly, string baseFileName, CultureInfo culture)
Parameters
Type Name Description
Assembly assembly

The assembly where we get the resource files.

System.String baseFileName

The base file name of the resource files. It includes the ResourcesPath and the TypeName. E.g.: "Resources.UtilResources".

CultureInfo culture

Culture for which the resource strings will be loaded.

Exceptions
Type Condition
System.ArgumentNullException

If assembly is null, or baseFileName is null or empty, or culture is null.

Properties

Item[String]

Gets the string resource with the given name.

Declaration
public LocalizedString this[string name] { get; }
Parameters
Type Name Description
System.String name

The name of the string resource.

Property Value
Type Description
LocalizedString

String resource with the given name.

Item[String, Object[]]

Gets the string resource with the given name and formatted with the supplied arguments.

Declaration
public LocalizedString this[string name, params object[] arguments] { get; }
Parameters
Type Name Description
System.String name

The name of the string resource.

System.Object[] arguments

The values to format the string with.

Property Value
Type Description
LocalizedString

String resource with the given name and formatted with the supplied arguments.

Methods

GetAllStrings(Boolean)

Gets a list with all localized strings for the defined culture. Strings from parent cultures can be optionally added. Returned strings are ordered from more specific culture strings at the top to less specific culture strings at the bottom.

Declaration
public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures)
Parameters
Type Name Description
System.Boolean includeParentCultures

A boolean indicating whether to include strings from parent cultures.

Returns
Type Description
System.Collections.Generic.IEnumerable<LocalizedString>

List with all localized strings for the defined culture.

WithCulture(CultureInfo)

Creates a new JsonStringLocalizer with the same assembly and baseFileName of this class, and the passed-in culture.

Declaration
public IStringLocalizer WithCulture(CultureInfo culture)
Parameters
Type Name Description
CultureInfo culture

Culture for which the resource strings will be loaded.

Returns
Type Description
IStringLocalizer

JsonStringLocalizer with the same assembly and baseFileName of this class, and the passed-in culture.

In This Article
Back to top Generated by DocFX