Git Product home page Git Product logo

laravel-translate-spreadsheet's Introduction

Translate Spreadsheet

Latest Version on Packagist Total Downloads

This package serves the purpose of translating the contents within the spreadsheet file. It facilitates the transition from the original language to your preferred language

Installation

You can install the package via composer:

composer require shishima/laravel-translate-spreadsheet

Publish config

php artisan vendor:publish --provider="Shishima\TranslateSpreadsheet\TranslateSpreadsheetServiceProvider"

After publishing the configuration file, you can edit the app/config/translate-spreadsheet.php file to customize the settings.

Usage

translate

The file can be a path to a file on the system

use Shishima\TranslateSpreadsheet\Facades\TranslateSpreadsheet;

$fileInput = public_path('demo.xlsx');
TranslateSpreadsheet::translate($fileInput);

Or it could be a file retrieved from the request when using the POST method in a form submit with <input type="file">.

TranslateSpreadsheet::translate($request->file('file'));

setTransTarget

To set the desired translation language target

TranslateSpreadsheet::setTransTarget('en')->translate($file);

setTransSource

To set the desired translation language source

TranslateSpreadsheet::setTransSource('en')->translate($file);

IMPORTANT! Pass in null if you want to use language detection

setShouldRemoveSheet

Clear the current sheets after translation is complete. The parameter passed to the method is true/false.

TranslateSpreadsheet::setShouldRemoveSheet(true)->translate($file);

setOutputDir

Directory to store files after translation

TranslateSpreadsheet::setOutputDir('translate/')->translate($file);

IMPORTANT! The file will be stored in the public directory, not in the storage directory.

setCloneSheetPosition

Position of the cloned sheets

The parameter passed in is enum ClonePosition. You can refer to it in the file Enumerations/ClonePosition.php for more detail.

use Shishima\TranslateSpreadsheet\Enumerations\ClonePosition;

TranslateSpreadsheet::setCloneSheetPosition(ClonePosition::AppendLastSheet)->translate($file);

highlightSheet

Sheets will be highlighted after export

TranslateSpreadsheet::highlightSheet(true)->translate($file);

translateSheetName

Sheets Name will be translated after export

TranslateSpreadsheet::translateSheetName(true)->translate($file);

enableDebug

For logging translated sentences into a log file for debugging purposes

TranslateSpreadsheet::enableDebug()->translate($file);

To disable this feature, pass false as the argument.

Translate Engine

The package supports two translation engines: Google Translate and Gemini

It can be installed through the translate_engine setting in the config file

Alternatively, you can use the setTranslateEngine function. The parameter to be passed is an Enum TranslateEngine, which can be either TranslateEngine::Gemini or TranslateEngine::Google

use Shishima\TranslateSpreadsheet\Enumerations\TranslateEngine;

TranslateSpreadsheet::setTranslateEngine(TranslateEngine::Gemini)->translate($file);

Google Translate

No need for setting

Gemini

This functionality has been developed from google-gemini-php/laravel library

Therefore, please install this package before use

Testing

composer test

Demo

Utilize the repository below as a reference for how to use it.

https://github.com/shishima123/laravel-translate-spreadsheet-demo

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

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

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

Special Thanks

laravel-translate-spreadsheet's People

Contributors

shishima123 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.