Skip to content

Commit

Permalink
Remove multi-lingual support
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Jennings committed Dec 3, 2012
1 parent 4b30111 commit 9c0526a
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 683 deletions.
49 changes: 0 additions & 49 deletions modules/api/lang/en/global.lng

This file was deleted.

34 changes: 0 additions & 34 deletions modules/api/lang/es/global.lng

This file was deleted.

15 changes: 0 additions & 15 deletions modules/api/lib/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
//ini_set('html_errors', false);

// require all singletons here
require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'language.class.php';
require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'session.class.php';
require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'registry.class.php';
require_once 'modules' . $ds . 'api' . $ds . 'lib' . $ds . 'controller.class.php';
Expand Down Expand Up @@ -184,30 +183,16 @@ function __autoload_elastica ($class) {
}

try {
PFLanguage::getInstance();
$request = PFFactory::getInstance()->createObject('api.request');

$lang = $request->get('lang');
$app = $request->get('app');

if (isset($lang)) {
PFLanguage::getInstance()->setCurrentLocale($lang);
}

if (!isset($app)) {
$app = 'content';
}
} catch (PFException $e) {
$e->handleException();
}

try {
PFLanguage::getInstance()->loadTranslationTable('api', 'global');
PFLanguage::getInstance()->loadTranslationTable($app, 'global');
} catch (PFException $e) {
$e->handleException();
}

function printr($arr, $buffered=false) {
if (php_sapi_name() != 'cli') {
echo '<pre>';
Expand Down
128 changes: 40 additions & 88 deletions modules/api/lib/exception.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,99 +94,51 @@ public function setCode($code) {
}

public function setMessage($app, $message) {
if ($app == '') {
if (is_array($message)) {
$this->message = sprintf($message[0], $message[1]);
} else {
$this->message = $message;
}
if (is_array($message)) {
$this->message = sprintf($message[0], $message[1]);
} else {
if (is_array($message)) {
$this->message = sprintf(PFLanguage::getInstance()->getTranslation($app, $message[0]), $message[1]);
} else {
$this->message = PFLanguage::getInstance()->getTranslation($app, $message);
}
$this->message = $message;
}
}

protected function setErrorTypes($app) {
if ($app == '') {
$this->errortype = array (
E_PHP5_ERROR => 'Error',
E_UNKNOWN_ERROR => 'Error',
E_INSUFFICIENT_DATA => 'Warning',
E_ERROR => 'Error',
E_WARNING => 'Warning',
E_PARSE => 'Error',
E_NOTICE => 'Warning',
E_CORE_ERROR => 'Error',
E_CORE_WARNING => 'Warning',
E_COMPILE_ERROR => 'Error',
E_COMPILE_WARNING => 'Warning',
E_USER_FATAL => 'Fatal',
E_USER_ERROR => 'Error',
E_USER_WARNING => 'Warning',
E_USER_NOTICE => 'Notice',
E_STRICT => 'Notice'
);

$this->verbose_errortype = array (
E_PHP5_ERROR => 'Error',
E_UNKNOWN_ERROR => 'Unknown Error',
E_INSUFFICIENT_DATA => 'Warning',
E_ERROR => 'Error',
E_WARNING => 'Warning',
E_PARSE => 'Parsing Error',
E_NOTICE => 'Notice',
E_CORE_ERROR => 'Core Error',
E_CORE_WARNING => 'Core Warning',
E_COMPILE_ERROR => 'Compile Error',
E_COMPILE_WARNING => 'Compile Warning',
E_USER_FATAL => 'User Fatal',
E_USER_ERROR => 'User Error',
E_USER_WARNING => 'User Warning',
E_USER_NOTICE => 'User Notice',
E_STRICT => 'Runtime Notice'
);
} else {
$this->errortype = array (
E_PHP5_ERROR => PFLanguage::getInstance()->getTranslation('api','ERROR'),
E_UNKNOWN_ERROR => PFLanguage::getInstance()->getTranslation('api','ERROR'),
E_INSUFFICIENT_DATA => PFLanguage::getInstance()->getTranslation('api','INSUFFICIENT_DATA'),
E_ERROR => PFLanguage::getInstance()->getTranslation('api','ERROR'),
E_WARNING => PFLanguage::getInstance()->getTranslation('api','WARNING'),
E_PARSE => PFLanguage::getInstance()->getTranslation('api','ERROR'),
E_NOTICE => PFLanguage::getInstance()->getTranslation('api','WARNING'),
E_CORE_ERROR => PFLanguage::getInstance()->getTranslation('api','ERROR'),
E_CORE_WARNING => PFLanguage::getInstance()->getTranslation('api','WARNING'),
E_COMPILE_ERROR => PFLanguage::getInstance()->getTranslation('api','ERROR'),
E_COMPILE_WARNING => PFLanguage::getInstance()->getTranslation('api','WARNING'),
E_USER_FATAL => PFLanguage::getInstance()->getTranslation('api','FATAL'),
E_USER_ERROR => PFLanguage::getInstance()->getTranslation('api','ERROR'),
E_USER_WARNING => PFLanguage::getInstance()->getTranslation('api','WARNING'),
E_USER_NOTICE => PFLanguage::getInstance()->getTranslation('api','NOTICE'),
E_STRICT => PFLanguage::getInstance()->getTranslation('api','NOTICE')
);

$this->verbose_errortype = array (
E_PHP5_ERROR => PFLanguage::getInstance()->getTranslation('api','ERROR'),
E_UNKNOWN_ERROR => PFLanguage::getInstance()->getTranslation('api','UNKNOWN_ERROR'),
E_INSUFFICIENT_DATA => PFLanguage::getInstance()->getTranslation('api','INSUFFICIENT_DATA'),
E_ERROR => PFLanguage::getInstance()->getTranslation('api','ERROR'),
E_WARNING => PFLanguage::getInstance()->getTranslation('api','WARNING'),
E_PARSE => PFLanguage::getInstance()->getTranslation('api','PARSING_ERROR'),
E_NOTICE => PFLanguage::getInstance()->getTranslation('api','NOTICE'),
E_CORE_ERROR => PFLanguage::getInstance()->getTranslation('api','CORE_ERROR'),
E_CORE_WARNING => PFLanguage::getInstance()->getTranslation('api','CORE_WARNING'),
E_COMPILE_ERROR => PFLanguage::getInstance()->getTranslation('api','COMPILE_ERROR'),
E_COMPILE_WARNING => PFLanguage::getInstance()->getTranslation('api','COMPILE_WARNING'),
E_USER_FATAL => PFLanguage::getInstance()->getTranslation('api','USER_FATAL'),
E_USER_ERROR => PFLanguage::getInstance()->getTranslation('api','USER_ERROR'),
E_USER_WARNING => PFLanguage::getInstance()->getTranslation('api','USER_WARNING'),
E_USER_NOTICE => PFLanguage::getInstance()->getTranslation('api','USER_NOTICE'),
E_STRICT => PFLanguage::getInstance()->getTranslation('api','RUNTIME_NOTICE')
);
}
$this->errortype = array (
E_PHP5_ERROR => 'Error',
E_UNKNOWN_ERROR => 'Error',
E_INSUFFICIENT_DATA => 'Warning',
E_ERROR => 'Error',
E_WARNING => 'Warning',
E_PARSE => 'Error',
E_NOTICE => 'Warning',
E_CORE_ERROR => 'Error',
E_CORE_WARNING => 'Warning',
E_COMPILE_ERROR => 'Error',
E_COMPILE_WARNING => 'Warning',
E_USER_FATAL => 'Fatal',
E_USER_ERROR => 'Error',
E_USER_WARNING => 'Warning',
E_USER_NOTICE => 'Notice',
E_STRICT => 'Notice'
);

$this->verbose_errortype = array (
E_PHP5_ERROR => 'Error',
E_UNKNOWN_ERROR => 'Unknown Error',
E_INSUFFICIENT_DATA => 'Warning',
E_ERROR => 'Error',
E_WARNING => 'Warning',
E_PARSE => 'Parsing Error',
E_NOTICE => 'Notice',
E_CORE_ERROR => 'Core Error',
E_CORE_WARNING => 'Core Warning',
E_COMPILE_ERROR => 'Compile Error',
E_COMPILE_WARNING => 'Compile Warning',
E_USER_FATAL => 'User Fatal',
E_USER_ERROR => 'User Error',
E_USER_WARNING => 'User Warning',
E_USER_NOTICE => 'User Notice',
E_STRICT => 'Runtime Notice'
);
}

public function errorHandlerOverride($errno, $errmsg, $filename, $linenum) {
Expand Down
Loading

0 comments on commit 9c0526a

Please sign in to comment.