diff --git a/lib/Conekta.php b/lib/Conekta.php index 9cd219c..50ce02e 100644 --- a/lib/Conekta.php +++ b/lib/Conekta.php @@ -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'; diff --git a/lib/locales/Lang.php b/lib/Conekta/Lang.php similarity index 93% rename from lib/locales/Lang.php rename to lib/Conekta/Lang.php index a85877a..8c543c8 100644 --- a/lib/locales/Lang.php +++ b/lib/Conekta/Lang.php @@ -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)]; diff --git a/test/Conekta/LangTest.php b/test/Conekta/LangTest.php new file mode 100644 index 0000000..bd4051a --- /dev/null +++ b/test/Conekta/LangTest.php @@ -0,0 +1,17 @@ +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) + ); + } +}