PHPackages                             kuenzelit/auto-lang - 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. kuenzelit/auto-lang

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

kuenzelit/auto-lang
===================

A package to automatically detect and set the locale in a laravel application

118PHP

Since Feb 2Pushed 11y ago1 watchersCompare

[ Source](https://github.com/KuenzelIT/auto-lang)[ Packagist](https://packagist.org/packages/kuenzelit/auto-lang)[ RSS](/packages/kuenzelit-auto-lang/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

AutoLang
========

[](#autolang)

AutoLang is a small package for Laravel applications which automatically detects the users browser language and sets this language with the `App::setLocale()` command.

It uses `Session` to temporarily save the language, so it doesn't need to detect the language on every request. Furthermore you can tell AutoLang which language to use, e.g. if a user wants to switch to another language than the browser has set.

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

[](#installation)

#### Get the package

[](#get-the-package)

Use the command line to get AutoLang:

```
composer require kuenzelit/auto-lang:dev-master

```

**OR** put this line in your composer.json file:

```
"kuenzelit/auto-lang": "dev-master",

```

#### Service Provider

[](#service-provider)

Add the service provider to your list of providers in `app.php`:

```
"Kuenzelit/AutoLang/AutoLangServiceProvider",

```

#### Alias

[](#alias)

If you like, you can register an alias by putting this line in your `aliases` array

```
'AutoLang' => 'Kuenzelit\AutoLang\Facades\AutoLang',

```

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

[](#configuration)

You may use artisan to publish the configuration file and edit it to specify the languages you're offering:

```
php artisan config:publish kuenzelit/auto-lang

```

Interface
---------

[](#interface)

The `AutoLang`-Facade provides 4 methods: `set`, `get`, `availableLanguages` and `detectLanguage`:

```
/**
 * Overrides the currently detected language and sets it to the $lang param.
 * $lang has to be from the array of available languages.
 *
 * @param $lang
 * @throws \Exception
 */
public function set($lang)

/**
 * Returns the current language.
 * @return mixed
 */
public function get()

/**
 * Returns the array of available languages. Can be set in the packages config.php.
 *
 * @return array
 */
public function availableLanguages()

/**
 * Returns the language of the users browser.
 *
 * @return string
 */
public function detectLanguage()
```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4572444?v=4)[kuenzelIT](/maintainers/KuenzelIT)[@KuenzelIT](https://github.com/KuenzelIT)

### Embed Badge

![Health badge](/badges/kuenzelit-auto-lang/health.svg)

```
[![Health](https://phpackages.com/badges/kuenzelit-auto-lang/health.svg)](https://phpackages.com/packages/kuenzelit-auto-lang)
```

###  Alternatives

[smmoosavi/php-gettext

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

1927.0k1](/packages/smmoosavi-php-gettext)

PHPackages © 2026

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