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

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

lase-peco/localization
======================

A simple localization library

1.3(1y ago)483MITPHPPHP &gt;=7.4

Since Apr 20Pushed 1y agoCompare

[ Source](https://github.com/lase-peco/localization)[ Packagist](https://packagist.org/packages/lase-peco/localization)[ Docs](https://github.com/lase-peco/localization)[ RSS](/packages/lase-peco-localization/feed)WikiDiscussions master Synced yesterday

READMEChangelog (6)Dependencies (3)Versions (8)Used By (0)

A simple localization library
=============================

[](#a-simple-localization-library)

[![Latest Version on Packagist](https://camo.githubusercontent.com/762d8dd4809616cc331012854856f64dd4541302a192a6e775a8b6898668bf7d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6173652d7065636f2f6c6f63616c697a6174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lase-peco/localization)[![Total Downloads](https://camo.githubusercontent.com/28b445e4e07041b8ff07c80471bd5accd76bd12f8c397481f5e83a158ae6c596/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6173652d7065636f2f6c6f63616c697a6174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lase-peco/localization)

A simple localization library.

Notes
-----

[](#notes)

This whole package is hugely inspired by [mcamara/laravel-localization](https://github.com/mcamara/laravel-localization), we wanted something simpler, with support for PHP IntlDateFormatter, so we made our package.

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

[](#installation)

You can install the package via composer:

```
composer require lase-peco/localization
```

Then in your Web kernel file `app/Http/Kernel.php` in the `web` array in `$middlewareGroups`, add this line to the end of the array:

```
'web' => [
     // Other middlewares
     //
     \LasePeco\Localization\Http\Middleware\Localization::class,
],
```

Then publish the config file `localization.php` with the following command to define your application languages:

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

Usage
-----

[](#usage)

### Get current language

[](#get-current-language)

Return a string with the current language `"en"`.

```
Localization::getCurrentLocale()
```

### Get current language name

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

Return a string with the name of the current language `"English"`.

```
Localization::getCurrentLocaleName()
```

### Get current language native name

[](#get-current-language-native-name)

Return a string with the native name of the current language `"Deutsch"`.

```
Localization::getCurrentLocaleNativeName()
```

### Get current regional language

[](#get-current-regional-language)

Return a string with the current regional language `"en_GB"`.

```
Localization::getCurrentLocaleRegional()
```

### Get keys of supported languages

[](#get-keys-of-supported-languages)

Return an array of supported languages in your application:

```
Localization::getSupportedLanguagesKeys()
```

```
//return
[
  0 => "ar"
  1 => "en"
  2 => "de"
]
```

### Get supported languages

[](#get-supported-languages)

Return an associative array with the supported languages for your application:

```
Localization::getSupportedLocales()
```

```
//return
[
  "en" => [
    "direction" => "ltr"
    "regional" => "en_GB"
    "name" => "English"
    "native" => "English"
  ]
  "de" => [
    "direction" => "ltr"
    "regional" => "de_DE"
    "name" => "German"
    "native" => "Deutsch"
  ]
]
```

### Set application language

[](#set-application-language)

To set the language of your application use the provided route `'locale'` with the selected language as a parameter:

```
route('locale', [$key]) // $key = "en" or "de" or ...
```

Or make a get request to `/local/{$local}`, this will set the application language to the selected language.

### Time format

[](#time-format)

`Localization::formatDate($date)` return a string of the date formatted in native Language:

Example

```
$model->created_at->intlDateFormat();
// or
Localization::formatDate($model->created_at);
```

```
//return
'Sep 14, 2021'   // 'en'
'14.09.2021'     // 'de'
'14 sept. 2021'  // 'fn'
'١٤‏/٠٩‏/٢٠٢١'    // 'ar'
```

### Date format

[](#date-format)

`Localization::formatTime($time)` return a string of the time formatted in native Language:

Example

```
$model->created_at->intlTimeFormat();
// or
Localization::formatTime($model->created_at);
```

```
//return
'1:27 PM'  // 'en'
'13:27'    // 'de'
'١:٢٧ م'   // 'ar'
```

### Date-Time format

[](#date-time-format)

`Localization::formatDateTime($date_time)` return a string of the date and time formatted in native Language:

Example

```
$model->created_at->intlDateTimeFormat();
// or
Localization::formatDateTime($model->created_at);
```

```
// return
'Sep 14, 2021, 1:27 PM'  // 'en'
'14.09.2021, 13:27'      // 'de'
'14 sept. 2021, 13:27'   // 'fr'
'١٤‏/٠٩‏/٢٠٢١, ١:٢٧ م'    // 'ar'
```

### Flags

[](#flags)

`Localization::getCurrentLocaleFlag()` return html string that represents the svg flag. `Localization::getSupportedLocalesFlags()` return an array, each item contains a html string that represents the svg flag.

The flags are set to take the full height and width of their parent tag.

Example using tailwindcss!

```
{!! Localization::getCurrentLocaleFlag() !!}{{Localization::getCurrentLocaleNativeName()}}
```

```
@foreach(Localization::getSupportedLocales() as $key => $locale)
    {!! Localization::getSupportedLocalesFlags()[$key] !!}{{$locale['native']}}
@endforeach
```

### Testing

[](#testing)

```
composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Ahmed Dabak](https://github.com/lase-peco)
- [Abdulsalam Emesh](https://github.com/lase-peco)
- [All Contributors](CONTRIBUTING.md)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.8% 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 ~222 days

Recently: every ~334 days

Total

7

Last Release

566d ago

Major Versions

0.3 → 1.02021-10-05

PHP version history (3 changes)0.1PHP ^7.1

0.2PHP &gt;=7.1.0

1.2PHP &gt;=7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11370582?v=4)[Ahmed Dabak](/maintainers/ahmeddabak)[@ahmeddabak](https://github.com/ahmeddabak)

---

Top Contributors

[![ahmeddabak](https://avatars.githubusercontent.com/u/11370582?v=4)](https://github.com/ahmeddabak "ahmeddabak (15 commits)")[![abdulsalamemesh](https://avatars.githubusercontent.com/u/49724103?v=4)](https://github.com/abdulsalamemesh "abdulsalamemesh (1 commits)")

---

Tags

flagsinternationalizationlanguagelaravellocalizationphplocalizationlase-peco

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[mcamara/laravel-localization

Easy localization for Laravel

3.6k9.7M129](/packages/mcamara-laravel-localization)[typicms/base

A modular multilingual CMS built with Laravel, enabling developers to manage structured content like pages, news, events, and more.

1.6k20.4k](/packages/typicms-base)[kg-bot/laravel-localization-to-vue

Laravel package used to collect all localization files from resources/lang (and custom) directories and sub-directories and make them available as JSON file

238940.5k5](/packages/kg-bot-laravel-localization-to-vue)[vildanbina/laravel-auto-translation

A Laravel package for automating the translation of language files.

9626.1k4](/packages/vildanbina-laravel-auto-translation)[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

3417.0k](/packages/duncanmcclean-statamic-cargo)[jayesh/laravel-gemini-translator

An interactive command to extract and generate Laravel translations using Gemini AI.

702.3k1](/packages/jayesh-laravel-gemini-translator)

PHPackages © 2026

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