All Projects → LaravelArab → tarjama

LaravelArab / tarjama

Licence: MIT license
This package allows you to translate your models fields. `2.0` version will be continued here: https://github.com/fevrok/laravel-translatable

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to tarjama

deepl-api-connector
Connector library for deepl.com rest translation api
Stars: ✭ 12 (+500%)
Mutual labels:  translations, translator, translation
Laravel Translatable
It's a Laravel database translations manager
Stars: ✭ 47 (+2250%)
Mutual labels:  translations, translation, laravel-package
Django Translations
Django model translation for perfectionists with deadlines.
Stars: ✭ 109 (+5350%)
Mutual labels:  translations, translation
Talkr
Talkr is a super small i18n provider for React applications. It supports Typescript, has 0 dependencies, and is very easy to use.
Stars: ✭ 129 (+6350%)
Mutual labels:  translations, translation
Deep Translator
A flexible free and unlimited python tool to translate between different languages in a simple way using multiple translators.
Stars: ✭ 233 (+11550%)
Mutual labels:  translations, translation
Developing Ios 11 Apps With Swift
Stanford 公开课,Developing iOS 11 Apps with Swift 字幕翻译
Stars: ✭ 1,237 (+61750%)
Mutual labels:  translations, translation
Cyrillic To Translit Js
Ultra-lightweight JavaScript library for converting Cyrillic symbols to Translit and vice versa
Stars: ✭ 91 (+4450%)
Mutual labels:  translations, translation
Normit
Translations with speech synthesis in your terminal as a node package
Stars: ✭ 219 (+10850%)
Mutual labels:  translations, translation
Developing Ios 10 Apps With Swift
Stanford 公开课,Developing iOS 10 Apps with Swift 字幕翻译
Stars: ✭ 391 (+19450%)
Mutual labels:  translations, translation
deepl-php-lib
🧠 DeepL API Client Library supporting PHP >= 7.3
Stars: ✭ 50 (+2400%)
Mutual labels:  translations, translator
laravel-startkit
Laravel Admin Dashboard, Admin Template with Frontend Template, for scalable Laravel projects. It is to save your time when You start with new scalable Laravel projects with many features Bootstrap, cooreui, infyom admin Generator, roles and permissions, translatable models, spatie media and much more
Stars: ✭ 55 (+2650%)
Mutual labels:  laravel-package, translatable
EverTranslator
Translate text anytime and everywhere, even you are gaming!
Stars: ✭ 59 (+2850%)
Mutual labels:  translator, translation
Translations
🐼 Chinese translations for classic IT resources
Stars: ✭ 6,074 (+303600%)
Mutual labels:  translations, translation
Eslint Plugin I18n Json
Fully extendable eslint plugin for JSON i18n translation files.
Stars: ✭ 101 (+4950%)
Mutual labels:  translations, translation
Termit
Translations with speech synthesis in your terminal as a ruby gem
Stars: ✭ 505 (+25150%)
Mutual labels:  translations, translation
Laravel Auto Translate
Automatically translate your language files using a translator service
Stars: ✭ 153 (+7550%)
Mutual labels:  translations, laravel-package
pomodoro-tracker-locales
Language files
Stars: ✭ 23 (+1050%)
Mutual labels:  translations, translation
Mojito
An automation platform that enables continuous localization.
Stars: ✭ 256 (+12700%)
Mutual labels:  translations, translation
yii2-translatable
Translatable behavior aggregates logic of linking translations to the primary model
Stars: ✭ 15 (+650%)
Mutual labels:  translations, translatable
lost-in-translation
Uncover missing translations and localization strings in Laravel applications.
Stars: ✭ 32 (+1500%)
Mutual labels:  translation, laravel-package

tarjama

It's a Laravel model columns translation manager

Current working model

Laravel Tarjama current working model

Installation

You can install the package via composer:

composer require laravelarab/tarjama

If you have Laravel 5.5 and up The package will automatically register itself.

else you have to add the service provider to app/config/app.php

LaravelArab\Tarjama\TarjamaServiceProvider::class,

If you want to change the default locale, you must publish the config file:

php artisan vendor:publish --provider="LaravelArab\Tarjama\TarjamaServiceProvider"

This is the contents of the published file:

return [

   /**
    * Default Locale || Root columns locale
    * We will use this locale if config('app.locale') translation not exist
    */
   'locale' => 'en',

   /**
    * Supported Locales e.g: ['en', 'fr', 'ar']
    */
   'locales' => ['ar', 'en', 'fr']

];

next migrate translations table

php artisan migrate

Making a model translatable

The required steps to make a model translatable are:

  • Just use the LaravelArab\Tarjama\Translatable trait.

Here's an example of a prepared model:

use Illuminate\Database\Eloquent\Model;
use LaravelArab\Tarjama\Translatable;

class Item extends Model
{
    use Translatable;

    /**
      * The attributes that are Translatable.
      *
      * @var array
      */
    protected $translatable = [
        'name', 'color'
    ];
}

Available methods

Saving translations

$item = new Item;
$data = array('en' => 'car', 'ar' => 'سيارة');

$item->setTranslations('name', $data); // setTranslations($attribute, array $translations, $save = false)

// or save one translation
$item->setTranslation('name', 'en', 'car', true); // setTranslation($attribute, $locale, $value, $save = false)

// or just do
$item->name = 'car'; // note: this will save automaticaly unless it's the default locale

// This will save if (current locale == default locale OR $save = false)
$item->save();

Get translations

$item = new Item::first();
// get current locale translation
$item->city
OR
$item->getTranslation('city');

// pass translation locales
$item->getTranslation('city', 'ar'); // getTranslation($attribute, $language = null, $fallback = true)
$item->getTranslationsOf('name', ['ar', 'en']); // getTranslationsOf($attribute, array $languages = null, $fallback = true)

Delete translations

$item = new Item::first();
$item->deleteTranslations(['name', 'color'], ['ar', 'en']); // deleteTranslations(array $attributes, $locales = null)

Maintainers


Abdellah Chadidi
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].