Help:Datatype "Monolingual text"

From semantic-mediawiki.org
Monolingual text
Holds a text value that associates the annotation with a specific language code
Further information
Provided by: Semantic MediaWiki
Since version: 2.4.0
Until version: still in use
Datatype ID:
_mlt_rec
In this wiki: Monolingual text
Table of Contents

The datatype Monolingual text1 associates a text value with a specific language code. The annotation form is expected as foo@en with the first element being an arbitrary text while the second element divided by @ to contain a valid language code.

Notes[edit]

  • An annotation with [[Has monolingual text::some text@en]] is identical to [[Has monolingual text::some text@EN]] because language codes are transformed to a IETF language tag / BCP47 (by "Localizer::asBCP47FormattedLanguageCode").
  • The Language code is internally managed by special property "Language code"Handles BCP47 conform language codes specifying the language of the annotated text
  • Internally each value of this special property ("MonolingualTextValue") is stored as separate entity using as special construct ("ContainerSemanticData") allowing for foo@en to be different from foo@ja by its data structure (oppose to a string comparison which only would establish that two strings are different but without the semantic interpretation that for the cited example only the language code is different).

Examples[edit]

Display text in a defined language[edit]

Annotation
[[Has monolingual text::foo@ja]]

or

{{#subobject:
 |Has monolingual text=foo@en
}}
Query
{{#ask:
 [[Has monolingual text::?@ja]]
 |?Has monolingual text|+index=1
 |mainlabel=-
 |headers=hide
}}

See <sandbox.semantic-mediawiki.org> for live examples.

Display text in context of the user language[edit]

Annotation
{{#subobject:
 |@category=Test one
 |Has monolingual text=123@en
}}{{#subobject:
 |@category=Test one
 |Has monolingual text=一二三@ja
}}
Query
{{#ask:
 [[Category:Test one]]
 [[Has monolingual text::?@{{USERLANGUAGECODE}}]]
 |?Has monolingual text|+index=1
 |mainlabel=-
 |headers=hide
}}

See <sandbox.semantic-mediawiki.org> for live examples.

The {{USERLANGUAGECODE}} variable used in this example is provided by extension "MyVariables" (MediaWiki.org).

Further examples[edit]

API example

See also[edit]

References

  1. ^  Semantic MediaWiki: GitHub pull request gh:smw:1344