-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[9.x] Fixes unable to use
trans()->has()
on JSON language files. (#…
…47582) * [9.x] Fixes unable to use `tran()->has()` on JSON language files. Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> --------- Signed-off-by: Mior Muhammad Zaki <[email protected]>
- Loading branch information
Showing
4 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Integration\Translation; | ||
|
||
use Orchestra\Testbench\TestCase; | ||
|
||
class TranslatorTest extends TestCase | ||
{ | ||
/** | ||
* Define environment setup. | ||
* | ||
* @param \Illuminate\Foundation\Application $app | ||
* @return void | ||
*/ | ||
protected function defineEnvironment($app) | ||
{ | ||
$app['translator']->addJsonPath(__DIR__.'/lang'); | ||
|
||
parent::defineEnvironment($app); | ||
} | ||
|
||
public function testItCanGetFromLocaleForJson() | ||
{ | ||
$this->assertSame('30 Days', $this->app['translator']->get('30 Days')); | ||
|
||
$this->app->setLocale('fr'); | ||
|
||
$this->assertSame('30 jours', $this->app['translator']->get('30 Days')); | ||
} | ||
|
||
public function testItCanCheckLanguageExistsHasFromLocaleForJson() | ||
{ | ||
$this->assertTrue($this->app['translator']->has('1 Day')); | ||
$this->assertTrue($this->app['translator']->hasForLocale('1 Day')); | ||
$this->assertTrue($this->app['translator']->hasForLocale('30 Days')); | ||
|
||
$this->app->setLocale('fr'); | ||
|
||
$this->assertFalse($this->app['translator']->has('1 Day')); | ||
$this->assertFalse($this->app['translator']->hasForLocale('1 Day')); | ||
$this->assertTrue($this->app['translator']->hasForLocale('30 Days')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"1 Day": "1 Day", | ||
"30 Days": "30 Days", | ||
"365 Days": "365 Days", | ||
"60 Days": "60 Days", | ||
"90 Days": "90 Days" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"30 Days": "30 jours", | ||
"365 Days": "365 jours", | ||
"60 Days": "60 jours", | ||
"90 Days": "90 jours" | ||
} |