YetaWF.DataProvider.File Package Documentation

Display
Print

YetaWF.DataProvider.FileDataProvider<KEYTYPE,OBJTYPE>.LocalizeModelAsync Method

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

Class: YetaWF.DataProvider.FileDataProvider<KEYTYPE,OBJTYPE>
Namespace: YetaWF.DataProvider
Assembly: YetaWF.DataProvider.File

Syntax

public Task LocalizeModelAsync(
    string language,
    Func<string,bool> isHtml,
    Func<List<string>,Task<List<string>>> translateStringsAsync,
    Func<string,Task<string>> translateComplexStringAsync );

Parameters

language

The target language (see LanguageSettings.json).

isHtml

A function 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.

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 YetaWF.Core.Models.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.FileDataProvider<KEYTYPE,OBJTYPE> ClassYetaWF.DataProvider.FileYetaWF.Core