Interface: Translation
Defined in: coreUtils/i18n.tsx:41
Provides i18n strings and templates for the UI elements.
Methods
formatIri()
formatIri(
iri
):string
Defined in: coreUtils/i18n.tsx:135
Formats IRI to display in the UI:
- usual IRIs are enclosed in
<IRI>
; - anonymous element IRIs displayed as
(blank node)
.
Parameters
Parameter | Type |
---|---|
|
|
Returns
string
Deprecated
Use DataLocaleProvider.formatIri instead.
formatLabel()
formatLabel(
labels
,fallbackIri
,language
):string
Defined in: coreUtils/i18n.tsx:122
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 = t.formatLabel(
[
model.factory.literal('Apfel', 'de'),
model.factory.literal('Яблоко', 'ru'),
],
'http://example.com/entity/Apple',
'en'
);
Parameters
Parameter | Type |
---|---|
|
|
|
|
|
|
Returns
string
selectLabel()
selectLabel(
labels
,language
):undefined
|Literal
Defined in: coreUtils/i18n.tsx:83
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:
// Returns: Rdf.Literal { value = 'Apfel', language = 'de' }
const name = t.selectLabel(
[
model.factory.literal('Apple', 'en'),
model.factory.literal('Apfel', 'de'),
model.factory.literal('Яблоко', 'ru'),
],
'de'
);
Parameters
Parameter | Type | Description |
---|---|---|
| readonly | candidate literal with same or different language codes |
|
| target language code |
Returns
undefined
| Literal
selected literal or undefined
if no suitable literal was found
selectValues()
selectValues(
values
,language
): (Literal
|NamedNode
<string
>)[]
Defined in: coreUtils/i18n.tsx:99
Selects a subset of RDF values for the target language.
The value is included if matches at least one criteria:
- is a named node,
- is a literal without language,
- is a literal with language equal to the target language.
Language code is specified as lowercase BCP47
string (examples: en
, en-gb
, etc).
Parameters
Parameter | Type |
---|---|
| readonly ( |
|
|
Returns
(Literal
| NamedNode
<string
>)[]
template()
template(
key
,parts
):ReactNode
Defined in: coreUtils/i18n.tsx:55
Templates a translation string into React Fragment by replacing placeholders with provided React nodes (elements, etc).
Parameters
Parameter | Type |
---|---|
|
|
|
|
Returns
ReactNode
text()
text(
key
,placeholders?
):string
Defined in: coreUtils/i18n.tsx:46
Formats a translation string by replacing placeholders with provided values.
Parameters
Parameter | Type |
---|---|
|
|
|
|
Returns
string