bousbaadev / lang-publisher
A Laravel package that publishes language folders and adds Arabic and French validation translations
Requires
- php: ^8.0|^8.1|^8.2
- illuminate/support: ^10.0|^11.0|^12.0
README
A Laravel package that automatically publishes language folders and adds Arabic (ar) and French (fr) validation translations. Compatible with all Laravel versions including Laravel 10+ where the lang directory is at the root level.
Features
- Automatically detects and adapts to your Laravel version's language folder structure
- Publishes language files if they haven't been published yet
- Adds Arabic (ar) and French (fr) validation translations
- Works with both resource-based (Laravel 9 and below) and root-based (Laravel 10+) language directories
- Includes translations for auth, validation, pagination, and passwords files
- Simple installation with zero configuration required
Requirements
- PHP 8.0 or higher
- Laravel 10.0 or higher
Installation
You can install the package via composer:
composer require bousbaadev/lang-publisher
The package will automatically detect your Laravel version and publish the language files to the appropriate directory.
Usage
Automatic Publishing
Language files are automatically published when the package is installed. No additional configuration is required.
Manual Publishing
If you need to manually publish or update the language files, you can use the following Artisan command:
php artisan lang:publish
To force overwrite existing language files:
php artisan lang:publish --force
Supported Languages
Currently, the package supports the following languages:
- English (en)
- Arabic (ar)
- French (fr)
How It Works
The package detects your Laravel version and publishes language files to the appropriate directory:
- For Laravel 10+:
lang/
directory at the root level - For Laravel 9 and below:
resources/lang/
directory
It provides translations for the following files:
- validation.php
- auth.php
- pagination.php
- passwords.php
Contributing
Adding Support for Other Languages
We welcome contributions to add support for additional languages. Here's how you can contribute:
-
Fork the Repository
- Visit the GitHub repository
- Click the "Fork" button in the top-right corner
-
Clone Your Fork
git clone https://github.com/YOUR_USERNAME/lang-publisher.git cd lang-publisher
-
Add a New Language
- Create a new directory in the
lang
folder with the ISO language code (e.g.,lang/de/
for German) - Copy the structure from an existing language folder
- Translate all files (validation.php, auth.php, pagination.php, passwords.php)
- Ensure you maintain the same array keys as the English version
- Create a new directory in the
-
Update the Service Provider
- Add your new language code to the
ensureLocaleExists
method calls inLangPublisherServiceProvider.php
- Add your new language code to the
-
Test Your Changes
- Install the package in a Laravel project
- Verify that your language files are correctly published
-
Submit a Pull Request
- Push your changes to your fork
- Submit a pull request to the main repository
- Provide a clear description of your changes
Translation Guidelines
- Maintain the same array structure and keys as the English version
- Ensure translations are grammatically correct and culturally appropriate
- Use proper character encoding for special characters
- Follow Laravel's translation conventions
Security
If you discover any security-related issues, please email mohammedilyeszakaria.bousbaa@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.