Skip to content

Commit 2a76b0c

Browse files
committed
Support Laravel 5 and add custom lang folder path
1 parent e461acd commit 2a76b0c

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ Use the github issue system to open a issue and ask for something.
190190

191191
## Change Log
192192

193+
### v1.2.1
194+
195+
- add `lang_folder_path` parameter in configuration file to configure the custom location of your lang files
196+
- check lang files in `app/lang` by default for Laravel 4.x
197+
- check lang files in `app/resources/lang` by default for Laravel 5
198+
193199
### v1.2
194200

195201
- support for Laravel 5 (4.3)

src/Potsky/LaravelLocalizationHelpers/Commands/LocalizationAbstract.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public function __construct( Repository $configRepository )
7070
$this->trans_methods = \Config::get('laravel-localization-helpers::config.trans_methods');
7171
$this->folders = \Config::get('laravel-localization-helpers::config.folders');
7272
$this->ignore_lang_files = \Config::get('laravel-localization-helpers::config.ignore_lang_files');
73+
$this->lang_folder_path = \Config::get('laravel-localization-helpers::config.lang_folder_path');
7374
$this->never_obsolete_keys = \Config::get('laravel-localization-helpers::config.never_obsolete_keys');
7475
$this->editor = \Config::get('laravel-localization-helpers::config.editor_command_line');
7576
parent::__construct();
@@ -82,7 +83,32 @@ public function __construct( Repository $configRepository )
8283
*/
8384
protected function get_lang_path()
8485
{
85-
return app_path() . DIRECTORY_SEPARATOR . 'lang';
86+
if ( empty( $this->lang_folder_path ) ) {
87+
$paths = array(
88+
app_path() . DIRECTORY_SEPARATOR . 'lang',
89+
app_path() . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'lang',
90+
);
91+
foreach( $paths as $path ) {
92+
if ( file_exists( $path ) ) {
93+
return $path;
94+
}
95+
}
96+
97+
$this->error( "No lang folder found in these paths:" );
98+
foreach( $paths as $path ) {
99+
$this->error( "- " . $path );
100+
}
101+
$this->line( '' );
102+
die();
103+
}
104+
else {
105+
if ( file_exists( $this->lang_folder_path ) ) {
106+
return $this->lang_folder_path;
107+
}
108+
$this->error( 'No lang folder found in your custom path: "' . $this->lang_folder_path . '"' );
109+
$this->line( '' );
110+
die();
111+
}
86112
}
87113

88114
/**

src/config/config.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@
3636
),
3737

3838

39+
/*
40+
|--------------------------------------------------------------------------
41+
| Lang folder
42+
|--------------------------------------------------------------------------
43+
|
44+
| You can overwrite where is located your lang folder
45+
| If null or missing, Localization::Missing will search :
46+
| - first in app_path() . DIRECTORY_SEPARATOR . 'lang',
47+
| - then in app_path() . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'lang',
48+
|
49+
*/
50+
'lang_folder_path' => null,
51+
52+
3953
/*
4054
|--------------------------------------------------------------------------
4155
| Methods or functions to search for

0 commit comments

Comments
 (0)