PHPackages                             torann/localization - 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. torann/localization

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

torann/localization
===================

Simple subdomain localization for Laravel.

2.0.4(3mo ago)25.7k↓75%BSD-2-ClausePHPPHP ^8.2

Since May 3Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/Torann/localization)[ Packagist](https://packagist.org/packages/torann/localization)[ RSS](/packages/torann-localization/feed)WikiDiscussions 2.x Synced 2mo ago

READMEChangelog (10)Dependencies (7)Versions (20)Used By (0)

Laravel Localization - Simplified
=================================

[](#laravel-localization---simplified)

[![Build Status](https://camo.githubusercontent.com/12148ffd100f58c9bd2192e57d4a72b3093f1592c07f2feca6bfbdc834dd503b/68747470733a2f2f6170702e7472617669732d63692e636f6d2f546f72616e6e2f6c6f63616c697a6174696f6e2e7376673f6272616e63683d322e78)](https://app.travis-ci.com/Torann/localization)[![Latest Stable Version](https://camo.githubusercontent.com/9b6184971608148c5f05bd7037402c11659775b04a487fde3d936e0dd095736e/68747470733a2f2f706f7365722e707567782e6f72672f746f72616e6e2f6c6f63616c697a6174696f6e2f762f737461626c652e706e67)](https://packagist.org/packages/torann/localization)[![Total Downloads](https://camo.githubusercontent.com/5e7b26dd7cb2ac2065cf23b0b6692fa4588a60d843ffbc09a59340fe6a7cacf8/68747470733a2f2f706f7365722e707567782e6f72672f746f72616e6e2f6c6f63616c697a6174696f6e2f646f776e6c6f6164732e706e67)](https://packagist.org/packages/torann/localization)[![Patreon donate button](https://camo.githubusercontent.com/f9e075baad95563481d35174d43ef50757281abb6bc795d0f473fad452afa030/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617472656f6e2d646f6e6174652d79656c6c6f772e737667)](https://www.patreon.com/torann)[![Donate to this project using Flattr](https://camo.githubusercontent.com/d79e412f78041f87e203449041ad81848a8405cf0f3c622c51e3bad0c2a4b599/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f666c617474722d646f6e6174652d79656c6c6f772e737667)](https://flattr.com/profile/torann)[![Donate to this project using Paypal](https://camo.githubusercontent.com/604e3db9c8751116b3f765aad0353ec7ded655bbe8aaacbc38d8c4a6b784b3ed/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d50617950616c2d677265656e2e737667)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4CJA2A97NPYVU)

Simplified localization for Laravel based on the application's subdomain.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation%5D)
    - [Composer](#composer)
    - [Laravel](#laravel)
- [Methods](#methods)
- [Helpers](#helpers)
- [Determining Locale](#determining-locale)
- [License](#license)
- [Localization on Packagist](https://packagist.org/packages/torann/localization)
- [Localization on GitHub](https://github.com/Torann/localization)

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

[](#installation)

### Composer

[](#composer)

From the command line run:

```
$ composer require torann/localization

```

### Laravel

[](#laravel)

Once installed you need to register the service provider with the application. Open up `config/app.php` and find the `providers` key.

```
'providers' => [
    \Torann\Localization\LocalizationServiceProvider::class,
]
```

### Publish the configurations

[](#publish-the-configurations)

Run this on the command line from the root of your project:

```
php artisan vendor:publish --provider="Torann\Localization\LocalizationServiceProvider"
```

A configuration file will be published to `config/localization.php`.

Methods
-------

[](#methods)

The following methods are available:

- `getDefaultLocale(): string`
- `getCurrentLocale(): string`
- `setLocale(string $locale = null): string|null`
- `getLocales(): array`
- `getLocale(string $key, mixed $default = null): mixed`
- `getLocaleDirection(string $locale = 'current'): string`
- `getLocaleKeys(): array`
- `getLocalizedURL(string $url = null, mixed $locale = false, array $extra = []): string`
- `isSupported(mixed $key): bool`
- `getConfig(string $key, mixed $default = null): mixed`

Helpers
-------

[](#helpers)

Laravel Localization comes with a few helper methods

#### `localization()`

[](#localization)

Returns the `Torann\Localization\LocaleManager` instance.

#### `localize_url($url = null, $locale = null, $attributes = []): string`

[](#localize_urlurl--null-locale--null-attributes---string)

Returns the given URL adapted to provided locale.

Determining Locale
------------------

[](#determining-locale)

### By Subdomain

[](#by-subdomain)

For this to work the subdomain needs to match an enabled supported locale key.

### By Host

[](#by-host)

When the given subdomain is determined to not be valid the system can then set the locale depending on the current host. You'll need to set a map of your application's locales to hosts using the **hosts** configuration option.

### License

[](#license)

Localization is open-sourced software licensed under the BSD 2-Clause License.

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance78

Regular maintenance activity

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 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 ~197 days

Recently: every ~259 days

Total

19

Last Release

118d ago

Major Versions

0.1.8 → 1.0.02020-09-28

1.0.x-dev → 2.0.02022-05-10

PHP version history (7 changes)0.1.0PHP &gt;=5.5.9

0.1.7PHP &gt;=5.6

1.0.0PHP ^7.2

1.0.1PHP &gt;=7.2

1.0.2PHP ^7.4|^8.0

2.0.0PHP ^8.0.2

2.0.3PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1406755?v=4)[Daniel Stainback](/maintainers/torann)[@Torann](https://github.com/Torann)

---

Top Contributors

[![Torann](https://avatars.githubusercontent.com/u/1406755?v=4)](https://github.com/Torann "Torann (31 commits)")

---

Tags

laravellocalizationlocalesubdomain

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/torann-localization/health.svg)

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

###  Alternatives

[codezero/laravel-localized-routes

A convenient way to set up, manage and use localized routes in a Laravel app.

543638.1k4](/packages/codezero-laravel-localized-routes)[opgginc/codezero-laravel-localized-routes

A convenient way to set up, manage and use localized routes in a Laravel app.

2770.1k1](/packages/opgginc-codezero-laravel-localized-routes)[longman/laravel-multilang

Package to integrate multi language (multi locale) functionality in Laravel 5.x

5514.4k1](/packages/longman-laravel-multilang)[laravelista/loki

Laravel localization done right.

7816.6k](/packages/laravelista-loki)[awes-io/localization-helper

Package for convenient work with Laravel's localization features

3527.1k4](/packages/awes-io-localization-helper)

PHPackages © 2026

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