IResourceLocales.DefaultLocale

Syntax

DefaultLocale: IResourceLocale;

Description

The DefaultLocale property returns default language of the resource editor.

Comments

Default resource language is a language that is used to display values in default language for repository. To provide correct work, default languages in resources and repository must match.

After resources are created, they contain only the language set as default for the current default repository. If default language is not set for the repository, resources will contain language corresponding to the platform interface language. The language is a default language for resources.

Example

Executing the example requires that the repository contains resources with the APP_RESOURCE identifier. These resources contain default language as Russian and translation language as English.

Add links to the IO, Metabase system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    Resource: IResourceObject;
    ResStrs: IResourceStrings;
    ResStrKey: Integer;
    Locales: IResourceLocales;
    Locale: IResourceLocale;
Begin
    
// Get current repository
    mb := MetabaseClass.Active;
    
// Get resources
    Resource := mb.ItemById("APP_RESOURCE").Edit As IResourceObject;
    
// Get resource languages collection
    Locales := Resource.Locales;
    
// Get default resource language
    Locale := Locales.DefaultLocale;
    
// Get string elements for default language
    ResStrs := Locale.Strings;
    
// Create a new string element
    ResStrKey := ResStrs.Add;
    
// Set string element value for default language
    ResStrs.ValueByKey(ResStrKey) := "Cancel";
    
// Get current translation language
    Locale := Locales.CurrentLocale;
    
// Check if language matches default language
    If Locale.IsDefault
        
// It language matches, display appropriate message
        Then
            Debug.WriteLine(
"Current translation language matches default repository language");
        
// If language does not match, set the current translation language value
        Else
            
// Get string elements for translation language
            ResStrs := Locale.Strings;
            
// Set string element value for translation language
            ResStrs.ValueByKey(ResStrKey) := "Cancel";
    
End If;
    
// Save changes
    (Resource As IMetabaseObject).Save;
End Sub UserProc;

After executing the example a new string element is added to resources. The string element will get default language value and translation language value if the current translation language does not match the default resource language.

See also:

IResourceLocales