Locale (utils)
@ckeditor/ckeditor5-utils/src/locale
Represents the localization services.
Filtering
Properties
-
contentLanguage : String
readonly
The editor content language code in the ISO 639-1 format.
Usually the same as editor language, it can be customized by passing an optional argument to the
Locale
constructor. -
contentLanguageDirection : String
readonly
Text direction of the editor content language.
If the content language was passed directly to the
Locale
constructor, this property represents the direction of that language.If the editor content language was derived from the editor language, the content language direction is the same as the UI language direction.
The value is either
'ltr'
or'rtl'
. -
language : String
deprecated
The editor UI language code in the ISO 639-1 format.
Note: This property has been deprecated. Please use
uiLanguage
andcontentLanguage
properties instead. -
uiLanguage : String
readonly
The editor UI language code in the ISO 639-1 format.
If the content language was not specified in the
Locale
constructor, it also defines the language of the content. -
uiLanguageDirection : String
readonly
Text direction of the editor UI language. Either
'ltr'
or'rtl'
.
Methods
-
constructor( [ options ] = { [options.uiLanguage], [options.contentLanguage] } )
Creates a new instance of the Locale class. Learn more about configuring language of the editor.
Parameters
[ options ] : Object
Locale configuration.
Properties[ options.uiLanguage ] : String
The editor UI language code in the ISO 639-1 format. See
uiLanguage
.Defaults to
'en'
[ options.contentLanguage ] : String
The editor content language code in the ISO 639-1 format. If not specified, the same as
options.language
. SeecontentLanguage
.
-
t( str, [ values ] )
Translates the given string to the
uiLanguage
. This method is also available int
andt
.The strings may contain placeholders (
%<index>
) for values which are passed as the second argument.<index>
is the index in thevalues
array.editor.t( 'Created file "%0" in %1ms.', [ fileName, timeTaken ] );
This method's context is statically bound to Locale instance, so it can be called as a function:
const t = this.t; t( 'Label' );
Parameters
str : String
The string to translate.
[ values ] : Array.<String>
Values that should be used to interpolate the string.
-
_t()
private
Base for the
t
method.