Skip to content

Commit

Permalink
Release 3.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
richardDobron committed Apr 16, 2024
1 parent f1b6dbf commit 29572f9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to `laravel-fbt` will be documented in this file.

Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## v3.2.4 - 2024-04-16
### Changed
- Update `fbt` dependency to 3.2.5.

## v3.2.3 - 2024-01-12
### Changed
- Update `fbt` dependency to 3.2.4.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"ext-mbstring": "*",
"illuminate/contracts": "~5.5.0",
"illuminate/support": "~5.5.0",
"richarddobron/fbt": "^3.2.4"
"richarddobron/fbt": "^3.2.5"
},
"require-dev": {
"phpunit/phpunit": "^6.3",
Expand Down
15 changes: 7 additions & 8 deletions docs/locale_detection.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ To implement locale detection in your PHP project, you can use the `HTTP2` libra
composer require pear/http2
```

# Usage
## Usage
After installing the `HTTP2 library`, you can utilize it in your PHP code to detect the user's locale. Here's a basic example:

```php
Expand All @@ -37,10 +37,9 @@ class RegisterFbt
*/
public function handle(Request $request, Closure $next)
{
if ($request->user()) {
// Notice: locale of logged-in user is always preferred
FbtConfig::set('viewerContext', $request->user());
} else {
// Notice: locale of logged-in user is always preferred
if (! $request->user()) {
// List of supported languages
$supportedLanguages = [
'en' => 'en_US',
'en-UK' => 'en_UK',
Expand Down Expand Up @@ -79,10 +78,10 @@ protected $middlewareGroups = [
];
```

# Explanation
## Explanation

## HTTP Accept-Language Header
### HTTP Accept-Language Header
The `negotiateLanguage()` method works by parsing the HTTP `Accept-Language` header sent by the user's browser. This header contains information about the user's preferred languages in order of priority. The method then matches these languages against the provided list and returns the best match.

## Fallback Locale
### Fallback Locale
In case the user's preferred language is not available or cannot be determined, it's essential to have a fallback locale. This ensures that your application always defaults to a suitable language/locale even when the detection process fails.

0 comments on commit 29572f9

Please sign in to comment.