Giter Site home page Giter Site logo

laravel-translate's Introduction

Laravel Translate

Build Code Quality Coverage

Easily translate your laravel application using cloud translation APIs. This package finds all of your __() and trans() methods in your app/ and resources/ directories and translates each string using the API. Online translation APIs aren't perfect however, so its recommended that this package is used to give you a good starting point. Packages such as barryvdh/laravel-translation-manager and joedixon/laravel-translation can then be used to fine-tune your translations.

Installing

Installation is achieved using composer

composer require --dev itsmattburgess/laravel-translate

Configuration

You can configure how this package is implemented using the config file in config/translate.php. You first need to publish this config file using the command below:

php artisan vendor:publish --provider="itsmattburgess\LaravelTranslate\TranslationServiceProvider"

In this config file, you can specify the methods that contain your translation strings, the path where your methods should be discovered in, and which languages you want to translate into.

The package currently only supports the Google Translate API.

To use the Google Translate API you need to set your API key. You can obtain an API key from your Google Cloud Console. Once generated, add your key to your .env file.

GOOGLE_TRANSLATE_API_KEY=XXXXXX

Usage

Once you have set your API key and set the languages you want to translate into, you're ready start processing. Run the following command to start processing. It will detect your translation methods and create the language files in resources/lang/. If you already have these files defined, it will override any matching keys with an updated translation.

php artisan translate

Pricing warning

Online translation providers, such as Google, charge for usage of their APIs. Check their pricing carefully, you are responsible for any charges incurred.

Contributing

Contributions are welcome. If you've spotted a bug, would like to add a new feature or implement a new service, please submit a pull request with associated test coverage. I'll review any pull requests as quickly as I can.

laravel-translate's People

Contributors

dependabot[bot] avatar mtburge avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.