🌍 Language Detection
Automatic language switching based on IP & browser language
Automatically detect and serve the most appropriate Flarum language based on a visitor's browser language preferences and IP-based country.
The extension is now available for Flarum 1.x.

What does it do?
Language Detection automatically determines which installed Flarum locale is most appropriate for each visitor.
It can use:
- Browser language preferences
- IP-based country detection
- Country → language mappings
- Configurable fallback rules
The extension supports both IPv4 and IPv6 and performs IP-to-country resolution locally, without sending visitor IP addresses to a third-party geolocation API.
This makes it possible to automatically serve visitors in the language that best matches their preferences and location.
Native Flarum localization integration
One of the main goals of this extension was to make language detection feel like a native part of Flarum rather than a frontend workaround.
The extension integrates directly into Flarum's middleware pipeline before the native SetLocale middleware.
The flow is:
Visitor request
↓
Language Detection
↓
Locale matching
↓
Flarum SetLocale
↓
Flarum serves the detected language
The detected locale therefore becomes the actual locale used by Flarum for the request.
There is no client-side language redirect or post-load language switch involved.
🌎 Visitor & Country Statistics
The extension can optionally collect visitor statistics to help administrators understand where their community is coming from.


You can see information such as:
- Visitor countries
- Visitor IP statistics
- Language requests
- Geographic distribution of visitors
Statistics are configurable, so administrators can decide whether they want to collect them.
🗣️ Discover languages your community needs
What languages are your visitors actually asking for?
Language Detection can track visitors requesting locales that are not currently installed on your forum.

This makes it easier to discover potential translation needs based on real traffic rather than assumptions.
🧠 Smart language matching
Browser language information isn't always specific enough to directly identify a Flarum language pack.
The extension uses a tiered matching system to handle exact locales, progressively less-specific locales, regional hints and language variants.
It also includes smarter fallbacks for languages that are split across multiple script variants:
| Browser locale | Installed variants | Selected |
zh | zh-Hans + zh-Hant | zh-Hans |
sr | sr-Cyrl + sr-Latn | sr-Latn |
no | nb + nn | nb |
ku | ckb + kmr | kmr |
More specific requests still take priority, so regional locales such as zh-CN and zh-TW are handled appropriately.
⚙️ Settings

The administration panel brings the main configuration options together.
Administrators can configure:
- Language detection behavior
- Country-to-language mappings
- Fallback behavior
- Visitor statistics
- Missing language tracking
The aim is to keep the default setup simple while providing enough flexibility for more advanced multilingual forums.
✨ Features
🌐 Browser Detection — Detect the visitor's preferred language from browser language preferences
📍 IP Country Detection — Determine the visitor's country locally using their IP address
⚡ Local Processing — No third-party IP geolocation API request is required
🔢 IPv4 & IPv6 — Supports both major IP address formats
🔄 Automatic Locale Selection — Automatically select the most appropriate installed Flarum language
🗺️ Country Mapping — Configure which languages should be preferred for specific countries
🧠 Smart Matching — Handles locale variants and ambiguous language codes intelligently
📊 Visitor Statistics — View visitor and country statistics
🔎 Missing Languages — Discover languages requested by visitors that aren't installed
🛡️ Configurable Tracking — Enable or disable statistics collection
🔧 Native Integration — Works directly with Flarum's SetLocale middleware
Privacy & Performance
IP-based country detection is performed locally by the extension.
There is no external geolocation service involved in determining a visitor's country, so there is no third-party API request on the critical request path.
Because the locale is resolved before Flarum's SetLocale middleware, the extension also avoids the need for client-side redirects or loading the forum in one language and switching afterwards.
Installation
Install the extension with Composer:
composer require huseyinfiliz/language-detection:"*"
You can also install it through Extension Manager by searching for:
huseyinfiliz/language-detection
After installation:
php flarum migrate
php flarum cache:clear
Updating
composer update huseyinfiliz/language-detection
php flarum migrate
php flarum cache:clear
Compatibility
Translations
The extension ships with English translations.
Community translations are very welcome!
Translate the extension on Weblate:
https://weblate.rob006.net/projects/flarum/huseyinfiliz-language-detection/
Links
Support & Contributing
If you find this extension useful:
- ⭐ Star the repository on GitHub
- 🌐 Contribute translations
- 🐛 Report bugs and improvements through GitHub Issues
If you liked this extension, don't forget to check out my other Flarum extensions:
https://www.huseyinfiliz.com/flarum-extensions/