Skip to content

Commit

Permalink
Merge branch 'master' of github.com:spatie/laravel-translatable
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Feb 27, 2019
2 parents a881ca2 + f819a4b commit ec27235
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 60 deletions.
15 changes: 0 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,6 @@ You can install the package via composer:
composer require spatie/laravel-translatable
```

The package will automatically register itself.

If you want to change add fallback_locale, you must publish the config file:
```
php artisan vendor:publish --provider="Spatie\Translatable\TranslatableServiceProvider"
```

This is the contents of the published file:
```php
return [
'fallback_locale' => 'en',
];
```


## Making a model translatable

The required steps to make a model translatable are:
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"extra": {
"laravel": {
"providers": [
"Spatie\\Translatable\\TranslatableServiceProvider"
]
}
}
Expand Down
9 changes: 0 additions & 9 deletions config/translatable.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/HasTranslations.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ protected function normalizeLocale(string $key, string $locale, bool $useFallbac
return $locale;
}

if (! is_null($fallbackLocale = config('translatable.fallback_locale'))) {
if (! is_null($fallbackLocale = config('app.fallback_locale'))) {
return $fallbackLocale;
}

Expand Down
20 changes: 0 additions & 20 deletions src/TranslatableServiceProvider.php

This file was deleted.

6 changes: 0 additions & 6 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Orchestra\Testbench\TestCase as Orchestra;
use Spatie\Translatable\TranslatableServiceProvider;

abstract class TestCase extends Orchestra
{
Expand All @@ -16,11 +15,6 @@ public function setUp(): void
$this->setUpDatabase();
}

protected function getPackageProviders($app)
{
return [TranslatableServiceProvider::class];
}

protected function setUpDatabase()
{
Schema::create('test_models', function (Blueprint $table) {
Expand Down
16 changes: 8 additions & 8 deletions tests/TranslatableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function setUp(): void
/** @test */
public function it_will_return_fallback_locale_translation_when_getting_an_unknown_locale()
{
$this->app['config']->set('translatable.fallback_locale', 'en');
$this->app['config']->set('app.fallback_locale', 'en');

$this->testModel->setTranslation('name', 'en', 'testValue_en');
$this->testModel->save();
Expand All @@ -30,7 +30,7 @@ public function it_will_return_fallback_locale_translation_when_getting_an_unkno
/** @test */
public function it_provides_a_flog_to_not_return_fallback_locale_translation_when_getting_an_unknown_locale()
{
$this->app['config']->set('translatable.fallback_locale', 'en');
$this->app['config']->set('app.fallback_locale', 'en');

$this->testModel->setTranslation('name', 'en', 'testValue_en');
$this->testModel->save();
Expand All @@ -41,7 +41,7 @@ public function it_provides_a_flog_to_not_return_fallback_locale_translation_whe
/** @test */
public function it_will_return_fallback_locale_translation_when_getting_an_unknown_locale_and_fallback_is_true()
{
$this->app['config']->set('translatable.fallback_locale', 'en');
$this->app['config']->set('app.fallback_locale', 'en');

$this->testModel->setTranslation('name', 'en', 'testValue_en');
$this->testModel->save();
Expand All @@ -52,7 +52,7 @@ public function it_will_return_fallback_locale_translation_when_getting_an_unkno
/** @test */
public function it_will_return_an_empty_string_when_getting_an_unknown_locale_and_fallback_is_not_set()
{
$this->app['config']->set('translatable.fallback_locale', '');
$this->app['config']->set('app.fallback_locale', '');

$this->testModel->setTranslation('name', 'en', 'testValue_en');
$this->testModel->save();
Expand All @@ -63,7 +63,7 @@ public function it_will_return_an_empty_string_when_getting_an_unknown_locale_an
/** @test */
public function it_will_return_an_empty_string_when_getting_an_unknown_locale_and_fallback_is_empty()
{
$this->app['config']->set('translatable.fallback_locale', '');
$this->app['config']->set('app.fallback_locale', '');

$this->testModel->setTranslation('name', 'en', 'testValue_en');
$this->testModel->save();
Expand Down Expand Up @@ -420,7 +420,7 @@ public function it_can_get_all_translations()
/** @test */
public function it_will_return_fallback_locale_translation_when_getting_an_empty_translation_from_the_locale()
{
$this->app['config']->set('translatable.fallback_locale', 'en');
$this->app['config']->set('app.fallback_locale', 'en');

$this->testModel->setTranslation('name', 'en', 'testValue_en');
$this->testModel->setTranslation('name', 'nl', null);
Expand All @@ -441,7 +441,7 @@ public function it_will_return_correct_translation_value_if_value_is_set_to_zero
/** @test */
public function it_will_not_return_fallback_value_if_value_is_set_to_zero()
{
$this->app['config']->set('translatable.fallback_locale', 'en');
$this->app['config']->set('app.fallback_locale', 'en');

$this->testModel->setTranslation('name', 'en', '1');
$this->testModel->setTranslation('name', 'nl', '0');
Expand All @@ -453,7 +453,7 @@ public function it_will_not_return_fallback_value_if_value_is_set_to_zero()
/** @test */
public function it_will_not_remove_zero_value_of_other_locale_in_database()
{
$this->app['config']->set('translatable.fallback_locale', 'en');
$this->app['config']->set('app.fallback_locale', 'en');

$this->testModel->setTranslation('name', 'nl', '0');
$this->testModel->setTranslation('name', 'en', '1');
Expand Down

0 comments on commit ec27235

Please sign in to comment.