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, 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, bool createFilledMethods)
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.
createFilledMethodsboolTells the generator to create descendant classes with "Filled" methods for entries with placeholders in the text.
TranslationConfiguration(Assembly?, string, string?, string?, string?, TextFormat, bool, bool, bool, bool, string?, string?)
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, bool createFilledMethods, bool createStringAccessors, string? stringAccessorsClass, string? stringAccessorsCulture)
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.
createFilledMethodsboolTells the generator to create descendant classes with "Filled" methods for entries with placeholders in the text.
createStringAccessorsboolTells the generator to generate a nested class with string accessors of the keys.
stringAccessorsClassstringThe name of the class with string accessors. Pass null to use the default name.
stringAccessorsCulturestringThe culture read by the string accessors, either "manager" or "ambient". Pass null to use the default.
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_CREATE_FILLED_METHODS
When set to true, indicates that key-specific translation unit classes should be created for keys with placeholders. Those classes contain "Filled()" methods.
public const string KEY_CREATE_FILLED_METHODS = "createFilledMethods"
Field Value
KEY_CREATE_STRING_ACCESSORS
When set to true, indicates that a nested class with string accessors should be generated in the generated class and in every generated group class. The accessors let the attributes that localize through a resource type and the name of a property, such as DisplayAttribute, use a class generated by Tlumach. This option is ignored when KEY_ONLY_DECLARE_KEYS is set.
public const string KEY_CREATE_STRING_ACCESSORS = "createStringAccessors"
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_DEFAULT_LOCALE_ALIAS
The deprecated alias of KEY_DEFAULT_LOCALE. It matches the name of the DefaultFileLocale property and was advertised by the documentation, so it is still accepted when reading configuration files. KEY_DEFAULT_LOCALE takes precedence when both are present, and only KEY_DEFAULT_LOCALE is ever written.
public const string KEY_DEFAULT_LOCALE_ALIAS = "defaultFileLocale"
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_STRING_ACCESSORS_CLASS
The name of the class with string accessors generated because of KEY_CREATE_STRING_ACCESSORS. The default is "Texts".
public const string KEY_STRING_ACCESSORS_CLASS = "stringAccessorsClass"
Field Value
KEY_STRING_ACCESSORS_CULTURE
The culture read by the string accessors generated because of KEY_CREATE_STRING_ACCESSORS. Set it to "ambient" to read the culture of the thread, which is what a web application that localizes requests needs; the default, "manager", reads the culture of the translation manager.
public const string KEY_STRING_ACCESSORS_CULTURE = "stringAccessorsCulture"
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
CreateFilledMethods
Gets the indicator used by the generator to create descendant classes with "Filled" methods for entries with placeholders in the text.
public bool CreateFilledMethods { get; }
Property Value
CreateStringAccessors
Gets the indicator used by the generator to generate a nested class with string accessors in the generated class and in every generated group class.
The accessors are static properties of the type string, one per key, which is what the attributes that localize through a resource type and the name of a property, such as DisplayAttribute, require. This option is ignored when OnlyDeclareKeys is set.
public bool CreateStringAccessors { 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; set; }
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
StringAccessorsClass
Gets the name of the class with string accessors generated because of CreateStringAccessors. When this property is empty, the generator uses "Texts".
public string? StringAccessorsClass { get; }
Property Value
StringAccessorsCulture
Gets the culture read by the string accessors generated because of CreateStringAccessors. When this property is set to "ambient", the accessors read the culture of the thread; otherwise they read the culture of the translation manager.
public string? StringAccessorsCulture { 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()