Table of Contents

Class TranslationConfiguration

Namespace
Tlumach.Base
Assembly
Tlumach.Base.dll

Contains the configuration built when parsing source files and passed to the translation manager by the translation unit.

public class TranslationConfiguration
Inheritance
TranslationConfiguration
Inherited Members

Constructors

TranslationConfiguration(Assembly?, string, string?, string?, string?, TextFormat)

Initializes a new instance of the TranslationConfiguration class.

Used by configuration parsers.

public TranslationConfiguration(Assembly? assembly, string defaultFile, string? @namespace, string? className, string? defaultFileLocale, TextFormat textProcessingMode)

Parameters

assembly Assembly

An optional assembly that contains translations. May be empty if files are loaded from the disk.

defaultFile string

a reference to the default file for the translation.

namespace string

The namespace to which the class with generated translation units belongs.

className string

The name of the class with generated translation units.

defaultFileLocale string

The locale specified in the file (when supported by the file format).

textProcessingMode TextFormat

specifies how the translation entries should be parsed to determine whether they contain placeholders and to replace these placeholders with real values. See TextFormat for details.

TranslationConfiguration(Assembly?, string, string?, string?, string?, TextFormat, bool, bool)

Initializes a new instance of the TranslationConfiguration class.

Used by configuration parsers.

public TranslationConfiguration(Assembly? assembly, string defaultFile, string? @namespace, string? className, string? defaultFileLocale, TextFormat textProcessingMode, bool delayedUnitCreation, bool onlyDeclareKeys)

Parameters

assembly Assembly

An optional assembly that contains translations. May be empty if files are loaded from the disk.

defaultFile string

a reference to the default file for the translation.

namespace string

The namespace to which the class with generated translation units belongs.

className string

The name of the class with generated translation units.

defaultFileLocale string

The locale specified in the file (when supported by the file format).

textProcessingMode TextFormat

Specifies how the translation entries should be parsed to determine whether they contain placeholders and to replace these placeholders with real values. See TextFormat for details.

delayedUnitCreation bool

Tells the generator to generate code for delayed creation of generated translation units.

onlyDeclareKeys bool

Tells the generator to skip generation of translation units and just add key constants.

TranslationConfiguration(Assembly?, string, string?, TextFormat)

Initializes a new instance of the TranslationConfiguration class.

Usable by the code that does not use TranslationUnits.

public TranslationConfiguration(Assembly? assembly, string defaultFile, string? defaultFileLocale, TextFormat textProcessingMode)

Parameters

assembly Assembly

An optional assembly that contains translations. May be empty if files are loaded from the disk.

defaultFile string

a reference to the default file for the translation.

defaultFileLocale string

The locale specified in the file (when supported by the file format).

textProcessingMode TextFormat

specifies how the translation entries should be parsed to determine whether they contain placeholders and to replace these placeholders with real values. See TextFormat for details.

Fields

KEY_ATTR_NAME

The name of the "name" attribute in the translations section in the configuration file (XML only).

public const string KEY_ATTR_NAME = "name"

Field Value

string

KEY_DEFAULT_FILE

The name of the default file (the one that will be loaded by default).

public const string KEY_DEFAULT_FILE = "defaultFile"

Field Value

string

KEY_DEFAULT_LOCALE

The name of the locale of the text in the default file.

public const string KEY_DEFAULT_LOCALE = "defaultLocale"

Field Value

string

KEY_DELAYED_UNITS_CREATION

When set to true, indicates that creation of generated translation units must be delayed until they are accessed.

public const string KEY_DELAYED_UNITS_CREATION = "delayedUnitsCreation"

Field Value

string

KEY_GENERATED_CLASS

The name of the class that the generator puts to the generated source code.

public const string KEY_GENERATED_CLASS = "generatedClass"

Field Value

string

KEY_GENERATED_NAMESPACE

The name of the namespace that the generator puts to the generated source code.

public const string KEY_GENERATED_NAMESPACE = "generatedNamespace"

Field Value

string

KEY_LOCALE

The name of an element in the translations section in the configuration file (XML only).

public const string KEY_LOCALE = "locale"

Field Value

string

KEY_ONLY_DECLARE_KEYS

When set to true, indicates that translation units should not be generated, and only string keys should be declared.

public const string KEY_ONLY_DECLARE_KEYS = "onlyDeclareKeys"

Field Value

string

KEY_SECTION_TRANSLATIONS

The name of the translations section in the configuration file.

public const string KEY_SECTION_TRANSLATIONS = "translations"

Field Value

string

KEY_SECTION_TRANSLATIONS_DOT

The name of the translations section in the configuration file suffixed with a dot.

public static readonly string KEY_SECTION_TRANSLATIONS_DOT

Field Value

string

KEY_TEXT_PROCESSING_MODE

The name of the class that the generator puts to the generated source code.

public const string KEY_TEXT_PROCESSING_MODE = "textProcessingMode"

Field Value

string

KEY_TRANSLATION_ASTERISK

The optional notation to specify the file, from which all translations not listed specifically are loaded. This values gets converted to "other" in the code but may be used for clarity in the configuration files.

public const string KEY_TRANSLATION_ASTERISK = "*"

Field Value

string

KEY_TRANSLATION_OTHER

The optional notation to specify the file, from which all translations not listed specifically are loaded.

public const string KEY_TRANSLATION_OTHER = "other"

Field Value

string

Properties

Assembly

Gets a reference to the assembly, in which the generated file resides.

public Assembly? Assembly { get; }

Property Value

Assembly

ClassName

Gets the name of the class that is generated by the generator.

public string? ClassName { get; }

Property Value

string

DefaultFile

Gets a reference to the default file. The value may be a filename with or without a path, but it must include an extension, so that the proper parser can be selected.

public string DefaultFile { get; }

Property Value

string

DefaultFileLocale

Gets a locale of the default file, if the locale was present in this file.

public string? DefaultFileLocale { get; }

Property Value

string

DelayedUnitsCreation

Gets the indicator used by the generator to generate the code that delays creation of generated translation units until they are accessed.

public bool DelayedUnitsCreation { get; }

Property Value

bool

DirectoryHint

Gets or sets the hint path that can be used when locating translation files.

When configuration is loaded by the constructors of the TranslationManager class, this property is set to whatever directory is specified in the configFile parameter of the constructor, but an application is free to change it.

Another way to specify the hint is to set the TranslationsDirectory property of TranslationManager.

public string? DirectoryHint { get; set; }

Property Value

string

Empty

public static TranslationConfiguration Empty { get; }

Property Value

TranslationConfiguration

Namespace

Gets the namespace, to which the generated class should belong.

public string? Namespace { get; }

Property Value

string

OnlyDeclareKeys

Gets the indicator used by the generator to not declare TranslationUnits and only declare string constants with keys.

public bool OnlyDeclareKeys { get; }

Property Value

bool

TextProcessingMode

Gets the text processing mode used for parsing (it will be used for processing templates too).

public TextFormat? TextProcessingMode { get; }

Property Value

TextFormat?

Translations

Gets the list of individual translation items covered by the configuration. This list may be empty or incomplete, in which case, the library will use heuristics to determine the filename to load the translation from.

public Dictionary<string, string> Translations { get; }

Property Value

Dictionary<string, string>

Methods

GetEscapeModeFullName()

public string GetEscapeModeFullName()

Returns

string