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

Commit

Permalink
Added option for changing the translation table suffix in configurati…
Browse files Browse the repository at this point in the history
…on. #29
  • Loading branch information
dimsav committed Aug 20, 2014
1 parent 5388d87 commit 7ecc0a7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Translatable/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public function getTranslationModelName()

public function getTranslationModelNameDefault()
{
return get_class($this) . 'Translation';
$config = App::make('config');
return get_class($this) . $config->get('app.translatable_suffix', 'Translation');
}

public function getRelationKey()
Expand Down
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ return array(
// The default locale
'locale' => 'en',

// Override the default 'Translation' class suffix
// to use CountryTrans instead of CountryTranslation
'translatable_suffix' => 'Trans'

);
```

Expand Down
12 changes: 12 additions & 0 deletions tests/TranslatableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ public function it_finds_the_default_translation_class()
$country->getTranslationModelNameDefault());
}

/**
* @test
*/
public function it_finds_the_translation_class_with_suffix_set()
{
App::make('config')->set('app.translatable_suffix', 'Trans');
$country = new Country;
$this->assertEquals(
'Dimsav\Translatable\Test\Model\CountryTrans',
$country->getTranslationModelName());
}

/**
* @test
*/
Expand Down

0 comments on commit 7ecc0a7

Please sign in to comment.