Coder Social home page Coder Social logo

zashme / laravel-translations-db Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hpolthof/laravel-translations-db

1.0 0.0 0.0 65 KB

Laravel Translations from Database

Home Page: https://packagist.org/packages/hpolthof/laravel-translations-db

License: GNU General Public License v2.0

PHP 100.00%

laravel-translations-db's Introduction

Localization from a database

This package was created, as an in-place replacement for the default TranslationServiceProvider and mend for everyone who got tired of collecting translations in language files and maintaining dozens of arrays, filled with lots and lots of keys. Keys will be added to the database automatically, so no more hussling with adding your keys to the translations file. You'll never forget to translate a key anymore! In production your keys will be cached to ensure the localization stays fast!

Installation

Require this package with composer:

composer require zash/laravel-translation-db

Like to live on the edge? Use: composer require 'zash/laravel-translations-db:*@dev'

After updating composer, we'll have to replace the TranslationServiceProvider the our ServiceProvider in config/app.php.

Find:

'Illuminate\Translation\TranslationServiceProvider',

and Replace this with:

'Zash\Translation\ServiceProvider',

The ServiceProvider will now be loaded. To use this package properly you'll also need the create a table in your database, this can be achieved by publishing the config and migration of this package.

Run the following command:

php artisan vendor:publish --provider='Zash\Translation\ServiceProvider'

and afterwards run your migrations:

php artisan migrate

And that's all there is to it!

Usage

You can just start using translations as you would normaly do with the Laravels default package. The functions trans() and Lang::get() can be used as you normaly would.

For more information about Localization and the usage of these functions, please refer to the Documentation on the mather.

Files are still possible

The usage of translation files is however still possible. Every translation prefixed by a namespace is parsed through the old TranslationServiceProvider. This is needed for external packages that come with there own translation files. But in general you shouldn't be bothered by this.

Importing and exporting

To ease the proces of migrating to translations in the database, two commands are available since version 0.3.

Import

To import all translations out of your current language files, you can use the command:

php artisan translation:fetch

This will import all available translations in language files into the database.

To import just some specifics you can also make use of the options --locale and --group.

Export

To dump the translations from your database back to your filesystem, use:

php artisan translation:dump

The options --locale and --group are also available for this command. Caution: all current files will be overwritten, so use with care!

laravel-translations-db's People

Contributors

hpolthof avatar alexandru-fiodorov avatar

Stargazers

 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.