From 7ecc0a75dfcec58ebf694e0a7feb686294b49847 Mon Sep 17 00:00:00 2001 From: Dimitrios Savvopoulos Date: Wed, 20 Aug 2014 17:04:15 +0200 Subject: [PATCH] Added option for changing the translation table suffix in configuration. #29 --- Translatable/Translatable.php | 3 ++- readme.md | 4 ++++ tests/TranslatableTest.php | 12 ++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Translatable/Translatable.php b/Translatable/Translatable.php index 112bb99..030a846 100644 --- a/Translatable/Translatable.php +++ b/Translatable/Translatable.php @@ -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() diff --git a/readme.md b/readme.md index e8d06c9..04485ca 100644 --- a/readme.md +++ b/readme.md @@ -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' + ); ``` diff --git a/tests/TranslatableTest.php b/tests/TranslatableTest.php index ebd033f..32957e3 100644 --- a/tests/TranslatableTest.php +++ b/tests/TranslatableTest.php @@ -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 */