Skip to main content

Interface: DataGraphLocaleFormatter

Provides utility methods to format the diagram content according to the current language.

Deprecated

Use Translation interface instead.

Extends

Methods

formatElementTypes()

formatElementTypes(types, language?): string[]

Formats an array of element types into a sorted labels to display in the UI.

Parameters

ParameterType

types

readonly ElementTypeIri[]

language?

string

Returns

string[]

Defined in

editor/dataDiagramModel.ts:969


formatIri()

formatIri(iri): string

Formats IRI to display in the UI:

  • usual IRIs are enclosed in <IRI>;
  • anonymous element IRIs displayed as (blank node).

Parameters

ParameterType

iri

string

Returns

string

Inherited from

LocaleFormatter.formatIri

Defined in

diagram/model.ts:538


formatLabel()

formatLabel(labels, fallbackIri, language?): string

Same as selectLabel() but uses local part of the fallbackIri as a fallback to display an entity referred by IRI even if there is no suitable label to use.

Example:

// Returns: 'Apple'
const name = model.locale.formatLabel(
[
model.factory.literal('Apfel', 'de'),
model.factory.literal('Яблоко', 'ru'),
],
'http://example.com/entity/Apple',
'en'
);

Parameters

ParameterType

labels

undefined | readonly Literal[]

fallbackIri

string

language?

string

Returns

string

Inherited from

LocaleFormatter.formatLabel

Defined in

diagram/model.ts:527


formatPropertyList()

formatPropertyList(properties, language?): FormattedProperty[]

Formats a map of property values into a sorted list with labels to display in the UI.

Parameters

ParameterType

properties

object

language?

string

Returns

FormattedProperty[]

Defined in

editor/dataDiagramModel.ts:978


selectLabel()

selectLabel(labels, language?): undefined | Literal

Selects a single preferred literal for the target language out of several candidates.

Language code is specified as lowercase BCP47 string (examples: en, en-gb, etc).

Example:

model.setLanguage('de');
// Returns: Rdf.Literal { value = 'Apfel', language = 'de' }
const name = model.locale.formatLabel([
model.factory.literal('Apple', 'en'),
model.factory.literal('Apfel', 'de'),
model.factory.literal('Яблоко', 'ru'),
]);

Parameters

ParameterTypeDescription

labels

readonly Literal[]

candidate literal with same or different language codes

language?

string

target language code (defaults to the DiagramModel.language)

Returns

undefined | Literal

selected literal or undefined if no suitable literal was found

Inherited from

LocaleFormatter.selectLabel

Defined in

diagram/model.ts:504