Class TranslationConfiguration
Contains the configuration built when parsing source files and passed to the translation manager by the translation unit.
Inherited Members
Namespace: Tlumach.Base
Assembly: Tlumach.Base.dll
Syntax
public class TranslationConfiguration
Constructors
TranslationConfiguration(Assembly?, string, string?, string?, string?, TextFormat)
Initializes a new instance of the TranslationConfiguration class.
Used by configuration parsers.
Declaration
public TranslationConfiguration(Assembly? assembly, string defaultFile, string? @namespace, string? className, string? defaultFileLocale, TextFormat textProcessingMode)
Parameters
| Type | Name | Description |
|---|---|---|
| Assembly | assembly | An optional assembly that contains translations. May be empty if files are loaded from the disk. |
| string | defaultFile | a reference to the default file for the translation. |
| string | namespace | The namespace to which the class with generated translation units belongs. |
| string | className | The name of the class with generated translation units. |
| string | defaultFileLocale | The locale specified in the file (when supported by the file format). |
| TextFormat | textProcessingMode | 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)
Initializes a new instance of the TranslationConfiguration class.
Used by configuration parsers.
Declaration
public TranslationConfiguration(Assembly? assembly, string defaultFile, string? @namespace, string? className, string? defaultFileLocale, TextFormat textProcessingMode, bool delayedUnitCreation)
Parameters
| Type | Name | Description |
|---|---|---|
| Assembly | assembly | An optional assembly that contains translations. May be empty if files are loaded from the disk. |
| string | defaultFile | a reference to the default file for the translation. |
| string | namespace | The namespace to which the class with generated translation units belongs. |
| string | className | The name of the class with generated translation units. |
| string | defaultFileLocale | The locale specified in the file (when supported by the file format). |
| TextFormat | textProcessingMode | 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. |
| bool | delayedUnitCreation | Tells the generator to generate code for delayed creation of generated translation units. |
TranslationConfiguration(Assembly?, string, string?, TextFormat)
Initializes a new instance of the TranslationConfiguration class.
Usable by the code that does not use TranslationUnits.
Declaration
public TranslationConfiguration(Assembly? assembly, string defaultFile, string? defaultFileLocale, TextFormat textProcessingMode)
Parameters
| Type | Name | Description |
|---|---|---|
| Assembly | assembly | An optional assembly that contains translations. May be empty if files are loaded from the disk. |
| string | defaultFile | a reference to the default file for the translation. |
| string | defaultFileLocale | The locale specified in the file (when supported by the file format). |
| TextFormat | textProcessingMode | 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).
Declaration
public const string KEY_ATTR_NAME = "name"
Field Value
| Type | Description |
|---|---|
| string |
KEY_DEFAULT_FILE
The name of the default file (the one that will be loaded by default).
Declaration
public const string KEY_DEFAULT_FILE = "defaultFile"
Field Value
| Type | Description |
|---|---|
| string |
KEY_DEFAULT_LOCALE
The name of the locale of the text in the default file.
Declaration
public const string KEY_DEFAULT_LOCALE = "defaultLocale"
Field Value
| Type | Description |
|---|---|
| string |
KEY_DELAYED_UNIT_CREATION
When set to true, indicates that creation of generated translation units must be delayed until they are accessed.
Declaration
public const string KEY_DELAYED_UNIT_CREATION = "delayedUnitCreation"
Field Value
| Type | Description |
|---|---|
| string |
KEY_GENERATED_CLASS
The name of the class that the generator puts to the generated source code.
Declaration
public const string KEY_GENERATED_CLASS = "generatedClass"
Field Value
| Type | Description |
|---|---|
| string |
KEY_GENERATED_NAMESPACE
The name of the namespace that the generator puts to the generated source code.
Declaration
public const string KEY_GENERATED_NAMESPACE = "generatedNamespace"
Field Value
| Type | Description |
|---|---|
| string |
KEY_LOCALE
The name of an element in the translations section in the configuration file (XML only).
Declaration
public const string KEY_LOCALE = "locale"
Field Value
| Type | Description |
|---|---|
| string |
KEY_SECTION_TRANSLATIONS
The name of the translations section in the configuration file.
Declaration
public const string KEY_SECTION_TRANSLATIONS = "translations"
Field Value
| Type | Description |
|---|---|
| string |
KEY_SECTION_TRANSLATIONS_DOT
The name of the translations section in the configuration file suffixed with a dot.
Declaration
public static readonly string KEY_SECTION_TRANSLATIONS_DOT
Field Value
| Type | Description |
|---|---|
| string |
KEY_TEXT_PROCESSING_MODE
The name of the class that the generator puts to the generated source code.
Declaration
public const string KEY_TEXT_PROCESSING_MODE = "textProcessingMode"
Field Value
| Type | Description |
|---|---|
| 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.
Declaration
public const string KEY_TRANSLATION_ASTERISK = "*"
Field Value
| Type | Description |
|---|---|
| string |
KEY_TRANSLATION_OTHER
The optional notation to specify the file, from which all translations not listed specifically are loaded.
Declaration
public const string KEY_TRANSLATION_OTHER = "other"
Field Value
| Type | Description |
|---|---|
| string |
Properties
Assembly
Gets a reference to the assembly, in which the generated file resides.
Declaration
public Assembly? Assembly { get; }
Property Value
| Type | Description |
|---|---|
| Assembly |
ClassName
Gets the name of the class that is generated by the generator.
Declaration
public string? ClassName { get; }
Property Value
| Type | Description |
|---|---|
| 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.
Declaration
public string DefaultFile { get; }
Property Value
| Type | Description |
|---|---|
| string |
DefaultFileLocale
Gets a locale of the default file, if the locale was present in this file.
Declaration
public string? DefaultFileLocale { get; }
Property Value
| Type | Description |
|---|---|
| string |
DelayedUnitCreation
Gets the indicator used by the generator to generate the code that delays creation of generated translation units until they are accessed.
Declaration
public bool DelayedUnitCreation { get; }
Property Value
| Type | Description |
|---|---|
| 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.
Declaration
public string? DirectoryHint { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Empty
Declaration
public static TranslationConfiguration Empty { get; }
Property Value
| Type | Description |
|---|---|
| TranslationConfiguration |
Namespace
Gets the namespace, to which the generated class should belong.
Declaration
public string? Namespace { get; }
Property Value
| Type | Description |
|---|---|
| string |
TextProcessingMode
Gets the text processing mode used for parsing (it will be used for processing templates too).
Declaration
public TextFormat TextProcessingMode { get; }
Property Value
| Type | Description |
|---|---|
| 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.
Declaration
public Dictionary<string, string> Translations { get; }
Property Value
| Type | Description |
|---|---|
| Dictionary<string, string> |
Methods
GetEscapeModeFullName()
Declaration
public string GetEscapeModeFullName()
Returns
| Type | Description |
|---|---|
| string |