Class BaseParser
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
UseDefaultFileForTranslations
public virtual 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 abstract bool CanHandleExtension(string fileExtension)
Parameters
fileExtensionstringThe extension to check.
Returns
DecodeTextProcessingMode(string?)
protected static TextFormat? DecodeTextProcessingMode(string? value)
Parameters
valuestring
Returns
GetAbsolutePosition(string, int, int)
protected static int GetAbsolutePosition(string text, int lineNumber, int linePosition)
Parameters
Returns
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
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 abstract 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.
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
configFilestringThe configuration file to read.
baseDirectorystringAn optional directory to language files if
configFiledoes not contain a directory.configurationTranslationConfigurationThe 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
Returns
ParseConfigurationFile(Assembly, string)
Loads configuration from the file stored in assembly resource.
public TranslationConfiguration? ParseConfigurationFile(Assembly assembly, string configFile)
Parameters
assemblyAssemblyA reference to the assembly, from which the configuration file should be loaded.
configFilestringThe 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
configFilestringThe 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
inputTextstringtextProcessingModeTextFormat
Returns
ValidateConfiguration(TranslationConfiguration)
protected virtual void ValidateConfiguration(TranslationConfiguration configuration)
Parameters
configurationTranslationConfiguration