Download the PHP package keasy9/laravel-localize without Composer

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

Laravel-localize - little but usefull package for localisation.

Installation:

Usage:

Adding uri-prefix:

At first you need to add available locales in config/localize.php. By default here is two locales:

'available_locales' => [
    'ru' => 'русский',
    'en' => 'english',
],

And add prefix for your app's routes:

namespace App\Providers;

use Keasy9\Localize\Facades\Localize;

class RouteServiceProvider extends ServiceProvider
{

    public function boot(): void
    {

        $this->routes(function () {
            //...

            Route::middleware('web')
                ->prefix(Localize::getLocalePrefix()) //prefix
                ->group(base_path('routes/web.php'));
        });
    }
}

Or in routes/web.php:

use Illuminate\Support\Facades\Route;
use Keasy9\Localize\Facades\Localize;

Route::prefix(Localize::getLocalePrefix())->group(function() {
    //...
});

Localize model fields:

Firstly you need run command that creates table "translations" in your DB. Secondly all models that need translation must use trait and have property:

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Keasy9\Localize\Traits\HasTranslations;

class Post extends Model
{
    use HasTranslations;

    // the array must include all fields that can be translated
    public static array $translated = [
        'title',
        'text',
    ];

}

so when you try to get a model attribute you will get a translated version of it:

{{ $post->title }} {{-- will returns title translated to current app locale --}}

Also you can translate all attributes:

$post->translate();

but be carefully. If you save translated model, fields in your database will be translated:

use App/Models/Post;

$post->translate()->save();
dd(Post->find($post->id)->title); //will dump translated title

Translate all attributes for all models in collection:

$posts->translate();

Web-interface for editing lang/**.json files and localize models:

This package also provides a simple web interface at http(s)://yourSiteRoot/localize/. But if you need to change this URI, you can do it through the configuration in config/localize.php:

'uri' => 'localize',

You can also specify a middleware to access that URL or remove it to open access to all users:

'access' => ['web','auth'],

All models added to the configuration will be available for translation via the web interface:

'translated_models' => [
    Post::class
],

And you can exclude default locale from editing also in config:

'default_locale' => 'en',
'translate_default_locale' => false,

Now it's time for you to create an amazing web application!


All versions of laravel-localize with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3 || ^8.0
laravel/framework Version >=8.0
keasy9/laravel-composite-pk Version ^1.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 keasy9/laravel-localize contains the following files

Loading the files please wait ....