GithubHelp home page GithubHelp logo

solumdesignum / package-translator-loader Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 17 KB

Laravel Package Translator Loader is translations loader that will help to translation your package fully Finally about time, I would say.

Home Page: https://solum-designum.eu/

License: MIT License

PHP 100.00%
php package opensource packages php7 githunt development laravel-package laravel-package-translator-loader solumdesignum opensourcedevelopment laravel laravel-5-package package-translator-loader

package-translator-loader's Introduction

StyleCI Scrutinizer Code Quality Total Downloads Latest Stable Version Latest Unstable Version MIT Licensed

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.