From 29572f94255eafc4175f5ec3e6c8f838110dd856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Dobro=C5=88?= Date: Tue, 16 Apr 2024 19:12:20 +0200 Subject: [PATCH] Release 3.2.4 --- CHANGELOG.md | 4 ++++ composer.json | 2 +- docs/locale_detection.md | 15 +++++++-------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d63ac88..e6e129f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/composer.json b/composer.json index c9e7440..457e123 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/docs/locale_detection.md b/docs/locale_detection.md index 5396e6b..beed022 100644 --- a/docs/locale_detection.md +++ b/docs/locale_detection.md @@ -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 @@ -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', @@ -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.