PHPackages                             palgoals/locale-package - 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. palgoals/locale-package

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

palgoals/locale-package
=======================

A Laravel package for database-driven multilingual support with language switcher, translation management, and RTL/LTR auto-detection.

v1.1.0(1mo ago)03MITPHPPHP ^8.1

Since Apr 13Pushed 1mo agoCompare

[ Source](https://github.com/palgooal/palgoals-locale-package)[ Packagist](https://packagist.org/packages/palgoals/locale-package)[ RSS](/packages/palgoals-locale-package/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (5)Versions (3)Used By (0)

PalGoals Locale Package
=======================

[](#palgoals-locale-package)

A Laravel package for **database-driven multilingual support** with language management, translation CRUD, RTL/LTR auto-detection, and ready-to-use Blade components.

Features
--------

[](#features)

- ✅ Database-driven translations with `t('key')` helper
- ✅ Auto-create missing translation keys in the DB
- ✅ Cache per key/locale pair (configurable TTL)
- ✅ Fallback locale chain
- ✅ RTL / LTR auto-detection via `current_dir()`
- ✅ Language switcher Blade components (frontend + dashboard)
- ✅ Full CRUD admin panel for languages and translations
- ✅ Supports Laravel 10, 11, 12

---

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

[](#requirements)

- PHP 8.1+
- Laravel 10 / 11 / 12

---

Installation
------------

[](#installation)

### Step 1 — Install via Composer

[](#step-1--install-via-composer)

```
composer require palgoals/locale-package
```

### Step 2 — Run the installer

[](#step-2--run-the-installer)

```
php artisan locale:install
```

This single command will:

- ✅ Publish all files (Models, Controllers, Middleware, Views, Routes, Config)
- ✅ Run migrations (creates `languages` and `translation_values` tables)

> **Optional:** Add `--seed` to seed default languages automatically:
>
> ```
> php artisan locale:install --seed
> ```

### Step 3 — Register the Helper

[](#step-3--register-the-helper)

In your project's `composer.json`, add the helper to autoload:

```
"autoload": {
    "files": [
        "app/helpers_locale.php"
    ]
}
```

Then run:

```
composer dump-autoload
```

### Step 4 — Register the Middleware

[](#step-4--register-the-middleware)

**Laravel 11+** — in `bootstrap/app.php`:

```
->withMiddleware(function (Middleware $middleware) {
    $middleware->alias([
        'setLocale' => \App\Http\Middleware\SetLocale::class,
    ]);
})
```

**Laravel 10 and below** — in `app/Http/Kernel.php`:

```
protected $middlewareAliases = [
    'setLocale' => \App\Http\Middleware\SetLocale::class,
];
```

### Step 5 — Add Routes

[](#step-5--add-routes)

In `routes/web.php`:

```
Route::middleware(['setLocale'])->group(function () {
    require __DIR__ . '/lang.php';
    // ... your other routes
});
```

In your dashboard routes file (inside auth/admin group):

```
require __DIR__ . '/lang_dashboard.php';
```

### Step 6 — Share Variables with All Views

[](#step-6--share-variables-with-all-views)

In `app/Providers/AppServiceProvider.php` inside `boot()`:

```
view()->composer('*', function ($view) {
    $view->with([
        'currentLocale'   => app()->getLocale(),
        'currentLanguage' => \App\Models\Language::where('code', app()->getLocale())->first(),
        'languages'       => \App\Models\Language::where('is_active', true)->get(),
    ]);
});
```

---

Usage
-----

[](#usage)

### Translate text

[](#translate-text)

```
{{ t('frontend.nav.home') }}
{{ t('frontend.hero.title', 'Welcome') }}
{!! t_html('frontend.about.description') !!}
```

### Page direction (RTL / LTR)

[](#page-direction-rtl--ltr)

```

```

### Language Switcher (Frontend)

[](#language-switcher-frontend)

```

```

### Language Switcher (Dashboard)

[](#language-switcher-dashboard)

```

```

### CMS Page Slug (optional — requires `App\Models\Page`)

[](#cms-page-slug-optional--requires-appmodelspage)

```
{{ t('frontend.nav.about') }}
```

---

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

[](#configuration)

After installation, edit `config/palgoals-locale.php`:

```
return [
    // Optional: resolve default language from your own settings model
    'default_language_resolver' => function () {
        return \App\Models\GeneralSetting::first()?->default_language_code
            ?? config('app.locale');
    },

    // Auto-create missing translation keys in the DB
    'auto_create' => env('TRANSLATION_AUTO_CREATE', true),

    // Cache duration in seconds
    'cache_ttl' => env('TRANSLATION_CACHE_TTL', 60),
];
```

### `.env` options

[](#env-options)

```
TRANSLATION_AUTO_CREATE=true
TRANSLATION_CACHE_TTL=60
APP_LOCALE=ar
APP_FALLBACK_LOCALE=en
```

---

Views Note
----------

[](#views-note)

The dashboard views (`resources/views/dashboard/lang/`) depend on your project's layout components:

- `` — your project's dashboard layout
- `` — your project's input component

Edit these views after installation to match your project's component names.

---

License
-------

[](#license)

MIT — © [PalGoals](https://github.com/palgooal)

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance89

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

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

2

Last Release

56d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f37b7d71a28c093a13146eb918126831ca239f3f9ac16235e3e4c97d872ed6e8?d=identicon)[palgooal](/maintainers/palgooal)

---

Top Contributors

[![palgooal](https://avatars.githubusercontent.com/u/25554014?v=4)](https://github.com/palgooal "palgooal (5 commits)")

---

Tags

laraveli18ntranslationmultilinguallocalertllanguage-switcher

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/palgoals-locale-package/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k51.0M7.4k](/packages/larastan-larastan)[api-platform/laravel

API Platform support for Laravel

59156.3k10](/packages/api-platform-laravel)[simplestats-io/laravel-client

Analytics for Laravel. Track visitors, registrations, and payments. Discover which channels actually drive revenue, not just traffic. Server-side, GDPR compliant, ad-blocker proof.

5019.3k](/packages/simplestats-io-laravel-client)[calebdw/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

15104.9k4](/packages/calebdw-larastan)

PHPackages © 2026

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