Skip to content
This repository was archived by the owner on Jun 18, 2019. It is now read-only.

Commit 5972379

Browse files
deargonautGummibeer
authored andcommitted
add locales helper class
1 parent f1d5569 commit 5972379

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

src/Translatable/Locales.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Dimsav\Translatable;
4+
5+
use Illuminate\Contracts\Config\Repository as ConfigContract;
6+
use Illuminate\Contracts\Translation\Translator as TranslatorContract;
7+
8+
class Locales
9+
{
10+
/**
11+
* @var ConfigContract
12+
*/
13+
protected $config;
14+
15+
/**
16+
* @var TranslatorContract
17+
*/
18+
protected $translator;
19+
20+
public function __construct(ConfigContract $config, TranslatorContract $translator)
21+
{
22+
$this->config = $config;
23+
$this->translator = $translator;
24+
}
25+
}

src/Translatable/TranslatableServiceProvider.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,29 @@ class TranslatableServiceProvider extends ServiceProvider
99
public function boot()
1010
{
1111
$this->publishes([
12-
__DIR__.'/../config/translatable.php' => config_path('translatable.php'),
12+
__DIR__ . '/../config/translatable.php' => config_path('translatable.php'),
1313
], 'translatable');
1414
}
1515

16-
/**
17-
* Register the service provider.
18-
*/
1916
public function register()
2017
{
2118
$this->mergeConfigFrom(
22-
__DIR__.'/../config/translatable.php', 'translatable'
19+
__DIR__ . '/../config/translatable.php', 'translatable'
2320
);
21+
22+
$this->registerTranslatableHelper();
23+
}
24+
25+
public function registerTranslatableHelper()
26+
{
27+
$this->app->singleton('translatable.locales', Locales::class);
28+
$this->app->singleton(Locales::class);
29+
}
30+
31+
public function provides()
32+
{
33+
return [
34+
'translatable.helper',
35+
];
2436
}
2537
}

0 commit comments

Comments
 (0)