Download the PHP package nalingia/laravel-i18n without Composer

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

An opinionated Laravel package for models internationalisation

Latest Version on Packagist Build Status Total Downloads

I18n is an opinionated package to add internationalisation to a Laravel model.

Installation

You can install the package via composer:

Laravel will discover the related service provider.

Usage

This package comes with a ready-to-use migration to enable your model to be internationalised. To create the migration run

and then

It has a minimum configuration available. You can publish using

To enable internationalisation in your models, follow these simple steps:

  1. Import Nalingia\I18n\Traits\HasI18n trait into you model.
  2. Add a public property named $catalogueAttributes: it will contains all attributes that will be translated.
  3. Add 'catalogueItems' to model's $with array when using Lavavel 5.6 or below. Starting from Laravel 5.7 imported traits can initialize everything needed when a model is booting. HasI18n can append 'catalogueItems' to $with and $hidden arrays.

Here's an set up example:

Translations management

There are several way to access property localisations but the easiest one is related to the current application locale:

You can also use this method to access a translation:

Get a catalogue item

Accessing translation for current application locale is as easy as accessing a model attribute:

If you want to access translation for a different locale, you can call translate(string $key, string $locale):

or

Retrieve all catalogue items

You can get all available catalogue items for a model by calling getCatalogueItems() without providing any argument:

Or you can use the accessor

Retrieve all available locales

You can get all available locale for which exist at least one catalogue item by calling getCatalogueLocales():

Setting a catalogue item

Setting translation for current application locale is as easy as setting a model's property:

If you want to translate in locales different to the application one you can call setCatalogueItem(string $key, string $locale, $value):

Remove a catalotue item

You can delete a translation for a specific field:

Or, you can delete all translation for a locale:

Creating models

You can set catalogue items when creating new model

or you can set only catalogue items that match the current application locale by setting the attribute value without providing any locale key. For example:

is the same as

Change log

Please, see CHANGELOG for more information about what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Testing

You can run the tests with:

or

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-i18n with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2
laravel/framework Version ~5.8.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 nalingia/laravel-i18n contains the following files

Loading the files please wait ....