Table of Contents

Class DefaultLocalizationManager

Namespace
TimeCockpit.Data.Localization.Default
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
Object
DefaultLocalizationManager
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

localizer DefaultLocalizer

the localizer to use.

fallbackCultures Dictionary<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

cultures IEnumerable<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

fallbackCultures Dictionary<String, String>

The fallback cultures defined in the datamodel.

allRelevantCultures HashSet<String>

All relevant cultures.

mainFallback String

The 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

dataContext IDataContext

The data context to clear.

cultures IEnumerable<String>

The cultures to remove.

GetApplicationLocalizations(IDataContext)

Gets the application specific localization information for the given culture.

public static DefaultLocalizer GetApplicationLocalizations(IDataContext dataContext)

Parameters

dataContext IDataContext

the 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

elementToTranslate Relation

Model entity for which a property has to be translated. It has to be a type derived from ModelElement.

targetCulture CultureInfo

Target 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

elementToTranslate ModelElement

Model entity for which a property has to be translated. It has to be a type derived from ModelElement.

targetCulture CultureInfo

Target 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

elementToTranslate ValidationRule

ValidationRule for which the message has to be translated.

targetCulture CultureInfo

Target 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

elementToTranslate Permission

Permission for which the message has to be translated.

targetCulture CultureInfo

Target 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

textConstantIdentifier String

The identifier of the text to translate.

targetCulture CultureInfo

The target culture to translate to.

defaultText String

The 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

dataContext IDataContext

the 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

dataContext IDataContext

the data context to query for culture information.

PrepareLocalizationsAsync(IDataContext)

Prepares the localizer using the provided dataContext.

public override Task PrepareLocalizationsAsync(IDataContext dataContext)

Parameters

dataContext IDataContext

The 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

dataContext IDataContext

the data context to use.

localizations DefaultLocalizer

the 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

dataContext IDataContext

the data context to use.

localizations DefaultLocalizer

the localization to store.

SetFallbackCultures(IDataContext)

sets the fallback cultures.

public void SetFallbackCultures(IDataContext dataContext)

Parameters

dataContext IDataContext

The data context to load localizations from.