Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Commit ddc6cbf

Browse files
committed
Adding support for multiple languages. refs #234
1 parent a237c88 commit ddc6cbf

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ to your database, obviously):
4747
'password' => 'h4ckr',
4848
'charset' => 'utf8',
4949
'collation' => 'utf8_unicode_ci'
50-
));
50+
), 'en'); //English is the default messages language, may be left empty
5151
```
5252

5353
------------------------------------------------------------------------------------------------------------

src/LaravelBook/Ardent/Ardent.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ abstract class Ardent extends Model {
134134
protected static $externalValidator = false;
135135

136136
/**
137-
* A Translator instance, to be used by standalone Ardent instances.
137+
* A Validation Factory instance, to be used by standalone Ardent instances with the Translator.
138138
*
139139
* @var \Illuminate\Validation\Factory
140140
*/
@@ -484,7 +484,7 @@ public function getAttribute($key) {
484484
* @param array $connection Connection info used by {@link \Illuminate\Database\Capsule\Manager::addConnection}.
485485
* Should contain driver, host, port, database, username, password, charset and collation.
486486
*/
487-
public static function configureAsExternal(array $connection) {
487+
public static function configureAsExternal(array $connection, $lang = 'en') {
488488
$db = new DatabaseCapsule;
489489
$db->addConnection($connection);
490490
$db->setEventDispatcher(new Dispatcher(new Container));
@@ -495,11 +495,11 @@ public static function configureAsExternal(array $connection) {
495495

496496
$db->bootEloquent();
497497

498-
$translator = new Translator('en');
498+
$translator = new Translator($lang);
499499
$translator->addLoader('file_loader', new PhpFileLoader());
500500
$translator->addResource('file_loader',
501-
dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'lang'.DIRECTORY_SEPARATOR.'en'.
502-
DIRECTORY_SEPARATOR.'validation.php', 'en');
501+
dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'lang'.DIRECTORY_SEPARATOR.$lang.
502+
DIRECTORY_SEPARATOR.'validation.php', $lang);
503503

504504
self::$externalValidator = true;
505505
self::$validationFactory = new ValidationFactory($translator);

0 commit comments

Comments
 (0)