Class BaseKeyValueWriter
The base class for the writers of key-value formats (INI, TOML). Each translation file of these formats holds one language; the part of a key before its last dot becomes the name of a section.
public abstract class BaseKeyValueWriter : BaseWriter
- Inheritance
-
BaseKeyValueWriter
- Derived
- Inherited Members
Methods
InternalWriteTranslations(TranslationManager, IReadOnlyCollection<CultureInfo>, Stream)
Writes translations.
protected override void InternalWriteTranslations(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.
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.
WriteKeyValueLine(string, string, StringBuilder)
Appends a line with a key and its value to the file being written, quoting and escaping them as the format requires.
protected abstract void WriteKeyValueLine(string key, string value, StringBuilder stringBuilder)
Parameters
keystringThe key (within the current section).
valuestringThe value.
stringBuilderStringBuilderThe builder of the file.
WriteSection(string, StringBuilder)
Appends the header of a section to the file being written.
protected abstract void WriteSection(string key, StringBuilder stringBuilder)
Parameters
keystringThe name of the section.
stringBuilderStringBuilderThe 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.