Pure-PHP language tag library, conforming to BCP-47

Clone this repo:

Branches

  1. 441a09e .gitreview by Adam Roses Wight · 11 years ago master
  2. 2056b04 change namespace to LanguageTag by Adam Roses Wight · 11 years ago
  3. 6a9633f marginally better interface and module DI by Adam Roses Wight · 11 years ago
  4. 1a41bed Canonicalize and lookup according to BCP-47 by Adam Roses Wight · 11 years ago

Pure-PHP language tag library, conforming to BCP-47

Usage

use LanguageTag\LanguageTag;

$canonicalForm = LanguageTag::fromRaw('zh-classical')->getCanonical();
print $canonicalForm;
# 'lzh'

$availablePageLanguages = array('zh', 'lzh');
$browserAcceptedLanguages = array('en', 'zh-classical', 'fr');
$renderLanguage = LanguageTag::lookupBestLang($browserAcceptedLanguages, $availablePageLanguages);
print $renderLanguage;
# 'lzh'
  NODES
languages 4
os 4