Skip to content

Stdlib: Locale class — getDefault()/getDisplayName() ICU locale API missing (ext/intl/locale) #6696

Closed

Description

@PurHur

Category

stdlib

Problem

ext/intl exposes the Locale class for ICU locale IDs (Locale::getDefault(), getPrimaryLanguage(), getRegion(), getDisplayName(), …). This compiler has no intl surface (class_exists('Locale') false). Number/collator formatters (#5154, #6187) depend on locale resolution.

Self-host and i18n apps need at least Locale::getDefault() and canonical parsing before heavier ICU classes.

php-src reference

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "echo class_exists(\"Locale\")?\"yes\":\"no\", PHP_EOL;"
php bin/vm.php -r "echo method_exists(\"Locale\",\"getDefault\")?\"yes\":\"no\", PHP_EOL;"
php -r "echo class_exists(\"Locale\")?\"yes\":\"no\", \" \", Locale::getDefault(), PHP_EOL;"
'
Runtime Locale class Locale::getDefault()
Zend (intl) yes e.g. en_US_POSIX
VM no —

Scope (this repo)

Area Files
Module ext/intl/Module.php (expand beyond error-code stub #5774)
Class ext/intl/Locale.php — static methods mirroring php-src
VM v1 Delegate to host intl when available; deterministic fallback (en_US_POSIX) when ICU absent for bootstrap
Tests test/compliance/cases/stdlib/locale_get_default.phpt

PHP-in-PHP first — ICU via thin FFI/host shim, not new logic in runtime/*.c.

Done when

  • Locale::getDefault() returns non-empty BCP47-like string matching host intl when loaded.
  • Locale::getPrimaryLanguage('en_US') → en; invalid locale → false/empty per php-src.
  • Enum operands to string locale args → TypeError (php-src-strict).

Related

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 6, 2026
  2. PurHur commented on Jul 16, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler Ext — I/O & Crypto — starting this run

    Pre-triage gates:

    • north-star5-verify-fast: OK
    • vm-driver-probe: OK
    • spine-coverage: OK
    • bootstrap-inventory --check: FAIL (stale inventory doc / DOM VmDom drift — not this issue)
    • user_release_ready: no (inventory only)

    Repro: class_exists('Locale') → false on bin/vm.php despite ext/intl/VmLocale.php / LocaleGetDefault.php sources present. Implementing Locale class registration + getDefault/getDisplayName (and related) toward php-src ext/intl/locale.

  3. PurHur commented on Jul 16, 2026

    @PurHur
    OwnerAuthor

    Merged in #19524

    Verification:

    • VM: class_exists('Locale') true; extension_loaded('intl') false
    • Locale::getPrimaryLanguage('en_US') → en; getDisplayName('en_US') → English (United States)
    • Enum operand → TypeError (php-src-strict)
    • PHPT locale_get_default / locale_class_methods / locale_gated OK
    • north-star5-verify-fast OK; inventory 5092/5092; spine sync OK
  4. PurHur commented on Jul 16, 2026

    @PurHur
    OwnerAuthor

    Merged: #19524

    Locale partial surface is on master:

    • class_exists('Locale') / locale_get_default() without extension_loaded('intl')
    • Locale::getPrimaryLanguage / getRegion / getScript / getDisplayName (English fallback)
    • Enum operands → TypeError; grapheme/Collator remain gated until full ICU
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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 apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions