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

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

diego1araujo/locale
===================

A better way to handle multilanguage

8364PHP

Since Oct 12Pushed 11y ago1 watchersCompare

[ Source](https://github.com/diego1araujo/locale)[ Packagist](https://packagist.org/packages/diego1araujo/locale)[ RSS](/packages/diego1araujo-locale/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![Build Status](https://camo.githubusercontent.com/859bae1ab4b3961c433ab991db5397effcfb48f0a097775d5ab6bf22a652efba/68747470733a2f2f7472617669732d63692e6f72672f646965676f31617261756a6f2f6c6f63616c652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/diego1araujo/locale)

Locale - A better way to handle multilanguage.
----------------------------------------------

[](#locale---a-better-way-to-handle-multilanguage)

The goal of this package is offer a simple way to make a multilanguage for Laravel 4/5.

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

[](#installation)

Edit `composer.json` file to require this package.

```
"require": {
	...
	"diego1araujo/locale": "dev-master"
}

```

Next, run the composer update command:

```
composer update

```

Open up `app/config/app.php`

Find the `providers` key and add a new item to the array

```
'Diego1araujo\Locale\ServiceProvider',

```

Find the `aliases` key and add a new item to the array

```
'Locale' => 'Diego1araujo\Locale\Facade',

```

Finally, publish the config file

```
php artisan config:publish diego1araujo/locale

```

Config
------

[](#config)

To see which languages are available, open up `app/config/packages/diego1araujo/locale/config.php`

By default, the main language is `en` (english) and the `available` item contains the list of languages.

Of course, feel free to change both of them.

> NOTE: The main language isn't appended in url, only others (from `available` item).

Data
----

[](#data)

Go to `app/lang/[language]` and create a new file(s) for each language (Files must have the same name for all languages)

Like this:

English `app/lang/en/message.php`

```
return array(

	'welcome' => 'Welcome to my page',

);
```

Portuguese `app/lang/pt/message.php`

```
return array(

	'welcome' => 'Bem-vindo à minha página',

);
```

Usage
-----

[](#usage)

Define the set method as a prefix value in route group

```
Route::group(array('prefix' => Locale::set()), function()
{
	Route::get('/', function()
	{
		return View::make('home');
	});

	Route::get('example', function()
	{
		return View::make('example');
	});
});
```

Printing a message

```
Lang::get('message.welcome')
```

Retrieving the current language

```
Locale::get();
```

Building url's with the current language

```
Locale::url('about'); // [site-domain]/[current-language]/about
```

### One route for many languages

[](#one-route-for-many-languages)

You can use a single route for a multiple language page. I suggest you to place all pages in your file translation.

English `app/lang/en/message.php`

```
return array(

	'menu-page' => 'Page',
	'slug-page' => 'page',

);
```

Portuguese `app/lang/pt/message.php`

```
return array(

	'menu-page' => 'Página',
	'slug-page' => 'pagina',

);
```

```
Route::group(array('prefix' => Locale::set()), function()
{
	Route::get(Lang::get('message.slug-page'), ['as' => 'page', 'uses' => 'HomeController@page']);
}
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

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://www.gravatar.com/avatar/a6c3c5164259958760ee57be585c0941ceefbe123840da5b95e9aa65401bf388?d=identicon)[diego1araujo](/maintainers/diego1araujo)

---

Tags

laravellocalemultilanguagephp

### Embed Badge

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

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

###  Alternatives

[symfony/translation

Provides tools to internationalize your application

6.6k836.5M2.1k](/packages/symfony-translation)[nesbot/carbon

An API extension for DateTime that supports 281 different languages.

169661.4M4.8k](/packages/nesbot-carbon)[joedixon/laravel-translation

A tool for managing all of your Laravel translations

717911.4k11](/packages/joedixon-laravel-translation)[illuminate/translation

The Illuminate Translation package.

6936.4M495](/packages/illuminate-translation)[lajax/yii2-translate-manager

Translation management extension for Yii 2

227578.8k13](/packages/lajax-yii2-translate-manager)[larswiegers/laravel-translations-checker

Make sure your laravel translations are checked and are included in all languages.

256423.2k2](/packages/larswiegers-laravel-translations-checker)

PHPackages © 2026

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