2017 © Pedro Peláez
 

library laravel-lang

Modular Export of Laravel translations for Front-End and API usage.

image

yazeed-obaid/laravel-lang

Modular Export of Laravel translations for Front-End and API usage.

  • Friday, June 29, 2018
  • by Yazeed-Obaid
  • Repository
  • 0 Watchers
  • 3 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Laravel-Lang

License Downloads Downloads , (*1)

Modular Export of Laravel translations for Front-End and API usage., (*2)

This package is inspired from the the way how CMSs built on top of Laravel work and how they are structured into packages for large-scale applications. In these CMSs, each package has its own langdirectory., (*3)

Also, this package has an exclude array to exclude lang files from each lang directory in these modular packages. And finally, an event is emitted after export is done., (*4)

Installation

Require this package, with Composer, in the root directory of your project., (*5)

``` bash $ composer require yazeedobaid/laravel-lang, (*6)



## Assets Publishing To publish the config file of the package use: ``` php php artisan vendor:publish --provider=YazeedObaid\Lang\LaravelLangServiceProvider --tag=config

Usage

Add this route to your Front-End side or call it as an API. http://your-web-app/js/lang.js, (*7)

Config File

The config file contains configurations for the route to use for the translations, a middlewares array for the route to be applied to it. An events channel, to specify the event channel., (*8)

The keys for the 'paths' and 'files_to_exclude' arrays must be the same, since these keys define each package name (alias). Feel free to select you prefered name., (*9)

Example config file

Below is an example on the path of a package to get its translations with a excluded trans file in that package:, (*10)

``` php 'paths' => [ /** * For each package in your project you can define the relative path to that * package from your root app directory to the lang directory in that package * to use it in export to Vue. The default path to Laravel applications which * is /resources/lang is set by default to you * */, (*11)

    /**
     * Default path is the resources/lang path.
     * */
    'default' => '/resources/lang',



    /**
     * Here you define a path for each package you want to export the
     * translations for.
     * */
    'my-package' => '/packages/myPckage/src/resources/lang'
],


'files_to_exclude' => [
    /**
     * In each package you define above in the paths array you can exclude files
     * in that package and not to include them in export to Vue process. Use the
     * same key you use above to exclude files in each package. The below is an
     * example of excluding the auth file in default Laravel translations
     * location.
     * */


    /*'default' => [
        'auth'
    ]*/
]

```, (*12)

A Note to be Mentioned

This package was inspired from kg-bot/laravel-localization-to-vue., (*13)

The Versions

29/06 2018

dev-master

9999999-dev

Modular Export of Laravel translations for Front-End and API usage.

  Sources   Download

MIT

by Yazeed Obaid

laravel framework yazeed obaid obaid laravel-lang laravel lang

17/06 2018

0.1

0.1.0.0

Modular Export of Laravel translations for Front-End and API usage.

  Sources   Download

MIT

by Yazeed Obaid

laravel framework yazeed obaid obaid laravel-lang laravel lang