Download the PHP package subotkevic/laravel-json-translation-helper without Composer
On this page you can find all versions of the php package subotkevic/laravel-json-translation-helper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download subotkevic/laravel-json-translation-helper
More information about subotkevic/laravel-json-translation-helper
Files in subotkevic/laravel-json-translation-helper
Package laravel-json-translation-helper
Short Description Searches for translation keys – inserts into JSON translation files.
License MIT
Informations about the package laravel-json-translation-helper
JSON Translation Helper for Laravel
JSON Translation Helper scans your project for __()
, lang()
translation helper methods and @lang
directives, then it creates keys in your JSON translation files.
And yes, it avoids duplicates – helper creates only non-existing keys. Ready for your translation.
Installation
First, install JSON Translation Helper using the Composer require command:
That's it. Package registers service provider automatically.
Usage
Translation files
First, you have to create your translation files for languages you will translate your application to.
For example, if you want your application to have a Spanish translation, you should create a resources/lang/es.json
file.
Of course you can have multiple translation files:
Make sure that your translation files is valid JSON, otherwise our package will not work:
If you don't have any translations for now, just make sure your file is not empty, but actually an empty JSON object:
Scan your application
Finally, to scan your application for missing translation keys just run:
Configuration
Publishing configuration
First, publish the configuration file:
It will bring you config/translation-helper.php
configuration file.
Read the following sections of what you can configure.
Directories
To specify where you want to scan for translation strings, just modify scan_directories
array:
File extensions
Our package scans only .php
files out of the box.
You can add more file extensions to file_extensions
array in the config/translation-helper.php
configuration file to scan, let's say, .vue
or .js
files:
Translation helper methods
By default our package looks for lang()
and __()
translation helper methods and directives.
But you can extend, modify, or remove them in the config file by modifying translation_methods
array: