Download the PHP package anahkiasen/polyglot without Composer

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

Build Status Latest Stable Version Total Downloads Scrutinizer Quality Score Code Coverage

Introduction

Polyglot is a localization helper for the Laravel framework, it's an helper class to localize your routes, models and views.

To install it, do composer require anahkiasen/polyglot:dev-master, then add Polyglot\PolyglotServiceProvider to the providers array in app/config/app.php.

Publish config to your laravel app : php artisan config:publish anahkiasen/polyglot

Model localization

Setting a model as polyglot will allow you to make fields speak several languages. Polyglot requires you to separate common fields from localized ones assuming the following common pattern :

Take the example of a blog article model

TABLE articles
  id INT
  category_id INT
  created_at DATETIME
  updated_at DATETIME

TABLE article_langs
  id INT
  title VARCHAR
  content TEXT
  article_id INT
  lang ENUM

From there you can either access any language easily by doing the following : $article->fr->title. Or you can add the following parameter to your model and let Polyglot automatically translate attributes.

Polyglot also helps you saving localized attributes :

Globally speaking when Polyglot sees you're trying to save localized attribute on the parent model, it will automatically fetch the Lang model and save them on it instead. If no lang attribute is passed, Polyglot will use the current language.

Note that, as your attributes are now split into two tables, you can Polyglot eager load the correct Lang relation with the withLang method. Per example Article::withLang()->get() will return Articles with fr autoloaded if it's the current language, or en, according to app.locale.

Routes localization

To localize your routes, you need to set the locales option in your config file, per example array('fr', 'en'). Now you may define your routes as such :

Now you can access /fr and /fr/articles, or /en and /en/articles – Polyglot will recognize the locale in the URL and automatically set your app in that language. There is also a default option in the config file, setting that option to a locale like 'default' => 'fr' will make the root URLs point to that locale. So accessing /articles without prefixing it with a locale would render the page in french.

Views localization

Views localization work by setting up gettext for you and providing two commands to extract translations from your views to PO files and compile those to MO files.

This is currently only possible for Twig but will soon for Blade and classic PHP files, and will require the twig/extensions package which adds gettext support for Twig.

To use simply configure your domain in the configuration, then run php artisan lang:extract.

Locales helpers

Polyglot also provide various locale helpers hooked into the Lang and URL class you know and love :


All versions of polyglot with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/container Version ~4.2
illuminate/support Version ~4.2
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 anahkiasen/polyglot contains the following files

Loading the files please wait ....