Download the PHP package mike-zange/laravel-database-translation without Composer

On this page you can find all versions of the php package mike-zange/laravel-database-translation. 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-database-translation

StyleCI Scrutinizer Code Quality Build Status

Laravel Database Translations

For Laravel <= 5.4 use version 0.2.x

For Laravel >= 5.5 use version 1.x

Description

This package extends the functionality of spatie/laravel-translatable and will allow you to manage your translation strings in the database while using the file based translations as a fallback.

The fallback priority is as follows:

Database current locale -> Database fallback locale -> File system current locale -> File system fallback locale

This is intentional as this package is meant to be a replacement for the file based language strings

Usage

You can use the Laravel trans('group.key') or __('group.key') helpers to display your translations.

The blade @lang('key') directive also behaves the same way.

Namespacing works the same as before too

In a Service Provider app('translator')->addNamespace('namespace', 'path/to/namespaced/folder/lang');

and trans('namespace::group.key'), __('namepace::group.key') or @lang('namepace::group.key') to display

By default the translations are cached for 1 day with the key {$locale}.{$namespace}.{$group}, caching can be disabled in the config file.

The cache for a translation group is refreshed when one of the lines is updated via the translation repository.

Importing translation files

To load your current translation files in to the database run php artisan trans-db:load {locale} where {locale} is a language code

For example php artisan trans-db:load en will load all the files for 'en' and php artisan trans-db:load es will load all the files for 'es'

Note: this is a catch all function and will include any files in language namespaces you have added to your service providers as well as any in resources/lang

Adding more translation keys

The included utility command php artisan trans-db:load is non-destructive so add your new key to the appropriate translation file and run the command again, your new key will appear in the database whilst preserving your modified translations

Working with translations

Add: use MikeZange\LaravelDatabaseTranslation\Repositories\TranslationRepository; and inject it into your __construct() or method.

  1. To retrieve all of the translations from the database: $translationRepository->all($related = [], $perPage)

  2. Get a group of keys by namespace and group: $translationRepository->getItems($namespace, $group)

  3. Get a specific key $translationRepository->getItem($namespace, $group, $key)

There are 2 included methods for updating translations via the translations repository.

  1. $translationRepository->updateTranslationById($id, $locale, $value, $overwrite)

  2. $translationRepository->updateTranslation(Translation $line, $locale, $value, $overwrite)

The second method requires an instance of the translation model.

The optional 4th parameter controls whether the new translation will overwrite the old one if it exists, default is true

Requirements

Installation

  1. As always: back up your database - I am not responsible for any data loss

  2. Install the package via Composer:

    composer require mike-zange/laravel-database-translation

  3. Comment the following Service Provider in config/app.php:

    Illuminate\Translation\TranslationServiceProvider::class,

    The new service provider is auto-loaded in laravel 5.5

  4. Publish the configuration file database.translations.php

    php artisan vendor:publish --provider="MikeZange\LaravelDatabaseTranslation\TranslationServiceProvider"

  5. Make sure you have a locale set either via app()->setLocale() or in config/app.php

  6. Edit the config at config/database.translations.php to your requirements, the defaults should be okay for most uses

  7. Run php artisan migrate to create the database table

To Do


All versions of laravel-database-translation with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
laravel/framework Version ~5.5
spatie/laravel-translatable Version ^2.1
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 mike-zange/laravel-database-translation contains the following files

Loading the files please wait ....