/** * Test that the '' domain causes exceptions. * * @expectedException \Cake\Error\Exception * @return void */ public function testTranslateEmptyDomain() { I18n::translate('Plural Rule 1', null, ''); }
//@codingStandardsIgnoreStart @mkdir(LOGS); @mkdir(SESSIONS); @mkdir(CACHE); @mkdir(CACHE . 'views'); @mkdir(CACHE . 'models'); //@codingStandardsIgnoreEnd require CAKE . 'Core/ClassLoader.php'; $loader = new Cake\Core\ClassLoader(); $loader->register(); $loader->addNamespace('TestApp', APP); $loader->addNamespace('TestPlugin', TEST_APP . 'Plugin/TestPlugin'); $loader->addNamespace('TestPluginTwo', TEST_APP . 'Plugin/TestPluginTwo'); $loader->addNamespace('PluginJs', TEST_APP . 'Plugin/PluginJs'); require CAKE . 'bootstrap.php'; date_default_timezone_set('UTC'); mb_internal_encoding('UTF-8'); Configure::write('debug', true); Configure::write('App', ['namespace' => 'App', 'encoding' => 'UTF-8', 'base' => false, 'baseUrl' => false, 'dir' => APP_DIR, 'webroot' => WEBROOT_DIR, 'www_root' => WWW_ROOT, 'fullBaseUrl' => 'http://localhost', 'imageBaseUrl' => 'img/', 'jsBaseUrl' => 'js/', 'cssBaseUrl' => 'css/', 'paths' => ['plugins' => [TEST_APP . 'Plugin' . DS], 'templates' => [APP . 'Template' . DS]]]); Cache::config(['_cake_core_' => ['engine' => 'File', 'prefix' => 'cake_core_', 'serialize' => true], '_cake_model_' => ['engine' => 'File', 'prefix' => 'cake_model_', 'serialize' => true]]); // Ensure default test connection is defined if (!getenv('db_class')) { putenv('db_class=Cake\\Database\\Driver\\Sqlite'); putenv('db_dsn=sqlite::memory:'); } ConnectionManager::config('test', ['className' => 'Cake\\Database\\Connection', 'driver' => getenv('db_class'), 'dsn' => getenv('db_dsn'), 'database' => getenv('db_database'), 'login' => getenv('db_login'), 'password' => getenv('db_password'), 'timezone' => 'UTC']); Configure::write('Session', ['defaults' => 'php']); Log::config(['debug' => ['engine' => 'Cake\\Log\\Engine\\FileLog', 'levels' => ['notice', 'info', 'debug'], 'file' => 'debug'], 'error' => ['engine' => 'Cake\\Log\\Engine\\FileLog', 'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'], 'file' => 'error']]); // Initialize the empty language. I18n::translate('empty'); Carbon\Carbon::setTestNow(Carbon\Carbon::now());
/** * The category argument allows a specific category of the locale settings to be used for fetching a message. * Valid categories are: LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES and LC_ALL. * * Note that the category must be specified with a class constant of I18n, instead of the constant name. The values are: * * - LC_ALL I18n::LC_ALL * - LC_COLLATE I18n::LC_COLLATE * - LC_CTYPE I18n::LC_CTYPE * - LC_MONETARY I18n::LC_MONETARY * - LC_NUMERIC I18n::LC_NUMERIC * - LC_TIME I18n::LC_TIME * - LC_MESSAGES I18n::LC_MESSAGES * * @param string $msg String to translate * @param int $category Category * @param mixed $args Array with arguments or multiple arguments in function * @return string translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__c */ function __c($msg, $category, $args = null) { if (!$msg) { return; } $translated = I18n::translate($msg, null, null, $category); if ($args === null) { return $translated; } elseif (!is_array($args)) { $args = array_slice(func_get_args(), 2); } $translated = preg_replace('/(?<!%)%(?![%\'\\-+bcdeEfFgGosuxX\\d\\.])/', '%%', $translated); return vsprintf($translated, $args); }