Download the PHP package marksitko/laravel-deep-translatable without Composer

On this page you can find all versions of the php package marksitko/laravel-deep-translatable. 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-deep-translatable

Automatic translatables Eloquent models with DeepL

Latest Version on Packagist Total Downloads

Laravel-Deep-Translatable is more than just an API Wrapper for DeepL. It contains a trait to make Eloquent models automatic translatable. So you can easily publish a Blog post (or whatever) and create multiple language versions of it quite automatically. If you need to adjust or refine the translation, just got for it by using the provided updateTranslation method.

Installation

Install the package via composer:

Laravel-Deep-Translatable comes with package discovery and Laravel will register the service provider automatically. Just in case you wanna add it manually, you should provide it in config/app.php

Service provider

Next you should publish the configuration and migration.

Run migrations

Configuration

You have at least to provide a DeepL API key in your .env file. Read how to accessing the DeepL API

Optional configurations:

Usage

First implement the Translatable Interface, add the UseDeepTranslations Trait and define your translatable keys.

Translate and persist Call translateViaDictionary() method on your model with your target language.

Translate without persisting

Retrieve all translations form a model

Update/Refine a translation To refine an existing Eloquent translation, call updateTranslation() method. It accepts three parameters.

  1. The key to refined.
  2. The target language to refined
  3. The refined translated string

Just use the API Client without Eloquent models

The third param in the translate method is an optional $options array. Here you can define a specific source language or additional query options.

Translate value from stored json object If you'r model has a json column which stored a value which you would like to translate, you can define the path with dot notaions in the $translatable property.

How it works

If you call translateViaDictionary() on your Eloquent model, each translation is stored in a special translation_dictionaries table. The source text is stored as a key and each translation is stored as a json with the specified target language code. This concept was implemented to avoid requests for already translated strings.

For each translation call, the translation_dictionaries table is first checked to see if a translation already exists for the specified target language. If a translation exists it will be returned from the database, if not it will be retrieved from DeepL. You can also use this method to keep your own dictionary for specific words.

Push translation calls to the queue

By default the translateViaDictionary() method is executed synchronously. For one model or simple strings this is fine, but if you plan to perform bulk translations it is recommended to use the queue for translate and persisting models.

Switch between translations

To swap translatables keys on your model, you just need to call your site with an additional query parameter which defines your target language code.

For example: If your default site for a particular post would be: https://yousite.test/posts/1 then call it up for the german translation as follows: https://yousite.test/posts/1?lang=de

License

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

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.


All versions of laravel-deep-translatable with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0|^8.1
illuminate/support Version ^9.0
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 marksitko/laravel-deep-translatable contains the following files

Loading the files please wait ....