Class TranslationConfiguration
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
assemblyAssemblyAn optional assembly that contains translations. May be empty if files are loaded from the disk.
defaultFilestringa reference to the default file for the translation.
namespacestringThe namespace to which the class with generated translation units belongs.
classNamestringThe name of the class with generated translation units.
defaultFileLocalestringThe locale specified in the file (when supported by the file format).
textProcessingModeTextFormatspecifies 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
assemblyAssemblyAn optional assembly that contains translations. May be empty if files are loaded from the disk.
defaultFilestringa reference to the default file for the translation.
namespacestringThe namespace to which the class with generated translation units belongs.
classNamestringThe name of the class with generated translation units.
defaultFileLocalestringThe locale specified in the file (when supported by the file format).
textProcessingModeTextFormatSpecifies 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.
delayedUnitCreationboolTells the generator to generate code for delayed creation of generated translation units.
onlyDeclareKeysboolTells 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
assemblyAssemblyAn optional assembly that contains translations. May be empty if files are loaded from the disk.
defaultFilestringa reference to the default file for the translation.
defaultFileLocalestringThe locale specified in the file (when supported by the file format).
textProcessingModeTextFormatspecifies 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
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
KEY_DEFAULT_LOCALE
The name of the locale of the text in the default file.
public const string KEY_DEFAULT_LOCALE = "defaultLocale"
Field Value
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
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
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
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
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
KEY_SECTION_TRANSLATIONS
The name of the translations section in the configuration file.
public const string KEY_SECTION_TRANSLATIONS = "translations"
Field Value
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
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
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
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
Properties
Assembly
Gets a reference to the assembly, in which the generated file resides.
public Assembly? Assembly { get; }
Property Value
ClassName
Gets the name of the class that is generated by the generator.
public string? ClassName { get; }
Property Value
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
DefaultFileLocale
Gets a locale of the default file, if the locale was present in this file.
public string? DefaultFileLocale { get; }
Property Value
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
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
Empty
public static TranslationConfiguration Empty { get; }
Property Value
Namespace
Gets the namespace, to which the generated class should belong.
public string? Namespace { get; }
Property Value
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
TextProcessingMode
Gets the text processing mode used for parsing (it will be used for processing templates too).
public TextFormat? TextProcessingMode { get; }
Property Value
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
Methods
GetEscapeModeFullName()
public string GetEscapeModeFullName()