-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from Laravel-Lang/1.x
Added the ability to translate certain localizations
- Loading branch information
Showing
14 changed files
with
187 additions
and
15 deletions.
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
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
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
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,5 @@ | ||
[ | ||
"Administrator", | ||
"This field must be accepted.", | ||
"The :attribute must be accepted." | ||
] |
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 @@ | ||
{ | ||
"Added.": "Added.", | ||
"Administrator": "Administrator", | ||
"Foo": "Foo", | ||
"Bar.": "Bar." | ||
} |
7 changes: 7 additions & 0 deletions
7
tests/Fixtures/Resources/Translate/locales/fr/php-inline.json
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 @@ | ||
{ | ||
"accepted": "This field must be accepted.", | ||
"accepted_if": "This field must be accepted when :other is :value.", | ||
"active_url": "This field is not a valid URL.", | ||
"custom2": "Custom field 2", | ||
"sub.array2": "Sub Array 2" | ||
} |
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,10 @@ | ||
{ | ||
"0": "Numeric Zero", | ||
"10": "Numeric Ten", | ||
"100": "Numeric One Hundred", | ||
"accepted": "The :attribute must be accepted.", | ||
"accepted_if": "The :attribute must be accepted when :other is :value.", | ||
"active_url": "The :attribute is not a valid URL.", | ||
"custom": "Custom field", | ||
"sub.array": "Sub Array" | ||
} |
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,56 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Unit\Commands\Translate; | ||
|
||
/** | ||
* @group Translate | ||
*/ | ||
class FrenchTest extends Base | ||
{ | ||
public function testJson(): void | ||
{ | ||
$this->assertJsonFileEqualsJson([ | ||
'Added.' => 'Ajoutée.', | ||
'Administrator' => 'Administrator', | ||
], 'locales/fr/json.json', __FUNCTION__); | ||
} | ||
|
||
public function testPhp(): void | ||
{ | ||
$values = $this->filesystem->load($this->tempPath('locales/fr/php.json')); | ||
|
||
$this->assertContainsEquals($values[0], ['Zéro numérique']); | ||
$this->assertContainsEquals($values[10], ['Dix numériques']); | ||
$this->assertContainsEquals($values[100], ['Cent numérique']); | ||
|
||
$this->assertSame($values['accepted'], 'The :attribute must be accepted.'); | ||
|
||
$this->assertContainsEquals($values['accepted_if'], ['Le :attribute doit être accepté quand :other vaut :value.']); | ||
|
||
$this->assertContainsEquals($values['active_url'], ['Le :attribute n\'est pas une URL valide.']); | ||
|
||
$this->assertContainsEquals($values['between.array'], ['The :attribute must have between :min and :max items.']); | ||
$this->assertContainsEquals($values['between.file'], ['The :attribute must be between :min and :max kilobytes.']); | ||
} | ||
|
||
public function testPhpInline(): void | ||
{ | ||
$values = $this->filesystem->load($this->tempPath('locales/fr/php-inline.json')); | ||
|
||
$this->assertSame($values['accepted'], 'This field must be accepted.'); | ||
|
||
$this->assertContainsEquals($values['accepted_if'], ['Ce champ doit être accepté lorsque :other vaut :value.']); | ||
|
||
$this->assertContainsEquals($values['active_url'], ['Ce champ n\'est pas une URL valide.']); | ||
|
||
$this->assertContainsEquals($values['between.array'], ['This field must have between :min and :max items.']); | ||
$this->assertContainsEquals($values['between.file'], ['This field must be between :min and :max kilobytes.']); | ||
} | ||
|
||
public function testExcludes(): void | ||
{ | ||
$this->assertFileExists($this->tempPath('locales/fr/_excludes.json')); | ||
} | ||
} |
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,66 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Unit\Commands\Translate; | ||
|
||
/** | ||
* @group Translate | ||
*/ | ||
class PerLocaleTest extends Base | ||
{ | ||
protected array $call_options = [ | ||
'--locale' => 'de', | ||
]; | ||
|
||
public function testJson(): void | ||
{ | ||
$this->assertJsonFileEqualsJson([ | ||
'Added.' => 'Hinzugefügt.', | ||
'Administrator' => 'Administrator', | ||
], 'locales/de/json.json', __FUNCTION__); | ||
|
||
$this->assertJsonFileEqualsJson([ | ||
'Added.' => 'Added.', | ||
'Administrator' => 'Administrator', | ||
'Foo' => 'Foo', | ||
'Bar.' => 'Bar.', | ||
], 'locales/fr/json.json', __FUNCTION__); | ||
} | ||
|
||
public function testPhp(): void | ||
{ | ||
// German | ||
$values = $this->filesystem->load($this->tempPath('locales/de/php.json')); | ||
|
||
$this->assertContainsEquals($values[0], ['Numerische Null']); | ||
$this->assertContainsEquals($values[10], ['Numerische Zehn']); | ||
$this->assertContainsEquals($values[100], ['Numerisch Hundert']); | ||
|
||
// French | ||
$values = $this->filesystem->load($this->tempPath('locales/fr/php.json')); | ||
|
||
$this->assertContainsEquals($values[0], ['Numeric Zero']); | ||
$this->assertContainsEquals($values[10], ['Numeric Ten']); | ||
$this->assertContainsEquals($values[100], ['Numeric One Hundred']); | ||
} | ||
|
||
public function testPhpInline(): void | ||
{ | ||
// German | ||
$values = $this->filesystem->load($this->tempPath('locales/de/php-inline.json')); | ||
|
||
$this->assertContainsEquals( | ||
$values['accepted_if'], | ||
['Dieses Feld muss akzeptiert werden, wenn :other gleich :value ist.', 'Dieses Feld muss akzeptiert werden, wenn :other :value ist.'] | ||
); | ||
|
||
$this->assertContainsEquals($values['active_url'], ['Dieses Feld ist keine gültige URL.', 'Das ist keine gültige Internet-Adresse.']); | ||
|
||
// French | ||
$values = $this->filesystem->load($this->tempPath('locales/fr/php-inline.json')); | ||
|
||
$this->assertSame($values['accepted_if'], 'This field must be accepted when :other is :value.'); | ||
$this->assertSame($values['active_url'], 'This field is not a valid URL.'); | ||
} | ||
} |