Hide

YetaWF.DataProvider.PostgreSQL Package Documentation

Display
Print

YetaWF.DataProvider.PostgreSQL.SQLSimpleObjectBase<KEYTYPE,KEYTYPE2,OBJTYPE>.LocalizeModelAsync Method

Called to translate the data managed by the data provider to another language.

Class: YetaWF.DataProvider.PostgreSQL.SQLSimpleObjectBase<KEYTYPE,KEYTYPE2,OBJTYPE>
Namespace: YetaWF.DataProvider.PostgreSQL
Assembly: YetaWF.DataProvider.PostgreSQL

Syntax

public Task LocalizeModelAsync(
    string language,
    Func<string,bool> isHtml,
    Func<List<string>,Task<List<string>>> translateStringsAsync,
    Func<string,Task<string>> translateComplexStringAsync );
protected Task LocalizeModelAsync(
    string language,
    Func<string,bool> isHtml,
    Func<List<string>,Task<List<string>>> translateStringsAsync,
    Func<string,Task<string>> translateComplexStringAsync,
    Func<int,int,Task<YetaWF.Core.DataProvider.DataProviderGetRecords<OBJTYPE>>> getRecordsAsync,
    Func<OBJTYPE,PropertyInfo,PropertyInfo?,Task<YetaWF.Core.DataProvider.UpdateStatusEnum>> saveRecordAsync );

Parameters

language

The target language (see LanguageSettings.json).

isHtml

A method that can be called by the data provider to test whether a string contains HTML.

translateStringsAsync

A method that can be called to translate a collection of simple strings into the new language. A simple string does not contain HTML or newline characters.

translateComplexStringAsync

A method that can be called to translate a collection of complex strings into the new language. A complex string can contain HTML and newline characters.

getRecordsAsync

Used by derived classes to retrieve the records to translate.

saveRecordAsync

Used by derived classes to save the translated records.

Remarks

The data provider has to retrieve all records and translate them as needed using the provided translateStringsAsync and translateComplexStringAsync methods, and save the translated data.

The YetaWF.Core.Models.ObjectSupport.TranslateObject method can be used to translate all YetaWF.Core.Models.MultiString instances.

The translated data should be stored separately from the default language (except MultiString, which is part of the record). Using the language parameter, a different folder should be used to store the translated data.

The YetaWF.Core.Models.ObjectSupport.TranslateObject method is to translate all YetaWF.Core.Models.MultiString instances.

The method providing getRecordsAsync and saveRecordAsync methods is used by derived classes to translate the data managed by the data provider to another language. The derived class provides getRecordsAsync and saveRecordAsync methods, which are used to retrieve, translate and save the data.

See Also YetaWF.DataProvider.PostgreSQL.SQLSimpleObjectBase<KEYTYPE,KEYTYPE2,OBJTYPE> ClassYetaWF.DataProvider.PostgreSQLYetaWF.Core