Class DefaultLocalizationManager
- Assembly
- TimeCockpit.Data.dll
The standard localizer in CoFX / time cockpit. Loads and Save localization info via DefaultLocalizer to a compressed binary column (named APP_LocalizedDataModel) in APP_CultureInfo. If the column APP_LocalizedDataModel does not exist, no localization is performed and the InvariantFriendlyNames are returned.
public class DefaultLocalizationManager : NameLocalizer
- Inheritance
-
ObjectDefaultLocalizationManager
- Inherited Members
-
Object.ToString()Object.Equals(Object)Object.Equals(Object, Object)Object.ReferenceEquals(Object, Object)Object.GetHashCode()Object.GetType()Object.MemberwiseClone()
Constructors
DefaultLocalizationManager()
Initializes a new instance of the DefaultLocalizationManager class.
public DefaultLocalizationManager()
DefaultLocalizationManager(DefaultLocalizer, Dictionary<String, String>)
Initializes a new instance of the DefaultLocalizationManager class.
public DefaultLocalizationManager(DefaultLocalizer localizer, Dictionary<string, string> fallbackCultures)
Parameters
localizerDefaultLocalizerthe localizer to use.
fallbackCulturesDictionary<String, String>the fallback cultures.
Methods
BuildCultureFilterAndParams(IEnumerable<String>)
Builds the query for selecting all cultures required to load.
[Obsolete]
public static Tuple<string, IEnumerable<QueryParameter>> BuildCultureFilterAndParams(IEnumerable<string> cultures)
Parameters
culturesIEnumerable<String>The cultures to load.
Returns
- Tuple<String, IEnumerable<QueryParameter>>
Returns a tuple containing the query string and the query parameters.
BuildFallbackChain(Dictionary<String, String>, HashSet<String>, String)
builds a fallback chain from the .net cultures and the defined fallback cultures.
public static Dictionary<string, string> BuildFallbackChain(Dictionary<string, string> fallbackCultures, HashSet<string> allRelevantCultures, string mainFallback)
Parameters
fallbackCulturesDictionary<String, String>The fallback cultures defined in the datamodel.
allRelevantCulturesHashSet<String>All relevant cultures.
mainFallbackStringThe fail-all fallback culture.
Returns
- Dictionary<String, String>
Returns a string array defining the fallback culture.
ClearUserLocalizations(IDataContext, IEnumerable<String>)
Removes all user localizations for all cultures or for an optionally given list of cultures.
public static void ClearUserLocalizations(IDataContext dataContext, IEnumerable<string> cultures = null)
Parameters
dataContextIDataContextThe data context to clear.
culturesIEnumerable<String>The cultures to remove.
GetApplicationLocalizations(IDataContext)
Gets the application specific localization information for the given culture.
public static DefaultLocalizer GetApplicationLocalizations(IDataContext dataContext)
Parameters
dataContextIDataContextthe data context to use.
Returns
- DefaultLocalizer
Returns a new localizer instance with the localizations loaded.
GetLocalizedBackReferenceFriendlyName(Relation, CultureInfo)
Returns the localized back reference friendly name for the specified model element.
public override string GetLocalizedBackReferenceFriendlyName(Relation elementToTranslate, CultureInfo targetCulture)
Parameters
elementToTranslateRelationModel entity for which a property has to be translated. It has to be a type derived from ModelElement.
targetCultureCultureInfoTarget culture for which the implementer has to provide a localized name. The CoFX UI will pass the current UI culture into this parameter.
Returns
- String
Localized text that CoFX has to use. A return value of null indicates that the back reference name has no translation. In this case CoFX will use the BackReferenceInvariantFriendlyName of the Relation.
GetLocalizedFriendlyName(ModelElement, CultureInfo)
Returns the localized friendly name for the specified model element.
public override string GetLocalizedFriendlyName(ModelElement elementToTranslate, CultureInfo targetCulture)
Parameters
elementToTranslateModelElementModel entity for which a property has to be translated. It has to be a type derived from ModelElement.
targetCultureCultureInfoTarget culture for which the implementer has to provide a localized name. The CoFX UI will pass the current UI culture into this parameter.
Returns
- String
Localized text that CoFX has to use. A return value of null indicates that the name has no translation. In this case CoFX will use the InvariantFriendlyName of the model element repectively the Message of the validation rule.
GetLocalizedMessage(ValidationRule, CultureInfo)
Returns the localized validation rule message for the specified validation rule.
public override string GetLocalizedMessage(ValidationRule elementToTranslate, CultureInfo targetCulture)
Parameters
elementToTranslateValidationRuleValidationRule for which the message has to be translated.
targetCultureCultureInfoTarget culture for which the implementer has to provide a localized name. The CoFX UI will pass the current UI culture into this parameter.
Returns
- String
Localized text that CoFX has to use. A return value of null indicates that the message has no translation. In this case CoFX will use the Message of the ValidationRule.
GetLocalizedMessage(Permission, CultureInfo)
Returns the localized permission message for the specified permissions.
public override string GetLocalizedMessage(Permission elementToTranslate, CultureInfo targetCulture)
Parameters
elementToTranslatePermissionPermission for which the message has to be translated.
targetCultureCultureInfoTarget culture for which the implementer has to provide a localized name. The CoFX UI will pass the current UI culture into this parameter.
Returns
- String
Localized text that CoFX has to use. A return value of null indicates that the message has no translation. In this case CoFX will use the Message of the Permission.
GetLocalizedText(String, CultureInfo, String)
Gets the localized text by looking at the localizer table loaded. If the target culture
public override string GetLocalizedText(string textConstantIdentifier, CultureInfo targetCulture, string defaultText = null)
Parameters
textConstantIdentifierStringThe identifier of the text to translate.
targetCultureCultureInfoThe target culture to translate to.
defaultTextStringThe default text to fallback to.
Returns
- String
Returns a localized string.
GetUserLocalizations(IDataContext)
Gets the user specific localization information for the given culture.
public static DefaultLocalizer GetUserLocalizations(IDataContext dataContext)
Parameters
dataContextIDataContextthe data context to use.
Returns
- DefaultLocalizer
returns a new localizer instance with the localization for the user specific parts.
PrepareLocalizations(IDataContext)
prepares the localizer to serve localizations specified.
public override void PrepareLocalizations(IDataContext dataContext)
Parameters
dataContextIDataContextthe data context to query for culture information.
PrepareLocalizationsAsync(IDataContext)
Prepares the localizer using the provided dataContext.
public override Task PrepareLocalizationsAsync(IDataContext dataContext)
Parameters
dataContextIDataContextThe datacontext to use.
Returns
- Task
Returns the data context when done loading the localizations.
SaveDirtyApplicationLocalizations(IDataContext, DefaultLocalizer)
saves the localizations that have been modified to the app column.
public static void SaveDirtyApplicationLocalizations(IDataContext dataContext, DefaultLocalizer localizations)
Parameters
dataContextIDataContextthe data context to use.
localizationsDefaultLocalizerthe localization to save.
SaveDirtyUserLocalizations(IDataContext, DefaultLocalizer)
saves the localizations that have been modified to the user column in the culture info. Before saving the localization, the localization info is reloaded and updates are merged from the localization info in the database.
public static void SaveDirtyUserLocalizations(IDataContext dataContext, DefaultLocalizer localizations)
Parameters
dataContextIDataContextthe data context to use.
localizationsDefaultLocalizerthe localization to store.
SetFallbackCultures(IDataContext)
sets the fallback cultures.
public void SetFallbackCultures(IDataContext dataContext)
Parameters
dataContextIDataContextThe data context to load localizations from.