Overview
Larapen provides several localization settings that control how your website handles multiple languages, visitor language detection, and URL behavior. These settings are found under Settings → General in the Localization section.
Available settings
Remove Default Locale Prefix
| Location | Settings → General → Localization |
| Options | Enabled / Disabled |
| Default | Disabled |
Controls whether the default language's code appears in URLs:
- Enabled (recommended): The default language uses clean URLs without a prefix. Example:
/aboutinstead of/en/about. Other languages still use their prefix (e.g.,/fr/a-propos). - Disabled: All languages, including the default, show their code in URLs. Example:
/en/aboutand/fr/a-propos.
/about as the canonical URL and /fr/a-propos as the French alternate.
Auto-Detect Language
| Location | Settings → General → Localization |
| Options | Disabled / Browser Language / Country Language |
| Default | Disabled |
Controls whether Larapen automatically detects and redirects visitors to their preferred language on their first visit:
Disabled
No automatic detection. All visitors see the default language unless they manually switch using the language selector or navigate to a URL with a language prefix.
Browser Language
Detects the visitor's preferred language from their browser settings (the Accept-Language HTTP header). For example, if a visitor's browser is set to French, they will be automatically redirected to the French version of the site.
How it works:
- Reads the browser's language preferences (sorted by priority).
- Matches against your active languages.
- Redirects to the best match on the first visit.
- The detection runs only once per session: subsequent page views use the session preference.
Country Language
Detects the visitor's geographic location using GeoIP (IP-to-country lookup) and redirects them to the language spoken in their country.
How it works:
- Determines the visitor's country from their IP address.
- Looks up the primary language spoken in that country.
- If the spoken language matches one of your active languages, the visitor is redirected.
- The country detection is cached in a cookie for 30 days to avoid repeated GeoIP lookups.
ip-api.com driver works without an API key but has rate limits.
Spoken Languages Mode
| Location | Settings → General → Localization |
| Options | Disabled / Active Only / Active + English / Active + Default |
| Default | Disabled |
Controls which languages appear in the front-end language switcher. This is useful if you have many active languages but only want to show a subset based on the visitor's country:
Disabled
All active languages are shown in the language switcher. This is the standard behavior.
Active Only
Only shows languages that are spoken in the default country (configured in Settings → General → Localization → Default Country). For example, if your default country is Belgium, only Dutch, French, and German would be shown.
Active + English
Shows languages spoken in the default country plus English (if English is active). Useful for international sites where English is always offered.
Active + Default
Shows languages spoken in the default country plus the default language. Ensures the site's primary language is always accessible in the switcher.
Default Country
| Location | Settings → General → Localization |
| Format | ISO 3166-1 alpha-2 country code (e.g., US, FR, BE) |
| Default | Empty |
The default country is used by:
- The Spoken Languages Mode to determine which country's languages to show.
- The Country Language auto-detection as a fallback when GeoIP detection is unavailable.
GeoIP settings (for Country Language detection)
If you use the "Country Language" auto-detection mode, you need to configure a GeoIP driver to resolve visitor IP addresses to their country. Go to Settings → GeoIP and choose from the available drivers:
| Driver | API Key Required |
|---|---|
| ip-api.com (default) | No |
| ipapi.co | No |
| ipinfo.io | Yes (token) |
| DB-IP | Optional |
| ipbase.com | Yes |
| IP2Location | Yes |
| ipgeolocation.io | Yes |
| iplocation.net | Optional |
| ipstack.com | Yes |
| MaxMind Web Service | Yes |
| MaxMind Database (offline) | License key for updates |
GeoLite2-City.mmdb (not GeoLite2-Country) and place it at /storage/database/maxmind/GeoLite2-City.mmdb. This driver is recommended for production and high-traffic sites as it does not require external API calls.
Recommended configurations
Simple bilingual site (e.g., English + French)
| Setting | Value |
|---|---|
| Remove Default Locale Prefix | Enabled |
| Auto-Detect Language | Browser Language |
| Spoken Languages Mode | Disabled |
International multi-language site
| Setting | Value |
|---|---|
| Remove Default Locale Prefix | Enabled |
| Auto-Detect Language | Browser Language |
| Spoken Languages Mode | Disabled |
Country-targeted site (e.g., Belgium)
| Setting | Value |
|---|---|
| Remove Default Locale Prefix | Enabled |
| Auto-Detect Language | Country Language |
| Spoken Languages Mode | Active + English |
| Default Country | BE |
Single language site
| Setting | Value |
|---|---|
| Remove Default Locale Prefix | Enabled |
| Auto-Detect Language | Disabled |
| Spoken Languages Mode | Disabled |
With only one active language, no language switcher is displayed and no prefixes are added to URLs.