Table of Contents

Class LocalizationService

Namespace
CMS.Localization
Assembly
CMS.Globalization.dll

Localization service including the database operations.

public class LocalizationService : ILocalizationService
Inheritance
object
LocalizationService
Implements
Extension Methods

Methods

GetString(string, string, bool)

Returns specified string.

public string GetString(string resourceKey, string culture = null, bool useDefaultCulture = true)

Parameters

resourceKey string

Resource key

culture string

Culture

useDefaultCulture bool

If true the default culture translation is used if translation in chosen culture doesn't exist

Returns

string

LocalizeExpression(string, string, bool, Func<string, string, bool, string>, bool)

Localizes the given expression, handles two types of expressions:

stringkey - Simple localization

=default string|cs-cz=localized string - advanced localization

public string LocalizeExpression(string expression, string culture = null, bool encode = false, Func<string, string, bool, string> getStringMethod = null, bool useDefaultCulture = true)

Parameters

expression string

Expression to localize

culture string

Culture to use for localization

encode bool

If true, translations (replacements) are HTML encoded

getStringMethod Func<string, string, bool, string>

Method to get the resource string for localization

useDefaultCulture bool

If true the default culture translation is used if translation in chosen culture doesn't exist

Returns

string

LocalizeString(string, string, bool, bool)

Replaces "{\(stringname\)}" expressions in given text with localized strings using given culture.

public string LocalizeString(string inputText, string culture = null, bool encode = false, bool useDefaultCulture = true)

Parameters

inputText string

Input text with localizable expressions

culture string

Culture

encode bool

If true, translations (replacements) are HTML encoded

useDefaultCulture bool

If true the default culture translation is used if translation in chosen culture doesn't exist

Returns

string