PHPackages                             wikimedia/bcp-47-code - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. wikimedia/bcp-47-code

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wikimedia/bcp-47-code
=====================

Simple interface representing languages which have a BCP 47 code

v2.0.3(3mo ago)1199.1k↑24.3%3GPL-2.0-or-laterPHPPHP &gt;=8.1

Since Nov 4Pushed 2mo ago18 watchersCompare

[ Source](https://github.com/wikimedia/mediawiki-libs-Bcp47Code)[ Packagist](https://packagist.org/packages/wikimedia/bcp-47-code)[ Docs](https://www.mediawiki.org/wiki/Bcp47Code)[ RSS](/packages/wikimedia-bcp-47-code/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (8)Versions (6)Used By (3)

[![Latest Stable Version](https://camo.githubusercontent.com/45cbc4c03479ff6b0c5d689c010451a15f440a7043ae3012858dfc4a0584ce7b/68747470733a2f2f706f7365722e707567782e6f72672f77696b696d656469612f6263702d34372d636f64652f762f737461626c652e737667)](https://packagist.org/packages/wikimedia/bcp-47-code) [![License](https://camo.githubusercontent.com/6af669c7e06cadeb72503d7cdbc3f8812ed6a74f0c2c3b480d301c59d6410c6e/68747470733a2f2f706f7365722e707567782e6f72672f77696b696d656469612f6263702d34372d636f64652f6c6963656e73652e737667)](https://packagist.org/packages/wikimedia/bcp-47-code)

Bcp47Code
=========

[](#bcp47code)

Simple interface representing languages which have a BCP 47 code.

This abstracts the details of a "language" object in MediaWiki (or your code) and exposes only the ability to convert this opaque object to an interoperable [BCP 47](https://www.rfc-editor.org/info/bcp47) code, which is the standard used in [HTML](https://www.w3.org/International/articles/language-tags/)and [HTTP](https://httpwg.org/specs/rfc9110.html#field.accept-language).

The [BCP 47](https://www.rfc-editor.org/info/bcp47) standard was originally [RFC 4647](https://www.rfc-editor.org/info/rfc4647), and is now [maintained by the IETF based on the IANA language registry](https://en.wikipedia.org/wiki/IETF_language_tag).

Additional documentation about this library can be found on [mediawiki.org](https://www.mediawiki.org/wiki/Bcp47Code).

Usage
-----

[](#usage)

```
use Wikimedia\Bcp47Code\Bcp47Code;

class YourCode {
   public function generateHtml(Bcp47Code $language, $content) {
      return "" .
          "$content";
   }
}
```

Running tests
-------------

[](#running-tests)

```
composer install
composer test

```

History
-------

[](#history)

This library was first introduced in MediaWiki 1.40 as a way to abstract the internal MediaWiki Language class in a way that could be used by external libraries such as \[Parsoid\], as well as making the interfaces between BCP 47 users (such as HTML and HTTP handlers) and core strongly typed and clear by using this opaque interface object. This avoids confusion between strings representing "MediaWiki internal language codes" (case-sensitive, usually lower-case) and strings representing "BCP 47 codes" (case-insensitive, often mixed-case).

---

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance84

Actively maintained with recent releases

Popularity35

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~299 days

Total

5

Last Release

95d ago

Major Versions

v1.0.0 → v2.0.02023-09-29

PHP version history (2 changes)v1.0.0PHP &gt;=7.4.3

v2.0.2PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/b94d9718c06ec7c3fd7a104bc44966fb7464b9ec7411582343ea35a7a6a85f08?d=identicon)[mediawiki](/maintainers/mediawiki)

![](https://www.gravatar.com/avatar/716c86d71cbf921e7912a505f89d799de398fc0a3af0bd4c8862834b2d642bd7?d=identicon)[wikimedia](/maintainers/wikimedia)

![](https://www.gravatar.com/avatar/3551c2aefb299a0c45807f7677f5b26d8a5be4a4af359b4bf4fabbdd1f2b990e?d=identicon)[cscott](/maintainers/cscott)

---

Top Contributors

[![cscott](https://avatars.githubusercontent.com/u/156080?v=4)](https://github.com/cscott "cscott (20 commits)")[![jdforrester](https://avatars.githubusercontent.com/u/881572?v=4)](https://github.com/jdforrester "jdforrester (8 commits)")[![umherirrender](https://avatars.githubusercontent.com/u/1174884?v=4)](https://github.com/umherirrender "umherirrender (3 commits)")[![reedy](https://avatars.githubusercontent.com/u/67615?v=4)](https://github.com/reedy "reedy (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wikimedia-bcp-47-code/health.svg)

```
[![Health](https://phpackages.com/badges/wikimedia-bcp-47-code/health.svg)](https://phpackages.com/packages/wikimedia-bcp-47-code)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
