'en-US', 'pt-br' => 'pt-BR', 'zh-hant' => 'zh-Hant', 'sr-latn-rs' => 'sr-Latn-RS', 'es-419' => 'es-419', ]; foreach ($cases as $input => $expected) { if (LocaleCode::canonicalize($input) !== $expected) { throw new RuntimeException('Locale canonicalization failed: ' . $input); } } foreach (['', 'e', 'en-', 'en/US', 'x-private'] as $invalid) { if (LocaleCode::canonicalize($invalid) !== null) { throw new RuntimeException('Invalid locale was accepted: ' . $invalid); } } echo "Locale code canonicalization tests passed.\n";