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'