Download the PHP package scottybo/laravel-translator without Composer

On this page you can find all versions of the php package scottybo/laravel-translator. 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-translator

Laravel-Translator for PHP and Vue

This is a forked version of Laravel-Translator (https://github.com/thiagocordeiro/laravel-translator) which adds the ability to separate generation of Vue translation files and PHP translation files. It's slightly refactored to play nicely with translated strings rather than named keys.

Follow these simple rules when adding translations

Translations in Laravel Blades

For simple strings:

{{ __("String that can be translated") }}

For strings with variables

{{ __("Hi :name, welcome to :app", ['name' => 'Scott', 'app' => 'Widgets 3000']) }}

Translations in Javascript/Vue

Translations not updating? Clear the cache! $ php artisan cache:clear

Strings used in Vue templates and Javascript code are stored in /resources/lang/_javascript/ and are handled separately from general PHP/system translations. This is to ensure the visitor only downloads translations that are used in JS, keeping file sizes small for faster downloads.

We load <script src="/js/lang-{lang}.js"></script> on every page of the system. The URL is actually a Laravel route which loads the corresponding language file (e.g. /resources/lang/_javascript/{lang}.json) and returns a json encoded string of the translations. This string is stored in the variable: window.i18n, which can then be referenced by Javascript.

During the generation of this string will tell Laravel to cache this response forever. Therefore if you ever update the translation file you need to clear the cache via php artisan cache:clear.

To keep the logic of translations consistent, we have a Vue prototype variable of __ which handles the conversion of the translations (in /resources/assets/js/app.js):

For simple strings:

{{ __("String that can be translated") }}

For strings with variables:

{{ __("Hi :name, welcome to :app", {'name': 'Scott', 'app', 'Widgets 3000'}) }}

Laravel-translator scans your project resources/view/ resources/js/ and app/ folder to find lang(...) and __(...) functions, then it create keys based on first parameter value and insert into json translation files.

Installation

You just have to require the package

This package register the provider automatically, See laravel package discover.

After composer finish it's installation, you'll be able to update your project translation keys running the following command:

if for any reason artisan can't find translator:update command, you can register the provider manually on your config/app.php file:

Usage

First you have to create your json translation files:

Keep working as you are used to, when laravel built-in translation funcion can't find given key, it'll return itself, so if you create english keys, you don't need to create an english translation

also you can use params on translation keys

Output

translator:update command will scan your code to identify new translation keys, then it'll update all json files on app/resources/lang/ folder appending this keys.


All versions of laravel-translator with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
laravel/framework Version >=5.4
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 scottybo/laravel-translator contains the following files

Loading the files please wait ....