php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #59430 Why Locale::acceptFromHttp can't Returns with an Array?
Submitted: 2010-09-20 05:17 UTC Modified: 2021-11-11 11:15 UTC
Votes:14
Avg. Score:4.0 ± 0.9
Reproduced:11 of 12 (91.7%)
Same Version:4 (36.4%)
Same OS:3 (27.3%)
From: i at walkinraven dot name Assigned:
Status: Open Package: I18N and L10N related
PHP Version: 5.3.2 OS: Ubuntu 10.04 LTS
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
50 - 25 = ?
Subscribe to this entry?

 
 [2010-09-20 05:17 UTC] i at walkinraven dot name
Description:
------------
Locale::acceptFromHttp could only returns with a string. But HTTP Accept-Language could offer more than one language tag with priority. Why not to return an number-ordered-array like:

array
(
  0 => language tag 1,
  1 => language tag 2,
  ...
)

Ordered with priority offered by HTTP?


Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-03-22 22:10 UTC] thflori at gmail dot com
At least this yes. But in each application we will have a code that looks similar to this:

$supportedLanguages = ['de_DE','en_US'];

foreach (Loacle::acceptFromHttp as $locale) {
  if (in_array($locale, $supportedLocales)) {
    return $locale;
  }
}
return $defaultLocale;

Why a acceptFromHttp if it is useless? The best matching is not useful at all. A list of matching locales is at least useful. But even better will be a function that gives the locale we want to use:
public static function acceptFromHttp($header, $supportedLocales, $defaultLocale)
 [2017-10-24 07:52 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: stas +Assigned To:
 [2021-11-11 11:15 UTC] nikic@php.net
-Package: intl +Package: I18N and L10N related
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 05:01:28 2024 UTC