solumdesignum / package-translator-loader
Laravel Package Translator Loader is translations loader for your package.
v2.02
2024-10-18 21:28 UTC
Requires
- php: ^8.1|^8.2|^8.3|^8.4
- illuminate/support: ^5|^6|^7|^8|^9|^10|^11|^12
Requires (Dev)
- mockery/mockery: ^1.4
- orchestra/testbench: ^5|^6|^7|^8|^9
- phpunit/phpunit: ^8|^9|^10|^11
- sempro/phpunit-pretty-print: ^1.4
README
Introduction
Laravel Package Translator Loader is translations loader that will help to
translation your package fully (Finally about time, I would say!!!).
Installation
To get started, install Package Translator Loader using the Composer package manager:
composer require solumdesignum/package-translator-loader
Features
The configuration file contains configurations.
<?php declare(strict_types=1); return [ 'segment' => 1 ];
Usage
<?php declare(strict_types=1); namespace SolumDeSignum\ThemeManager; use Illuminate\Contracts\Foundation\Application; use Illuminate\Support\ServiceProvider; use SolumDeSignum\PackageTranslatorLoader\PackageTranslatorLoader; class ExampleServiceProvider extends ServiceProvider { /** * @var PackageTranslatorLoader */ private PackageTranslatorLoader $packageTranslatorLoader; /** * ExampleServiceProvider constructor. * * @param Application $app */ public function __construct(Application $app) { parent::__construct($app); $this->packageTranslatorLoader = new PackageTranslatorLoader( $this->app, [ 'translator' => 'theme-manager.translator', 'nameSpace' => 'solumdesignum/theme-manager', 'packageRootPath' => __DIR__ . '/..', 'loadLangPath' => '/../resources/lang', 'loaderLangPath' => '/resources/lang', ] ); } }
Usage: Accessing Translations
<?php declare(strict_types=1); /** * Internal package translations * Even exceptions for both examples */ /** * Internal Translator instance * inside function get() should pass package name with translation key (package.translation-key) */ $this->packageTranslatorLoader->trans() ->get('theme-manager.invalid_argument_exception'); /** * Helper: can be used in Blade, Controllers, Models, Services and etc... * Inside first key must pass name of translator * Inside second key must pass package name with translation key (package.translation-key) */ translator( 'theme-manager.translator', 'theme-manager.invalid_argument_exception' );
Contributing
Thank you for considering contributing to the Laravel Package Translator Loader. You can read the contribution guidelines here
Security
If you discover any security-related issues, please email to Solum DeSignum.
Author
About
Solum DeSignum is a web design agency based in Latvia, Riga.
License
Laravel Package Translator Loader is open-sourced software licensed under the MIT license