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 2w 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 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

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

---

Top Contributors

[![diego1araujo](https://avatars.githubusercontent.com/u/4531801?v=4)](https://github.com/diego1araujo "diego1araujo (12 commits)")

---

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

[php-translation/translator

Translator services

25224.8k5](/packages/php-translation-translator)[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.

1926.6k1](/packages/smmoosavi-php-gettext)[laradevs/spanish

labels translated to spanish

166.7k](/packages/laradevs-spanish)

PHPackages © 2026

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