Locales: Array;
The Locales property determines the resources languages for the import.
Executing the example requires that the repository contains resources with the RESOURCES identifier. There also should be a file, into which the C:\Res.txt resources were exported.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
ImpObj: ResourceImporter;
Prov: DtTextProvider;
ResObj: IResourceObject;
CountrysArr: Array[0..1] Of String;
Log: IResourceImporterLog;
i: Integer;
s: String;
Begin
Prov := New DtTextProvider.Create;
ImpObj := New ResourceImporter.Create;
MB := MetabaseClass.Active;
MObj := MB.ItemById("RESOURCES").Edit;
ResObj := MObj As IResourceObject;
Prov.File := "C:\Res.txt";
Prov.RangeHasHeader := True;
ImpObj.Provider := Prov;
CountrysArr[0] := "ru";
CountrysArr[1] := "en";
ImpObj.Locales := CountrysArr;
ImpObj.Resource := ResObj;
ImpObj.Method := ResourceImportType.UpdateAndAdd;
ImpObj.Import;
Log := ImpObj.Log;
Debug.WriteLine("Total " + Log.Count.ToString + " records");
For i := 0 To Log.Count - 1 Do
Select Case log.State(i).ToString
Case "0": s := " - record is added";
Case "1": s := " - record is updated";
Case "2": s := " - record is skipped";
End Select;
Debug.WriteLine(Log.Item(i) + s);
End For;
End Sub UserProc;
After executing the example resources are imported from the C:\Res.txt file. The elements missing in the current resources are imported, and existing elements values are updated. Information about import process is displayed in the console window.
See also: