Giter VIP home page Giter VIP logo

laravel-translatable's Introduction

Introduction

Total Downloads CircleCI StyleCI ScrutinizerCI Code Climate Code Coverage Latest Version MIT License GitBook Open Collective

Laravel Translatable

If you want to store translations of your models into the database, this package is for you.

This is a Laravel package for translatable models. Its goal is to remove the complexity in retrieving and storing multilingual model instances. With this package you write less code, as the translations are being fetched/saved when you fetch/save your instance.

The full documentation can be found at GitBook.

Quick Example

Getting translated attributes

$post = Post::first();
echo $post->translate('en')->title; // My first post

App::setLocale('en');
echo $post->title; // My first post

App::setLocale('de');
echo $post->title; // Mein erster Post

Saving translated attributes

$post = Post::first();
echo $post->translate('en')->title; // My first post

$post->translate('en')->title = 'My cool post';
$post->save();

$post = Post::first();
echo $post->translate('en')->title; // My cool post

Filling multiple translations

$data = [
  'author' => 'Gummibeer',
  'en' => ['title' => 'My first post'],
  'fr' => ['title' => 'Mon premier post'],
];
$post = Post::create($data);

echo $post->translate('fr')->title; // Mon premier post

Tutorials

Versions

Package Laravel PHP
v11.3 5.6.* / 5.7.* / 5.8.* >=7.1.3
v11.2 5.6.* / 5.7.* / 5.8.* >=7.1.3
v11.1 5.6.* / 5.7.* / 5.8.* >=7.1.3
v11.0 5.6.* / 5.7.* / 5.8.* >=7.1.3

laravel-translatable's People

Contributors

actuallymab avatar ahmed-aliraqi avatar alfhen avatar askello avatar ben-nsng avatar deargonaut avatar derekmd avatar dimsav avatar easteregg avatar flyos avatar frozire avatar gummibeer avatar hyleeh avatar johannesschobel avatar lan0 avatar lloople avatar luc-k avatar netdown avatar nsaumini avatar nwidart avatar plmarcelo avatar raphaelsaunier avatar saidbakr avatar sdebacker avatar sebastiandedeyne avatar shadowalker89 avatar sjorso avatar tintamarre avatar unitedworx avatar yakidahan avatar

Watchers

 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.