PHPackages                             ericlagarda/locally - 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. [Database &amp; ORM](/categories/database)
4. /
5. ericlagarda/locally

ActiveLibrary[Database &amp; ORM](/categories/database)

ericlagarda/locally
===================

Laravel 5 User Preferred Localization

1.0.1(9y ago)121MITPHP

Since Dec 7Pushed 9y ago1 watchersCompare

[ Source](https://github.com/Krato/locally)[ Packagist](https://packagist.org/packages/ericlagarda/locally)[ RSS](/packages/ericlagarda-locally/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

This is a fork to use removed package. Credits to [Mohammed Isa](https://github.com/mohd-isa)
---------------------------------------------------------------------------------------------

[](#this-is-a-fork-to-use-removed-package-credits-to-mohammed-isa)

Laravel 5 User Preferred Localization
=====================================

[](#laravel-5-user-preferred-localization)

This package allows users to set the prefered site localization. Locales are based on ISO 639-1 standard. It automatically switch the site langage to the user preference. All you have to do is install it and set a locale for the user.

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

[](#installation)

You can install the package via composer

```
composer require ericlagarda/locally

```

Then you must configure the service provider by adding this in config/app.php

```
'providers' => [
  ...
  Smartisan\Locally\LocallyServiceProvider::class,
];

```

Also, add the middleware to web group in Kernel.php

```
'web' => [
            ...
            \Smartisan\Locally\Http\Middlewares\LocallyMiddleware::class
        ],

```

And you must publish the migrations

```
php artisan vendor:publish --provider="Smartisan\Locally\LocallyServiceProvider" --tag="migrations"

```

Do not forget to migrate your tables

```
php artisan migrate

```

Finally, add the package trait in your User model.

```
class User
{
    use LocallyTrait;
}

```

Optionally, you can add a Laravel Facade and alias for it in config/app.php

```
'aliases' => [
  ...
  'Locally'   => \Smartisan\Locally\Facades\Locally::class
];

```

Usage
-----

[](#usage)

### Set User Locale

[](#set-user-locale)

If given language code is not exists, an exception will be thrown.

```
$user->setLocale('en');

```

### Get User Prefered Locale

[](#get-user-prefered-locale)

If user local is not set, the system default locale will be returned.

```
$user->getLocale(); //en

```

### Remove User Prefered Locale

[](#remove-user-prefered-locale)

```
$user->removeLocale();

```

### Supported Locales

[](#supported-locales)

An array of supported locales will be returned by scanning resources/lang folder.

```
Locally::getSupportedLocales();

```

### Get Language Code / Name

[](#get-language-code--name)

Two helper functions to get language code or name

```
Locally::getLanguageCodeByName('english'); //en
Locally::getLanguageNameByCode('en'); //English

```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/mohd-isa/locally/blob/master/LICENSE) for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity63

Established project with proven stability

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

Unknown

Total

1

Last Release

3441d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3865030b01e29299f1f6837852ba6a70fea204ceb46e58a917d4e4398268800f?d=identicon)[Krato1](/maintainers/Krato1)

---

Tags

localizationtranslateeloquentmultilingual

### Embed Badge

![Health badge](/badges/ericlagarda-locally/health.svg)

```
[![Health](https://phpackages.com/badges/ericlagarda-locally/health.svg)](https://phpackages.com/packages/ericlagarda-locally)
```

###  Alternatives

[spatie/laravel-translatable

A trait to make an Eloquent model hold translations

2.4k23.0M412](/packages/spatie-laravel-translatable)[richan-fongdasen/laravel-i18n

Simple route and eloquent localization / translation in Laravel

1296.6k](/packages/richan-fongdasen-laravel-i18n)

PHPackages © 2026

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