jobmetric/laravel-language

It is a standard package for managing different system languages in Laravel.

1.12.0 2024-12-26 08:11 UTC

This package is auto-updated.

Last update: 2024-12-26 08:11:42 UTC


README

Contributors Forks Stargazers MIT License LinkedIn

Language for laravel

It is a standard package for managing different system languages in Laravel.

Install via composer

Run the following command to pull in the latest version:

composer require jobmetric/laravel-language

Documentation

This package evolves every day under continuous development and integrates a diverse set of features. It's a must-have asset for Laravel enthusiasts and provides a seamless way to align your projects with basic language models.

To use the services of this package, please follow the instructions below.

Before doing anything, you must migrate after installing the package by composer.

php artisan migrate

Usage

Store language

You can store a new language by using the following code:

use JobMetric\Language\Facades\Language

$language = Language::store([
    'name' => 'English',
    'flag' => 'us',
    'locale' => 'en',
    'direction' => 'ltr',
    'status' => true
]);

Update language

You can update an existing language by using the following code:

use JobMetric\Language\Facades\Language

$language = Language::update($language->id, [
    'name' => 'English',
    'flag' => 'us',
    'locale' => 'en',
    'direction' => 'ltr',
    'status' => true
]);

Delete language

You can delete an existing language by using the following code:

use JobMetric\Language\Facades\Language

$language = Language::delete($language->id);

Get all languages

You can get all languages by using the following code:

use JobMetric\Language\Facades\Language

$languages = Language::all();

Get language by id

You can get a language by id by using the following code:

use JobMetric\Language\Facades\Language

$language = Language::all([
    'id' => $language->id
]);

Get language by locale

You can get a language by locale by using the following code:

use JobMetric\Language\Facades\Language

$language = Language::all([
    'locale' => 'en'
]);

Rules

This package contains several rules for which you can write a listener as follows

  • CheckLocaleRule - This rule checks if the locale exists in the language table.
use JobMetric\Language\Rules\CheckLocaleRule;

$request->validate([
    'locale' => ['required', new CheckLocaleRule]
]);
  • LanguageExistsRule - This rule checks if the language exists in the language table.

Events

This package contains several events for which you can write a listener as follows

Contributing

Thank you for considering contributing to the Laravel Language! The contribution guide can be found in the CONTRIBUTING.md.

License

The MIT License (MIT). Please see License File for more information.