Skip to content

Commit 9e570ee

Browse files
authored
Supports ever changing lang folder (#170)
* Allows users add the name of their lang directory * Updates README
1 parent 1253167 commit 9e570ee

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ The configuration will be published to `config/localization-js.php`.
8080

8181
You may edit this file to define the messages you need in your Javascript code. Just edit the `messages` array in the config file. **Empty messages array will include all the language files in build**.
8282

83+
8384
To make only `pagination.php` and `validation.php` files to be included in build process:
8485

8586
```php
@@ -93,6 +94,10 @@ return [
9394
];
9495
```
9596

97+
### Specifying the path to your language folder
98+
99+
Out of the box, this package points to `/app/lang` in Laravel 4 or the `resources/lang` in Laravel >= 5 but you can specify where yours exists by editing the `lang_path` key in the config file.
100+
96101
### Using [gulp](http://gulpjs.com/) (optional)
97102

98103
Install [`gulp-shell`](https://github.com/sun-zheng-an/gulp-shell) and then run it directly in your `gulpfile.js`:

src/Mariuzzo/LaravelJsLocalization/LaravelJsLocalizationServiceProvider.php

+10-4
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,17 @@ public function register()
7070

7171
$files = $app['files'];
7272

73-
if ($laravelMajorVersion === 4) {
74-
$langs = $app['path.base'].'/app/lang';
75-
} elseif ($laravelMajorVersion >= 5) {
76-
$langs = $app['path.base'].'/resources/lang';
73+
$languagePath = $this->app['config']->get('localization-js')['lang_path'];
74+
if (empty($languagePath)) {
75+
if ($laravelMajorVersion === 4) {
76+
$languagePath = 'app/lang';
77+
$langs = $app['path.base'].'/app/lang';
78+
} elseif ($laravelMajorVersion >= 5) {
79+
$languagePath = 'resources/lang';
80+
}
7781
}
82+
$langs = $app['path.base'].$languagePath;
83+
7884
$messages = $app['config']->get('localization-js.messages');
7985
$generator = new Generators\LangJsGenerator($files, $langs, $messages);
8086

src/config/config.php

+5
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@
1919
* The default path to use for the generated javascript.
2020
*/
2121
'path' => public_path('messages.js'),
22+
23+
/*
24+
* The path for your laravel lang folder
25+
*/
26+
'lang_path' => '',
2227
];

0 commit comments

Comments
 (0)