Class BaseTableParser
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
DescriptionColumnCaption
Use this property to override the caption by which the description column was detected.
public static string DescriptionColumnCaption { get; set; }
Property Value
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
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
UseDefaultFileForTranslations
public override bool UseDefaultFileForTranslations { get; }
Property Value
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
fileExtensionstringThe extension to check.
Returns
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
contentstringThe content to parse.
textProcessingModeTextFormat?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
translationTextstringThe text of the file to load.
cultureCultureInfoAn 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.
textProcessingModeTextFormat?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
Returns
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
contentstringThe text, from which the cells are read.
offsetintThe starting position of the text to read from.
lineNumberintThe current line being processed. Used for error reporting.
bufferList<string>The container for read cells.
posAfterEndintUpon 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
contentstringThe text, from which the cells are read.
offsetintThe starting position of the text to read from.
lineNumberintThe current line being processed. Used for error reporting.
bufferList<string>The container for read cells.
posAfterEndintUpon 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.
separatorcharThe separator character (comma, tab, maybe something else).
quotedFieldsboolSpecifies whether cells are expected to be enclosed in quotes.
Exceptions
- ArgumentNullException
Thrown if
contentorbufferis 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