DefaultLocale: IResourceLocale;
DefaultLocale: Prognoz.Platform.Interop.ForeIO.IResourceLocale;
The DefaultLocale property returns default language of the resource editor.
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.
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.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.ForeIO;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
Resource: IResourceObject;
ResStrs: IResourceStrings;
ResStrKey: uinteger;
Locales: IResourceLocales;
Locale: IResourceLocale;
Begin
// Get current repository
mb := Params.Metabase;
// 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 the language matches the default language
If Locale.IsDefault
// If language matches, display appropriate message
Then
System.Diagnostics.Debug.WriteLine("Current translation language matches default repository language");
// If language does not match, set value for current translation language
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;
See also: