MediaWiki Extension · Wikibase · GPL v2
A native 2-state Boolean
for self-hosted Wikibase
WikibaseBoolean adds a genuine true/false datatype to standalone Wikibase installations that don't need Wikidata's item-based workaround — a checkbox where you'd otherwise juggle two items, a query pattern, and a pair of labels for every single flag.
Quick start
# From your MediaWiki extensions/ directory git clone https://github.com/lucamauri/WikibaseBoolean # Enable it (after Wikibase Repository) echo 'wfLoadExtension( "WikibaseBoolean" );' >> LocalSettings.php # Composer-based install: see the README
What's included
Five focused components
Each piece does exactly one job in the parse → validate → store → display/export pipeline. Nothing here tries to do more than its name says.
Parser
BooleanParser
Accepts a checkbox state or typed text (true/yes/1,
false/no/0) and produces the
one canonical stored value.
Validator
BooleanValidator
Confirms a stored value is genuinely well-formed -- exactly
"true" or "false" -- before it's ever
accepted, whatever wrote it.
Formatter
BooleanFormatter
Localized, format-aware display -- plain text, wikitext, or HTML with a ✓/✗ glyph -- via a message-lookup abstraction.
RDF mapper
BooleanRdfMapper
Exports to a plain xsd:boolean literal for the
Wikibase Query Service, by exact string equality -- never
truthiness.
Edit widget
jquery.valueview.experts.Boolean
A checkbox right in the statement editor, instead of a raw text field for something with exactly two valid values.
How it fits together
Architecture overview
One value flows through validation once, then branches into whichever direction it's needed: shown to a person, or exported as RDF.
│
▼
BooleanParser → StringValue("true" / "false")
│
▼
BooleanValidator confirms exactly "true" or "false"
│
├──► BooleanFormatter "True" / "False" (localized)
└──► BooleanRdfMapper "true"^^xsd:boolean
The stored value is a plain DataValues\StringValue,
not a native PHP boolean -- a deliberate fix for a real Wikibase-core bug.
See ADR-0006
for the full trace.
Prerequisites
What you need first
A small, standard footprint -- nothing beyond what Wikibase itself already needs.
- MediaWiki 1.43 or later
- PHP 8.1 or later
- The Wikibase Repository extension
- Composer (for dependency resolution)
Documentation
Guides and references
Everything below lives in the repository itself -- one source, linked from everywhere else.