Table of Contents

Class BaseParser

Namespace
Tlumach.Base
Assembly
Tlumach.Base.dll
public abstract class BaseParser
Inheritance
BaseParser
Derived
Inherited Members

Properties

RecognizeFileRefs

Gets or sets the flag that tells parsers to recognize file references in translation texts.

A file reference is the text that starts with '@' character followed by the file name (with or without a path depending on other settings). If a reference is used, the text is taken from the referenced file.

public static bool RecognizeFileRefs { get; set; }

Property Value

bool

UseDefaultFileForTranslations

public virtual 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 abstract bool CanHandleExtension(string fileExtension)

Parameters

fileExtension string

The extension to check.

Returns

bool

true if the extension is supported and false otherwise.

DecodeTextProcessingMode(string?)

protected static TextFormat? DecodeTextProcessingMode(string? value)

Parameters

value string

Returns

TextFormat?

GetAbsolutePosition(string, int, int)

protected static int GetAbsolutePosition(string text, int lineNumber, int linePosition)

Parameters

text string
lineNumber int
linePosition int

Returns

int

GetLocaleSeparatorChar()

Used for internal needs.

public virtual char GetLocaleSeparatorChar()

Returns

char

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

GetTextProcessingMode()

Used for internal needs.

protected virtual TextFormat GetTextProcessingMode()

Returns

TextFormat

The effective text processing mode.

InternalLoadTranslationStructure(string, TextFormat?)

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

protected abstract 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 abstract 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.

LoadTranslationStructure(string, string?, out TranslationConfiguration?)

Parses the specified configuration file, then loads the keys from the specified default translation file and builds a tree of keys.

The files are loaded from the disk - this method is intended to be used by generators and converters.

public TranslationTree? LoadTranslationStructure(string configFile, string? baseDirectory, out TranslationConfiguration? configuration)

Parameters

configFile string

The configuration file to read.

baseDirectory string

An optional directory to language files if configFile does not contain a directory.

configuration TranslationConfiguration

The loaded configuration or null if the method does not succeed.

Returns

TranslationTree

The constructed TranslationTree upon success or null otherwise.

Exceptions

ParserLoadException

Gets thrown when loading of a configuration file or a default translation file fails.

TextFileParseException

Gets thrown when parsing of a default translation file fails.

ParseConfiguration(string, Assembly?)

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

Parameters

fileContent string
assembly Assembly

Returns

TranslationConfiguration

ParseConfigurationFile(Assembly, string)

Loads configuration from the file stored in assembly resource.

public TranslationConfiguration? ParseConfigurationFile(Assembly assembly, string configFile)

Parameters

assembly Assembly

A reference to the assembly, from which the configuration file should be loaded.

configFile string

The name of the file to load the configuration from. This name must include a subdirectory (if any) in resource format, such as "Translations.Data" if the original files' subdirectory is "Translations\Data" or "Translations/Data".

Returns

TranslationConfiguration

The loaded configuration or null if loading failed.

ParseConfigurationFile(string)

Loads configuration from the file.

public TranslationConfiguration? ParseConfigurationFile(string configFile)

Parameters

configFile string

The name of the file to load the configuration from.

Returns

TranslationConfiguration

The loaded configuration or null if loading failed.

StringHasParameters(string, TextFormat)

public static bool StringHasParameters(string inputText, TextFormat textProcessingMode)

Parameters

inputText string
textProcessingMode TextFormat

Returns

bool

ValidateConfiguration(TranslationConfiguration)

protected virtual void ValidateConfiguration(TranslationConfiguration configuration)

Parameters

configuration TranslationConfiguration