PHPackages                             bpnpdl/easy-locale - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. bpnpdl/easy-locale

ActiveLibrary[Localization &amp; i18n](/categories/localization)

bpnpdl/easy-locale
==================

Easy localization for Laravel

v0.1.2(4mo ago)21MITPHPPHP ^8.2

Since Jan 3Pushed 4mo agoCompare

[ Source](https://github.com/bpnpdl1/easy-locale)[ Packagist](https://packagist.org/packages/bpnpdl/easy-locale)[ RSS](/packages/bpnpdl-easy-locale/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (5)Used By (0)

Easy Locale for Laravel
=======================

[](#easy-locale-for-laravel)

Easy Locale adds locale-aware routing and link generation to Laravel with a simple, predictable rule:

- The default locale has no URL prefix (clean URLs).
- Non-default locales are prefixed as the first URL segment (e.g., `/np/about`).

This helps you ship a single set of routes while presenting localized URLs only when needed.

Features
--------

[](#features)

- Clean URLs for your default locale (e.g., `en` → `/about`).
- Prefixed URLs for non-default locales (e.g., `np` → `/np/about`).
- Lightweight helper to group your routes once and let the package handle locale prefixes.
- Built-in locale switch endpoint to redirect correctly when changing languages.
- Optional, publishable Blade switcher UI and translation stubs.

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 12 (Illuminate Support ^12.0)

Installation (Composer)
-----------------------

[](#installation-composer)

Install from Packagist:

```
composer require bpnpdl/easy-locale
```

Laravel will auto-discover the service provider.

Publish assets
--------------

[](#publish-assets)

```
php artisan vendor:publish --provider="Bpnpdl\EasyLocale\EasyLocaleServiceProvider" --tag=config
php artisan vendor:publish --provider="Bpnpdl\EasyLocale\EasyLocaleServiceProvider" --tag=lang
php artisan vendor:publish --provider="Bpnpdl\EasyLocale\EasyLocaleServiceProvider" --tag=views
```

Configuration
-------------

[](#configuration)

`config/easy-locale.php`:

```
return [
        'locales' => [
                'en' => 'English',
                'np' => 'नेपाली',
                // add more like:
                // 'hi' => 'Hindi',
                // 'es' => 'Español',
        ],
        'default' => 'en', // default app locale; has no URL prefix
];
```

Routing: group by current locale
--------------------------------

[](#routing-group-by-current-locale)

Group your frontend routes once. Easy Locale mounts them with no prefix for the default locale and with `/{locale}` for others:

```
use Bpnpdl\EasyLocale\Services\GroupLocaleRouteService;

$frontend = function () {
        Route::get('/', fn () => view('welcome'))->name('home');
        Route::get('/about', [PageController::class, 'about'])->name('about');
        Route::get('/contact', [PageController::class, 'contact'])->name('contact');
};

GroupLocaleRouteService::setLocaleRoutePrefix($frontend);
```

Behind the scenes, the package sets `app()->getLocale()` from the first URL segment if it matches a configured locale; otherwise it uses your configured default. This means you avoid duplicating route definitions while still serving localized paths.

Locale switching
----------------

[](#locale-switching)

The package registers:

- `GET /locale/{locale}` → `easy-locale.switch-language`

Use it to switch languages without breaking URLs. Examples:

```
English
नेपाली
```

If you prefer a ready-made UI, include the switcher view:

```
@include('easy-locale::switcher')
{{-- or if you published views: --}}
@include('vendor.easy-locale.switcher')
```

Translations and views
----------------------

[](#translations-and-views)

- Translations can be published to `lang/vendor/easy-locale`.
- Views can be published to `resources/views/vendor/easy-locale`.

Use your own app translation files (e.g., `lang/en/pages.php`, `lang/np/pages.php`) for labels and navigation. The package does not override your app’s translation loading; it focuses on routing and URL shape.

In your app views you can use normal Laravel translation files (e.g., `lang/en/*.php`, `lang/np/*.php`). The package itself does not override your app’s translation loading.

Example: links
--------------

[](#example-links)

When you build links using named routes, the current locale determines the URL. Use your app's translation labels for link text:

```
{{ __('pages.home') }}
{{ __('pages.about') }}
{{ __('pages.contact') }}
```

- Default locale `en`: `/`, `/about`, `/contact`
- Locale `np`: `/np`, `/np/about`, `/np/contact`

Troubleshooting
---------------

[](#troubleshooting)

- Seeing `/en/...` when you expect no prefix? Ensure `default` in `config/easy-locale.php` is set to `en` and that you group routes with `GroupLocaleRouteService`.
- Switching to the default locale still shows a prefix? Use the `easy-locale.switch-language` route; it removes the prefix for the default locale.
- Added a new locale but URLs don’t work? Add the locale code to `config('easy-locale.locales')`, clear caches, and verify your route group is using `GroupLocaleRouteService`.

Contributing
------------

[](#contributing)

We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for the full development workflow, coding standards, and PR process.

License
-------

[](#license)

MIT — see [LICENSE.md](LICENSE.md).

Contact
-------

[](#contact)

- Email:
- LinkedIn:

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance77

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

126d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3a008efe0de671dc5b41bd3b22dc9dffcf9aed8994b7a4f4259f4ba1353f8f50?d=identicon)[bpnpdl](/maintainers/bpnpdl)

---

Top Contributors

[![bpnpdl1](https://avatars.githubusercontent.com/u/79793674?v=4)](https://github.com/bpnpdl1 "bpnpdl1 (2 commits)")

---

Tags

laravel-packagelocalizationurl

### Embed Badge

![Health badge](/badges/bpnpdl-easy-locale/health.svg)

```
[![Health](https://phpackages.com/badges/bpnpdl-easy-locale/health.svg)](https://phpackages.com/packages/bpnpdl-easy-locale)
```

###  Alternatives

[barryvdh/laravel-translation-manager

Manage Laravel Translations

1.7k3.6M17](/packages/barryvdh-laravel-translation-manager)[vluzrmos/language-detector

Detect the language for your application using browser preferences, subdomains or route prefixes.

109554.8k3](/packages/vluzrmos-language-detector)[kerigard/laravel-lang-ru

Ru lang for Laravel

2116.8k](/packages/kerigard-laravel-lang-ru)[highsolutions/laravel-translation-manager

Manage Laravel Translations

1518.8k](/packages/highsolutions-laravel-translation-manager)[amendozaaguiar/laraveles-spanish-for-jetstream

Archivos de traducción al español latinoamericano para Laravel con Jetstream (auth, pagination, passwords, validation + todas las cadenas de Jetstream).

1412.1k](/packages/amendozaaguiar-laraveles-spanish-for-jetstream)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
