Skip to content

Commit

Permalink
Add localization support
Browse files Browse the repository at this point in the history
  • Loading branch information
Patroklo committed May 13, 2016
1 parent cce0310 commit 5827811
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/FileUpload.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Patroklo\FormWidgets;


use Illuminate\Support\Facades\App;
use Input;
use Request;
use Response;
Expand Down Expand Up @@ -50,9 +50,6 @@ public function init()

parent::init();

// Load the $this->rules parameter
$this->setValidationRules();

}


Expand All @@ -67,6 +64,10 @@ protected function checkUploadPostback()
return;
}

// Adds the path to the lang files
app('translator')->getLoader()->
addNamespace('patroklo.formwidgets', base_path('vendor/patroklo/octobercms-improved-fileupload/src/lang') );

try
{
if (!Input::hasFile('file_data'))
Expand All @@ -76,12 +77,13 @@ protected function checkUploadPostback()

$uploadedFile = Input::file('file_data');

$validationRules = $this->rules;
// Load the $this->rules parameter
$this->setValidationRules();

$validation = Validator::make(
['file_data' => $uploadedFile],
['file_data' => $validationRules],
['max_files' => e(trans('patroklo.webcomic::lang.messages.max_files'))]
['file_data' => $this->rules],
['max_files' => e(trans('patroklo.formwidgets::messages.max_files'))]
);

if ($validation->fails())
Expand Down
5 changes: 5 additions & 0 deletions src/lang/en/messages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
return [
'max_files' => 'You have uploaded the max number of files allowed.',

];
4 changes: 4 additions & 0 deletions src/lang/sp/messages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
return [
'max_files' => 'Has subido el máximo número de ficheros permitidos.',
];

0 comments on commit 5827811

Please sign in to comment.