Looking to hire Laravel developers? Try LaraJobs

laravel-i18n-strings-batch maintained by yaroslawww

Description
Simple way to transfer strings to js component without load all lang files or additional ajax requests.
Last update
2023/11/24 14:08 (dev-master)
License
Downloads
61
Tags

Comments
comments powered by Disqus

i18n strings batch

Packagist License Packagist Version Total Downloads Build Status Code Coverage Scrutinizer Code Quality

Installation

Install the package via composer:

composer require yaroslawww/laravel-i18n-strings-batch

Usage

Set specific directory for language strings.

As usually js strings has other formatting for choise and others - you will want set all js strings to specific directory and call batches without specify directory each time:

use I18nStringsBatch\I18nStringsBatchManager;

class AppServiceProvider extends ServiceProvider
{
    public function register()
    {
        I18nStringsBatchManager::setDefaultDirectoryPrefix('front-js');
    }
}

Usage in php

\I18nStringsBatch\Facades\I18nStringsBatch::getBatch(["licenses-list", "modal-confirmation"]);
\I18nStringsBatch\Facades\I18nStringsBatch::getBatchJson(["licenses-list", "modal-confirmation"]);
// or
\I18nStringsBatch\Facades\I18nStringsBatch::getBatch("modal-confirmation");
\I18nStringsBatch\Facades\I18nStringsBatch::getBatchJson("modal-confirmation");

// Using helpers
i18n_strings_batch(["licenses-list", "modal-confirmation"])
i18n_strings_batch_json(["licenses-list", "modal-confirmation"])
// or
i18n_strings_batch("modal-confirmation")
i18n_strings_batch_json("modal-confirmation")

Usage with component

<licenses-list
    :i18n-batch='@transBatch("licenses-list")'
/>
<!-- or -->
<licenses-list
    :i18n-batch='@transBatch(["licenses-list", "modal-confirmation"])'
/>

Usage with vue

Optionally publish assets

php artisan vendor:publish --tag=i18n-string-batch-resources --force

Example you can find there

Add directive to PHPStorm

transBatch
<?php echo i18n_strings_batch_json(
); ?>

Credits

  • Think Studio