Hide

YetaWF.DataProvider.PostgreSQL Package Documentation

Display
Print

YetaWF.DataProvider.PostgreSQL.SQLModuleObject<KEY,OBJTYPE>.LocalizeModelAsync Method

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

Class: YetaWF.DataProvider.PostgreSQL.SQLModuleObject<KEY,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 );
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

(not specified)

saveRecordAsync

(not specified)

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.

See Also YetaWF.DataProvider.PostgreSQL.SQLModuleObject<KEY,OBJTYPE> ClassYetaWF.DataProvider.PostgreSQLYetaWF.Core