Download the PHP package grajewsky/laravel-i18n without Composer

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

I18n

Push your Laravel translations to the front-end and use them easily with JavaScript.

The JSON based translations are not supported!

Getting started

You can install the package with composer, running the composer require grajewsky/laravel-i18n command.

Laravel 5.4 and below

You have to register the service provider manually. Go to the config/app.php file and add the Grajewsky\Laravel\I18n\Providers\I18nServiceProvider::class to the providers array.

Laravel 5.5 and up

Package is auto-discover

Configuration

You can add your own i18n paths providers only what u must to do is implements Grajewsky\Laravel\I18n\Interfaces\I18nProvider

and add I18nProvider into config/i18n.php Fullnamespace\MyI18nProvider::class

Translations in view files

You can use the @translations blade directive. This directive automatically wrap the translations to a <script> tag.

You may override the default key for the translations. You can do that by passing a string to the blade directive.

Publishing and using the JavaScript library

Use the php artisan vendor:publish command and choose the Grajewsky\Laravel\I18n\Providers\I18nServiceProvider::class provider. After publishing you can find your fresh copy in the resources/assets/js/vendor folder.

Using the I18n.js

Then you can import the I18n class and assign it to the window object.

Initializing a translation instance

From this point you can initialize the translation service anywhere from your application.

By default, it uses the translations key in the window object. If you want to use the custom one you set in the blade directive, pass the same key to the constructor.

Using it as a Vue service

If you want to use it from Vue templates directly you can extend Vue with this easily.

You can call it from your template or the script part of your component like below:

Methods

The package comes with two methods on JS side. The trans() and the trans_choice().

trans()

The trans method accepts the key of the translation and the attributes what we want to replace, but it's optional.

trans_choice()

The trans_choice method determines if the translation should be pluralized or nor by the given cout. Also, it accepts the attributes we want to replace.

Let's say we have the following translation line:

Note, the plural and the singular verions are separated with the | character!

Like in Laravel, you have the ability to set ranges for the pluralization. Also, you can replace placeholders like before.

You can separate more than two choices with the | character.

Transforming replacement parameters

Like in Laravel's functionality, you can transform your parameters to upper case, or convert only the first character to capital letter. All you need to do, to modify your translations.

If you want, you can pass the same parameter with different modifiers in one line as well, like :NAME, :name or :Name.


All versions of laravel-i18n with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0|^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 grajewsky/laravel-i18n contains the following files

Loading the files please wait ....