Download the PHP package mosab/translation without Composer

On this page you can find all versions of the php package mosab/translation. 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 translation

Translation Package

This package allows you to manage models and his translations in database.

Installation

  1. This package can be used with Laravel 8.0 or higher. you can install the package via composer:

  2. Optional: The service provider will automatically get registered. Or you may manually add the service provider in your config/app.php file:

  3. You should publish the migrations and seeder files:
  1. Run the migrations: After the migration have been published, you can create the tables for this package by running:

  2. Run the seeder

Automatically after executing seeding, your project will support Arabic and English languages. But, if you want to add a new language, you have to add this language in the following way:

Note:. you can manage Languages or modify it by dealing with translations_languages table directly.

  1. list the middleware class in the $middleware property of your app/Http/Kernel.php class:

Usage Instructions

Set Up Translatable Model Class

  1. After determine the tables that you want to translate some column of them, modify the model for this table by inheriting TranslatableModel, like this:

  2. Add new protected variable called translatable, and the type of this variable must be array. You should add the columns you want to translate from this model in the translatable variable. for example:

Note:. you should not add the columns you want to translate in migration files. just add the another columns that have no translation. for example:

As the translatable columns are automatically stored at the translations table in database.

Inserting Translatable Models

When you need to insert new records, you should instantiate a new model instance and set attributes on the model. Then, call the save method on the model instance. Note that When you adding translation for a specific column, you must assign the value as:

You may use the create method to "save" a new model, like this:

If you want to add validate for request you can use function called translation_rule(), this method forces the user to enter the value with its translations in all languages ​​supported in the system. for example:

Updating Translatable Models

The save method may also be used to update models that already exist in the database. To update a model, you should retrieve it and set any attributes you wish to update. Then, you should call the model's save method. When you update any translatable column, the old translation value delete from translations table and insert the new translation value in this table. for example:

You may use the update method to "update" a model, like this:

Deleting Translatable Models

To delete a model, you may call the delete method on the model instance: When you delete a model, his translations are automatically deleted from the translation table.

Retrieving Translatable Models

When you need to retrieve a model, you can do it by this way:

Then the model and his translation returned in this way:

In this package you can specify which language you want to return the translatable columns in, by sending the language code you want in the headers, like this:

By default if you don't send the accept-language header it will take English as the default language. All This is provided by RequestLanguage middleware.


All versions of translation with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
illuminate/support Version >=5.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 mosab/translation contains the following files

Loading the files please wait ....