Download the PHP package mindtwo/laravel-translatable without Composer

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

Laravel Translatable Package

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Overview

The mindtwo/laravel-translatable package provides a simple and effective way to manage multilingual models in a Laravel application. It allows you to easily translate Eloquent model attributes into multiple languages without the need for separate tables for each language.

Features

Installation

To install the package, run the following command in your Laravel project:

You can publish and run the migrations with:

You can publish the config file with:

This is the contents of the published config file:

Quick Start

1. Create a Translatable Model

2. Add Translations

3. Automatic Translation Override

Advanced Usage

Query Scope Methods

All scope methods support IDE autocomplete and have full parameter type hints:

Locale Resolution

By default, the package uses Laravel's built-in locale configuration:

Custom Locale Resolution

You can customize locale resolution by extending the LocaleResolver:

Then register it in your config/translatable.php:

Or set locales dynamically:

Working with Translation Data

Performance Features

Configuration Examples

E-commerce Setup

Multi-Region Content

API Reference

Instance Methods

Method Description Parameters
setTranslation($key, $value, $locale) Set translation for a field string $key, string $value, ?string $locale
setTranslations($translations, $locale) Set multiple translations at once array $translations, ?string $locale
getTranslation($key, $locales) Get translated text with fallback string $key, string\|array\|null $locales
getTranslations($key, $locales) Get translations as array string $key, string\|array\|null $locales
getAllTranslations($key) Get all translations for a key string $key
hasTranslation($key, $locale) Check if translation exists string $key, ?string $locale
getUntranslated($key) Get original table value string $key
translations() Get translations relationship -

Query Scope Methods (Static)

Method Description Parameters
withTranslations($locales) Eager load translations ?array $locales
searchByTranslation($key, $search, $locales, $operator) Search in translations string\|array $key, string $search, string\|array\|null $locales, string $operator
searchByTranslationExact($key, $search, $locales) Exact match search string\|array $key, string $search, string\|array\|null $locales
searchByTranslationStartsWith($key, $search, $locales) Prefix search string\|array $key, string $search, string\|array\|null $locales
searchByTranslationEndsWith($key, $search, $locales) Suffix search string\|array $key, string $search, string\|array\|null $locales
whereHasTranslation($key, $locales) Filter models with translation string $key, string\|array\|null $locales
whereTranslation($key, $value, $locales, $operator) Filter by translation value string $key, string $value, string\|array\|null $locales, string $operator
orderByTranslation($key, $direction) Order by translated field string $key, string $direction

Required Configuration

Models using HasTranslations must define translatable fields:

Optional Configuration

IDE Support

The package includes comprehensive PHPDoc annotations for full IDE support:

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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


All versions of laravel-translatable with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2||^8.3||^8.4||^8.5
illuminate/contracts Version ^10.18||^11.0||^12.0||^13.0
illuminate/database Version ^10.18||^11.0||^12.0||^13.0
mindtwo/laravel-auto-create-uuid Version ^2.6
spatie/laravel-package-tools Version ^1.14.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 mindtwo/laravel-translatable contains the following files

Loading the files please wait ...