mohammad-zarifiyan/laravel-locale-kit

There is no license information available for the latest version (1.0.1) of this package.

A Laravel package that provides structured locale metadata alongside traditional translation files.

Maintainers

Package info

github.com/MohammadZarifiyan/Laravel-Locale-Kit

pkg:composer/mohammad-zarifiyan/laravel-locale-kit

Statistics

Installs: 9

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.1 2026-06-27 13:38 UTC

This package is auto-updated.

Last update: 2026-06-27 13:38:57 UTC


README

Laravel Locale Kit provides locale metadata for Laravel applications. It allows you to retrieve locale-specific information such as writing direction, number symbols, punctuation, calendar system, and other locale definitions.

The package also supports custom locale definitions and locale aliases.

Installation

Install the package via Composer:

composer require mohammad-zarifiyan/laravel-locale-kit:^1.0

Publishing Locale Definitions

To publish the predefined locale definition files into your application:

php artisan vendor:publish --provider="MohammadZarifiyan\LaravelLocaleKit\LocaleKitProvider" --tag="locale-kit-locales"

The files will be published to locales directory. You can edit the published files or add your own locale definitions.

Each locale definition file must be named using a locale identifier in the following format:

language_COUNTRY.json

Examples:

en_US.json
en_GB.json
fa_IR.json
fa_AF.json
ar_SA.json

You can edit the published files or add your own locale definition files.

Usage

alias()

Registers an alias for a locale identifier.

use MohammadZarifiyan\LaravelLocaleKit\LocaleKit;

LocaleKit::alias('fa', 'fa_IR');
LocaleKit::alias('en', 'en_US');
LocaleKit::alias('ar', 'ar_SA');

In this example, fa, en, and ar become aliases for the locale identifiers fa_IR, en_US, and ar_SA.

After registering an alias, any method that accepts a locale can use either the alias or the full locale identifier.

For example:

use MohammadZarifiyan\LaravelLocaleKit\LocaleKit;

LocaleKit::get('direction', 'fa');

is equivalent to:

use MohammadZarifiyan\LaravelLocaleKit\LocaleKit;

LocaleKit::get('direction', 'fa_IR');

getIdentifier()

Returns the locale identifier for a locale or alias.

use MohammadZarifiyan\LaravelLocaleKit\LocaleKit;

LocaleKit::getIdentifier('fa'); // fa_IR
LocaleKit::getIdentifier('en'); // en_US
LocaleKit::getIdentifier('fa_AF'); // fa_AF

locales()

Returns all application locales available in Laravel's lang directory.

use MohammadZarifiyan\LaravelLocaleKit\LocaleKit;

$locales = LocaleKit::locales();

Example result:

[
    'en',
    'fa',
    'ar',
]

definedLocales()

Returns all locale definition files available to the package, including custom locale definitions.

use MohammadZarifiyan\LaravelLocaleKit\LocaleKit;

$locales = LocaleKit::definedLocales();

Example result:

[
    'en_US',
    'en_GB',
    'fa_IR',
    'ar_SA',
]

get()

Returns a value from a locale definition.

use MohammadZarifiyan\LaravelLocaleKit\LocaleKit;

LocaleKit::get('calendar_system', 'en_US');

Result:

'gregorian'