Skip to content

Simple and powerful solution to manage your Laravel translation keys efficiently.

License

Notifications You must be signed in to change notification settings

anastalal/laravel-translation-importer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Translation Importer

Latest Version on Packagist Total Downloads

Introduction

The Laravel Translation Importer package is a simple and powerful solution to manage your Laravel application's translation keys efficiently. It scans your project for translation functions (__() and trans()) and automatically updates the translation files located in the resources/lang directory.

This package simplifies the process of maintaining translations, especially when new keys are introduced during development. It helps you avoid missing translation keys by automating the synchronization between your project and language files.

Features

  • Manual scanning: The package provides commands to scan your project for translation keys inside __() and trans() functions. You can run these commands to update your translation files as needed.
  • File generation: It generates and updates translation files in resources/lang.
  • CLI Commands: Use artisan commands to sync missing keys or update existing ones.
  • Supports Multiple Languages: The package is compatible with multi-language projects and works seamlessly across different locales.

Installation

You can install the package via composer:

composer require anastalal/laravel-translation-importer

After installing, you need to publish the configuration file using:

php artisan vendor:publish --provider="Anastalal\LaravelTranslationImporter\TranslationImporterServiceProvider"

Usage

Important Note: Before using the package, you must manually create the necessary language folders and files in the resources/lang directory. For example:

resources/lang/
 ├── en/
 │ └── messages.php
 ├── ar/ 
 │ └── messages.php
 ├── en.json
 └── ar.json

You need to ensure that directories and files for the languages that you want are in place, as the package does not generate them automatically.

Sync Missing Translation Keys

The following command scans your project files for any missing translation keys and adds them to the respective language files in the resources/lang folder:

php artisan translation-importer:sync-missing-translation-keys

Sync Translations

To ensure that all translations are up-to-date, use the sync command. This will compare existing translations and update them as needed:

php artisan translation-importer:sync-translations

Configuration

Once you’ve published the configuration, you can customize the package’s behavior by modifying the config file located at:

config/translation-importer.php

Testing

To ensure the package works as expected, you can run the following tests:

composer test

Contributing

Contributions are welcome!

License

The Laravel Translation Importer is open-sourced software licensed under the MIT license.

Acknowledgments

About

Simple and powerful solution to manage your Laravel translation keys efficiently.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages