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

Commit

Permalink
Adding support for multiple languages. refs #234
Browse files Browse the repository at this point in the history
  • Loading branch information
igorsantos07 committed May 10, 2015
1 parent a237c88 commit ddc6cbf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ to your database, obviously):
'password' => 'h4ckr',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci'
));
), 'en'); //English is the default messages language, may be left empty
```

------------------------------------------------------------------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions src/LaravelBook/Ardent/Ardent.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ abstract class Ardent extends Model {
protected static $externalValidator = false;

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

$db->bootEloquent();

$translator = new Translator('en');
$translator = new Translator($lang);
$translator->addLoader('file_loader', new PhpFileLoader());
$translator->addResource('file_loader',
dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'lang'.DIRECTORY_SEPARATOR.'en'.
DIRECTORY_SEPARATOR.'validation.php', 'en');
dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'lang'.DIRECTORY_SEPARATOR.$lang.
DIRECTORY_SEPARATOR.'validation.php', $lang);

self::$externalValidator = true;
self::$validationFactory = new ValidationFactory($translator);
Expand Down

0 comments on commit ddc6cbf

Please sign in to comment.