Skip to content

Commit

Permalink
Merge pull request #14 from joecohens/fix-lang
Browse files Browse the repository at this point in the history
Fix autoload Lang class
  • Loading branch information
MauricioMurga committed Feb 24, 2016
2 parents 515ff5b + 6a211e9 commit df3d1a3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Conekta.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
if (!function_exists('get_called_class')) {
throw new Exception('Conekta needs to be run on PHP >= 5.3.0.');
}
require_once dirname(__FILE__).'/locales/Lang.php';
require_once dirname(__FILE__).'/Conekta/Lang.php';
require_once dirname(__FILE__).'/Conekta/Conekta.php';
require_once dirname(__FILE__).'/Conekta/Util.php';
require_once dirname(__FILE__).'/Conekta/Requestor.php';
Expand Down
2 changes: 1 addition & 1 deletion lib/locales/Lang.php → lib/Conekta/Lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Conekta_Lang

public static function translate($key, $parameters = null, $locale)
{
$langs = self::readDirectory(dirname(__FILE__).'/messages');
$langs = self::readDirectory(dirname(__FILE__).'/../locales/messages');

$keys = explode('.', $locale.'.'.$key);
$result = $langs[array_shift($keys)];
Expand Down
17 changes: 17 additions & 0 deletions test/Conekta/LangTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

class Conekta_LangTest extends UnitTestCase
{
public function testShouldTranslatesMessage()
{
$this->assertEqual(
'There was an error. Please contact system administrator.',
Conekta_Lang::translate('error.resource.id_purchaser', null, Conekta_Lang::EN)
);

$this->assertEqual(
'Hubo un error. Favor de contactar al administrador del sistema.',
Conekta_Lang::translate('error.resource.id_purchaser', null, Conekta_Lang::ES)
);
}
}

0 comments on commit df3d1a3

Please sign in to comment.