Download the PHP package hadefication/polyglot without Composer

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

Polyglot

Polyglot creates a blade directive @polyglot that you can add to your master blade file. This will then export a global variable Polyglot where all of your app's current locale translation keys are stored. The root object keys are base from the defined translation files located in the Polyglot's configuration file.

Installation

  1. composer require hadefication/polyglot
  2. Add Hadefication\Polyglot\PolyglotServiceProvider::class to your config/app.php under the providers array. This step is not needed for version 5.5 and above where package auto-discovery is introduced.
  3. Include @polyglot blade directive to your master blade file on top of your JavaScript files -- probably in the header or before the body tag ends.

Usage

Once installed, this package will then expose a Polyglot variable where all of your current locale translation keys are stored.

A nifty JavaScript helper function will be exposed too that you can use to translate translation keys like what we're doing in Laravel. Accidentally named it trans too. See examples below for more details on trans helper function.

Example

Without param

Translations with params

Config

A configuration file is included too to customize the translation files that will be loaded to Polyglot. To publish the included config file, run php artisan vendor:publish.

Artisan Command

An artisan command is also provided where it will dump a JavaScript file that houses all collected translation keys including the importable route method helper. Upon using this approach, including the @polyglot blade directive won't be necessary.

The command above should dump a JavaScript file named polyglot.js in your /resources/assets/js directory. You can also supply --path=/path/to/where/the/dump/file/will/be/exported to dumpt the file in other location. The command should look like php artisan polyglot:dump --path=./resources/assets/js/vendor/polyglot.js.

The code above should be added to your bootstrap file or to the main JavaScript file if you have a custom entry point.

Laravel Mix

You can also automate the dumping by installing a webpack plugin that runs a simple artisan command on every build so you are sure that you got the latest translation files included in your build. Follow steps below:

  1. Install the webpack shell plugin: npm install --save-dev webpack-shell-plugin or yarn add --dev webpack-shell-plugin
  2. Include the plugin to your webpack.mix.js file:

  3. Done! This will run php artisan polyglot:dump on start of the build so you get the latest translation files.

All versions of polyglot with dependencies

PHP Build Version
Package Version
Requires laravel/framework Version ~5.5.0|~5.6.0|~5.7.0
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 hadefication/polyglot contains the following files

Loading the files please wait ....