Class BaseJsonWriter
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
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
translationManagerTranslationManagerThe translation manager whose configuration should be written.
streamStreamThe 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
namestringThe name of the property.
valuestringThe value of the property. It is encoded as a JSON string.
isFirstboolWhether this is the first property of its object; if not, a comma precedes the property.
sbStringBuilderThe 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
translationManagerTranslationManagerThe translation manager from which the translations should be picked.
cultureCultureInfoThe culture to write.
Set this parameter to InvariantCulture to signal that the default translation should be written.
streamStreamThe 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
translationManagerTranslationManagerThe translation manager from which the translations should be picked.
culturesIReadOnlyCollection<CultureInfo>The list of cultures to write.
streamStreamThe stream to write the resulting file to.
Exceptions
- TlumachException
Always.