Compile lang files to be used within js

Installs: 159

Dependents: 0

Suggesters: 0

Security: 0

Stars: 5

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/awkwardideas/langjs

v1.0.0 2017-03-01 23:19 UTC

This package is auto-updated.

Last update: 2025-09-29 01:49:50 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

Install Via Composer

composer require awkwardideas/langjs

Add to config/app.php

Under Package Service Providers Add

AwkwardIdeas\LangJS\LangJSServiceProvider::class,

Build LangJS script file

  1. run php artisan langjs:build --d js/LangJS.js
  2. Adjust the --d path to whatever you would like under your public directory
  3. Include this script file into your layout
  • You must run the build command any time you want to recompile the language file changes. A watchdog may be built in the future but is not currently available
  • This only compiles the lang files within your resources/lang folder. Vendor lang files are not included currently.

Javascript commands

  • _lang(key [, replace, locale])

    • Same setup as @lang('auth.user'), will retrieve your language for password which you put in your php lang file auth.php.
    • Replace and locale are optional parameters
    • Locale will default to en, if not provided.
    • If key has a plural form, the singular version will be returned, instead of the full term value
  • _choice(key, number [, replace, locale])

    • Same setup as @choice('auth.user',2)
    • Replace and locale are optional parameters
    • Locale will default to en, if not provided.