Download the PHP package mishalestev/laravel-files-translator without Composer

On this page you can find all versions of the php package mishalestev/laravel-files-translator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-files-translator

Laravel Files Translator

Files Translator for Laravel - is a package designed to streamline the process of extracting and translating text content from Blade or HTML files in your Laravel applications.


Installation

Run the following command in your Laravel project directory:


If you're unsure how this package works, please watch our short introductory video:

Under 10 minutes https://youtu.be/IsiUgIftRiw


Example Use Case

Suppose you have a file with the following text (that is the 4th commandement):

To translate this content into Spanish, run the following command:

This command will:

  1. Generate a Translated Blade File:
    It creates a new Blade file with the text replaced by __() translation calls. This file uses unique keys mapped to text segments, due to maintenance considerations.

  2. Produce Corresponding Translation Files:
    It generates translation files within your lang/ directory. You get both the source language and the target language files populated with key-value pairs, mapping each text snippet to its translation.

Resulting Files

Translated Blade File:

_resources/views/commandment_translated.blade.php_

Translation Files:

lang/es/commandement.php

lang/en/commandement.php

Process In More Details

  1. It Generates a Translated File:
    After processing your specified input file (Blade or HTML), the package produces a new, translated file (_translated.blade.php) in the same directory. This file has all the original plain text replaced by their translated equivalents.

  2. Creates Corresponding Translation Files:
    The package will generate language directories under lang/ for both the source language and the target language(s). Inside these directories, it will create translation files to store your translations. For example:

Example Usage

  1. Create a New Laravel Project (if needed):
    If you don't already have a Laravel project, create one using the following command:

  2. Run the Translation Command:
    Use the Artisan command provided by the package to process and translate your Blade or HTML files.
    For example:

    • Replace es with the desired target language code.
    • Specify the input file path and the output translation file path as required.
  3. Update Application Locale (Optional):
    Open config/app.php and modify the locale configuration as follows:

  4. Serve Your Application:
    Run the Laravel development server to test the changes:

    Open your application in a browser to see the translations in action.


Artisan Command Signature

The package provides a customizable Artisan command:


Future Objectives & Roadmap

As we continue to develop and enhance the Laravel Files Translator package, here are several objectives and enhancements we plan to implement:

  1. Preserving Blade Directives:
    Currently, the package removes all Blade directives. We aim to support the preservation of these directives in future releases, eliminating the need to manually re-insert them.

[!NOTE]

  1. ~File Replacement or New File Creation~ (Implemented)
    We plan to introduce an option to replace the original file, akin to using a --force flag in Git. This feature will complement the existing functionality that creates a new file with a _translated.blade.php suffix.
  1. Custom Output Directories:
    Future versions may include a feature to specify a custom output directory (e.g., built/) for storing compiled files, translations, and Blade templates post-translation. This will let developers manually distribute files within a project (if applicable).

  2. Route-Based Language Switcher:
    We're considering the addition of a feature to automatically set up a language switcher in routes/web.php, which will allow for quick testing and demonstration of different localizations.

  3. JSON Translation Support:
    In addition to the default PHP array files, we plan to support the generation of JSON-based translation files, providing more flexibility in how translations are stored and used.

  4. Whitespace & Formatting Preservation:
    Currently logic for handling spacing and indentation, particularly for nested elements, is needed. It has to retain space formatting of the translated files.

  5. Multiple Languages Support:
    Builed a multiple language support (e.g., --lang=en,es,fr) in a single command, generating multiple sets of translated files simultaneously.

  6. Shortening Translation Keys:
    We are looking for options to shorten the keys generated for translation entries, currently based on an MD5 algorithm, to make them more manageable.

  7. Handling Non-Native HTML Tags:
    Plans include developing methods to recognize and correctly handle non-native HTML tags, which are currently not supported.

  8. Duplicate Text Optimization:
    If the text is the same across the file, the system should reuse existing keys instead of generating new ones.

  9. Community-Driven Features:
    We actively encourage the community to contribute ideas and improvements. Please submit issues or pull requests on GitHub for any features you'd like to see incorporated or enhanced.

Your feedback and contributions help us make this tool better for everyone.

For More Information

If you have any questions or need support, feel free to reach out via email:
[email protected]


Credits

This project is built using the following open-source projects:

Thanks for their outstanding work.


To Support

The greatest support you may offer is to read this book.

Whether you read it or not is your choise, and I respect it.


All versions of laravel-files-translator with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
stichoza/google-translate-php Version ^4.0
laravel/framework Version ^8.0 || ^9.0 || ^10.0 || ^11.0
stillat/blade-parser Version ^1.10
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mishalestev/laravel-files-translator contains the following files

Loading the files please wait ....