Skip to content

Stdlib: Locale::lookup()/locale_lookup() + acceptFromHttp — BCP-47 negotiate missing (ext/intl/locale) #20036

Description

@PurHur

Category

stdlib · php-src-strict · child of #3336 / extends Locale surface (#6696)

Problem

Locale OOP today covers getDefault/setDefault/getPrimaryLanguage/getRegion/getScript/getDisplayName. Negotiating Accept-Language / preferred locale lists still missing:

API Role
Locale::lookup() / locale_lookup() Best match from locale list vs locale
Locale::filterMatches() / locale_filter_matches() Filter match predicate
Locale::acceptFromHttp() / locale_accept_from_http() Parse HTTP Accept-Language
Check Zend + intl VM (forced Locale)
method_exists('Locale','lookup') true false ❌
Locale::lookup(['de-DE','fr-FR'], 'de-CH', false, 'en_US') de_DE (or equiv) n/a

php-src reference

PHP implementation target

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r "
var_export(function_exists(\"locale_lookup\"));
"'

Done when

  • Locale::lookup(['de_DE','fr_FR'], 'de_CH', false, 'en_US') returns German match (php-src-strict shape)
  • Locale::acceptFromHttp('en-US,en;q=0.9,fr;q=0.8') non-empty preferred tag
  • locale_filter_matches true/false parity on simple lang/region pairs
  • Phantom-withheld without intl
  • ./script/phpunit.sh --filter LocaleLookup green
  • php-src-strict

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions