Download the PHP package codezero/browser-locale without Composer

On this page you can find all versions of the php package codezero/browser-locale. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package browser-locale

BrowserLocale

GitHub release Build Status Code Coverage Code Quality Total Downloads

ko-fi

Get the most preferred locales from your visitor's browser.

Every browser has a setting for preferred website locales.

This can be read by PHP, usually with the $_SERVER["HTTP_ACCEPT_LANGUAGE"] variable.

$_SERVER["HTTP_ACCEPT_LANGUAGE"] will return a comma separated list of language codes. Each language code MAY have a "relative quality factor" attached ("nl;q=0.8") which determines the order of preference. For example: nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4. If no relative quality factor is present, the value is by default 1.0.

BrowserLocale parses this string and lets you access the preferred locales quickly and easily.

Requirements

Install

Instantiate

For vanilla PHP:

For Laravel:

Laravel >= 5.5 will automatically register the ServiceProvider so you can get BrowserLocale from the IOC container.

Get Primary Locale

This will return an instance of \CodeZero\BrowserLocale\Locale or null if no locale exists.

Get All Locales

This will return an array of \CodeZero\BrowserLocale\Locale instances, sorted by weight in descending order. So the first array item is the most preferred locale.

If no locales exist, an empty array will be returned.

Filter Locale Info

You can get a flattened array with only specific Locale information. These arrays will always be sorted by weight in descending order. There will be no duplicate values! (e.g. en and en-US are both the language en)

LocaleFilter

Returns an array of every locale found in the input string.

CombinedFilter

Returns an array of every locale found in the input string, while making sure the 2-letter language version of the locale is always present.

LanguageFilter

Returns an array of only the 2-letter language codes found in the input string. Language codes are also extracted from full locales and added to the results array.

CountryFilter

Returns an array of only the 2-letter country codes found in the input string. Locales that only contain a 2-letter language code will be skipped.

WeightFilter

Returns an array of all relative quality factors found in the input string. The default of 1.0 is also included.

You can create your own filters by implementing the \CodeZero\BrowserLocale\Filters\Filter interface.

Testing

Security

If you discover any security related issues, please e-mail me instead of using the issue tracker.

Changelog

A complete list of all notable changes to this package can be found on the releases page.

License

The MIT License (MIT). Please see License File for more information.


All versions of browser-locale with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0|^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package codezero/browser-locale contains the following files

Loading the files please wait ....