Skip to content

Commit

Permalink
added mkdir excteption and updated to laravel 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Mordi Sacks committed Mar 8, 2017
1 parent 63f599b commit 98752cd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
12 changes: 6 additions & 6 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# I18n
This package is a Laravel 5.2 wrapper for [I18n](https://github.com/MordiSacks/I18n)
This package is a Laravel wrapper for [I18n](https://github.com/MordiSacks/I18n)

# Installation
```
Expand All @@ -12,14 +12,14 @@ MordiSacks\LaravelI18n\I18nServiceProvider::class,
```

# Usage
Set your default locale in .env file
```
I18N=he_IL
```
Set your default locale in app.php config

This package overrides blade `@lang`

So the following will work
```
<h1>@lang('Hello :name', 'default', ['name' => 'Mordi'])</h1>
```
```

# Changelog 2.1.0
* Updated to laravel 5.4
4 changes: 2 additions & 2 deletions composer.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
"laravel localisation"
],
"license": "MIT",
"version": "2.0.0",
"version": "2.1.0",
"authors": [
{
"name": "Mordi Sacks"
}
],
"require": {
"php": ">=5.4.0",
"laravel/framework": "5.2.*",
"laravel/framework": "5.4.*",
"mordisacks/i18n": "2.0.*"
},
"autoload": {
Expand Down
34 changes: 18 additions & 16 deletions src/I18nServiceProvider.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
<?php
namespace MordiSacks\LaravelI18n;

use Exception;
use Illuminate\Support\ServiceProvider;
use MordiSacks\I18n\I18n;

class I18nServiceProvider extends ServiceProvider
{

public function boot()
{
if(!file_exists(resource_path('i18n')))
{
mkdir(resource_path('i18n'), 0755);
}
public function boot()
{
if (!file_exists(resource_path('i18n'))) {
if (!@mkdir(resource_path('i18n'), 0755, $recursive = true)) {
$error = error_get_last();
throw new Exception('cant create directory ' . $error['message'], 1);
}
}

I18n::$dir = resource_path('i18n');
I18n::$dir = resource_path('i18n');

I18n::$locale = env('I18N');
I18n::$locale = config('app.locale');

\Blade::directive('lang', function ($expression)
{
return "<?php echo __{$expression}; ?>";
});
}
\Blade::directive('lang', function ($expression) {
return "<?php echo MordiSacks\\I18n\\I18n::translate({$expression}); ?>";
});
}

public function register()
{
public function register()
{

}
}
}

0 comments on commit 98752cd

Please sign in to comment.