Giter Site home page Giter Site logo

translation's Introduction

Laravel Translation

A simple GUI for Laravel Translation.

This package will allows you to take control of lang files in Laravel infrastructre . it will also allows you to translate user inputs (models or database columns data)

Installation

So simple just run composer require motwreen/translation in your application terminal.

Publish

If you'd like to edit package views run php artisan vendor:publish --tag=motwreen-translation in your terminal and you'll find it in this path : resources/views/vendor/translation.

Migrate

To migrate database tables run php artisan migrate

Using GUI

  • after installation you can access translation gui with http://app-url.dev/translation.
  • create your languages and translate them.
  • you can use (.) dot syntax to defind multidimensional array in lang file like this in key field:
level1.level2.level3.level4.etc

which will produce this result in lang file

'level1' => [
        'level2' => [
            'level3' => [
                'level4' => 'etc',
            ],
        ],
    ],

Database translation

  • To start using database translations in your models use this trait Motwreen\Translation\Traits\TranslatableTrait.
  • define a protected $translatable array in your model class like this :
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Motwreen\Translation\Traits\TranslatableTrait;

class Category extends Model
{
    use TranslatableTrait;

    protected $translatable = ['name'];
}

And in your controller :

public function store(Request $request){
    $category = new App\Category;
    $category->name => ['en'=>'Test Name','du'=>'Miene name ist Test'];
    $category->description => ['en'=>'Test Description','du'=>'Miene name ist Description'];
    $category->save();
}

translation's People

Contributors

theahmedgad avatar

Watchers

James Cloos 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.