Table of Contents

Class BaseJsonWriter

Namespace
Tlumach.Writers
Assembly
Tlumach.Writers.dll

The base class for the writers of JSON-based formats. Each translation file of these formats holds one language, unless a writer overrides WriteTranslations(TranslationManager, IReadOnlyCollection<CultureInfo>, Stream).

Configuration files are written in the JSON configuration format.

public abstract class BaseJsonWriter : BaseWriter
Inheritance
BaseJsonWriter
Derived
Inherited Members

Properties

IndentationStep

Gets or sets the number of spaces to add for each level of indentation. The default value is 2.

Only JsonWriter and StringCatWriter honor this property, in the translation files they write. ArbWriter and WriteConfiguration(TranslationManager, Stream) use a fixed indentation.

public int IndentationStep { get; set; }

Property Value

int

Methods

WriteConfiguration(TranslationManager, Stream)

Writes the default configuration of the translation manager (DefaultConfiguration) as a configuration file of the format.

public override void WriteConfiguration(TranslationManager translationManager, Stream stream)

Parameters

translationManager TranslationManager

The translation manager whose configuration should be written.

stream Stream

The stream to write the resulting file to.

Exceptions

TlumachException

The translation manager has no default configuration, or the format does not support configuration files.

WriteJsonProperty(string, string, bool, StringBuilder)

Appends a property with a string value to the configuration file being written.

protected virtual void WriteJsonProperty(string name, string value, bool isFirst, StringBuilder sb)

Parameters

name string

The name of the property.

value string

The value of the property. It is encoded as a JSON string.

isFirst bool

Whether this is the first property of its object; if not, a comma precedes the property.

sb StringBuilder

The builder of the file.

WriteTranslation(TranslationManager, CultureInfo, Stream)

Writes translations in the format that supports one language in one file.

public override void WriteTranslation(TranslationManager translationManager, CultureInfo culture, Stream stream)

Parameters

translationManager TranslationManager

The translation manager from which the translations should be picked.

culture CultureInfo

The culture to write.

Set this parameter to InvariantCulture to signal that the default translation should be written.

stream Stream

The stream to write the resulting file to.

WriteTranslations(TranslationManager, IReadOnlyCollection<CultureInfo>, Stream)

Always throws an exception, as the format does not support multiple languages in one file. Use WriteTranslation(TranslationManager, CultureInfo, Stream) instead.

public override void WriteTranslations(TranslationManager translationManager, IReadOnlyCollection<CultureInfo> cultures, Stream stream)

Parameters

translationManager TranslationManager

The translation manager from which the translations should be picked.

cultures IReadOnlyCollection<CultureInfo>

The list of cultures to write.

stream Stream

The stream to write the resulting file to.

Exceptions

TlumachException

Always.