Table of Contents

Class BaseTableParser

Namespace
Tlumach.Base
Assembly
Tlumach.Base.dll

The base class for CSV and TSV parsers.

public abstract class BaseTableParser : BaseParser
Inheritance
BaseTableParser
Derived
Inherited Members

Properties

CommentsColumnCaption

Use this property to override the caption by which the Comments column was detected.

public static string CommentsColumnCaption { get; set; }

Property Value

string

DescriptionColumnCaption

Use this property to override the caption by which the description column was detected.

public static string DescriptionColumnCaption { get; set; }

Property Value

string

LocaleSeparatorChar

Gets or sets the character that is used to separate the locale name from the base name in the names of locale-specific translation files.

public static char LocaleSeparatorChar { get; set; }

Property Value

char

TreatEmptyValuesAsAbsent

Gets or sets the indicator that tells the parser to treat empty values as missing instead of being empty.

When the text is missing from the specific translation, the text from the basic locale or from the default locale will be used. When the text is empty, this empty value will be used without a fallback to the basic or default locale.

public static bool TreatEmptyValuesAsAbsent { get; set; }

Property Value

bool

UseDefaultFileForTranslations

public override bool UseDefaultFileForTranslations { get; }

Property Value

bool

Methods

CanHandleExtension(string)

Checks whether this parser can handle a translation file with the given extension.

This method is not used for configuration files.

public override bool CanHandleExtension(string fileExtension)

Parameters

fileExtension string

The extension to check.

Returns

bool

true if the extension is supported and false otherwise.

GetLocaleSeparatorChar()

Used for internal needs.

public override char GetLocaleSeparatorChar()

Returns

char

The character, used to separate the base file name and the locale.

InternalLoadTranslationStructure(string, TextFormat?)

Loads the keys from the default translation file and builds a tree of keys.

protected override TranslationTree? InternalLoadTranslationStructure(string content, TextFormat? textProcessingMode)

Parameters

content string

The content to parse.

textProcessingMode TextFormat?

The mode of processing of the text of the default file.

Returns

TranslationTree

The constructed TranslationTree upon success or null otherwise.

Exceptions

TextParseException

Gets thrown when parsing of a default translation file fails.

LoadTranslation(string, CultureInfo?, TextFormat?)

Loads the translation information from the file and returns a translation.

public override Translation? LoadTranslation(string translationText, CultureInfo? culture, TextFormat? textProcessingMode)

Parameters

translationText string

The text of the file to load.

culture CultureInfo

An optional reference to the locale, whose translation is to be loaded. Makes sense for CSV and TSV formats that may contain multiple translations in one file.

textProcessingMode TextFormat?

The mode of processing of the text of the translation file.

Returns

Translation

The loaded translation or null if loading failed.

ParseConfiguration(string, Assembly?)

public override TranslationConfiguration? ParseConfiguration(string fileContent, Assembly? assembly)

Parameters

fileContent string
assembly Assembly

Returns

TranslationConfiguration

ReadCells(string, int, int, List<string>, out int)

Reads cells from the provided text starting at position offset.

This is an abstract function overridden by specific parsers which implement the logic or call the ReadCells(string, int, int, List<string>, out int) method with the required parameters for the default implementation.

protected abstract void ReadCells(string content, int offset, int lineNumber, List<string> buffer, out int posAfterEnd)

Parameters

content string

The text, from which the cells are read.

offset int

The starting position of the text to read from.

lineNumber int

The current line being processed. Used for error reporting.

buffer List<string>

The container for read cells.

posAfterEnd int

Upon return, is set to the position of the first character beyond the read one. EOL characters are skipped, so the value must reference the start of the next line.

ReadDelimitedLine(string, int, int, List<string>, out int, char, bool)

The implementation of reading cells from the provided text starting at position offset.

protected static void ReadDelimitedLine(string content, int offset, int lineNumber, List<string> buffer, out int posAfterEnd, char separator, bool quotedFields)

Parameters

content string

The text, from which the cells are read.

offset int

The starting position of the text to read from.

lineNumber int

The current line being processed. Used for error reporting.

buffer List<string>

The container for read cells.

posAfterEnd int

Upon return, is set to the position of the first character beyond the read one. EOL characters are skipped, so the value must reference the start of the next line.

separator char

The separator character (comma, tab, maybe something else).

quotedFields bool

Specifies whether cells are expected to be enclosed in quotes.

Exceptions

ArgumentNullException

Thrown if content or buffer is null.

TextParseException

Thrown when parsing ends with unclosed quotes (when they are used).

Events

OnCultureNameMatchCheck

Handle this event to match the column caption to a specific locale. For example, if the request is made for "de-AT" locale, you can provide the translation from the column captioned "German".

public static event EventHandler<CultureNameMatchEventArgs>? OnCultureNameMatchCheck

Event Type

EventHandler<CultureNameMatchEventArgs>