本文整理汇总了PHP中Piwik\Translate::loadEnglishTranslation方法的典型用法代码示例。如果您正苦于以下问题:PHP Translate::loadEnglishTranslation方法的具体用法?PHP Translate::loadEnglishTranslation怎么用?PHP Translate::loadEnglishTranslation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Translate
的用法示例。
在下文中一共展示了Translate::loadEnglishTranslation方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetPrettyString
/**
* @group Core
*/
public function testGetPrettyString()
{
Translate::loadEnglishTranslation();
$year = new Year(Date::factory('2024-10-09'));
$shouldBe = '2024';
$this->assertEquals($shouldBe, $year->getPrettyString());
}
示例2: setUp
public function setUp()
{
parent::setUp();
$this->addNonLdapUsers();
$this->addPreexistingLdapUser();
$plugins = Config::getInstance()->Plugins;
$plugins['Plugins'][] = 'LoginLdap';
Config::getInstance()->Plugins = $plugins;
$application = new Console(self::$fixture->piwikEnvironment);
$application->setAutoExit(false);
$this->applicationTester = new ApplicationTester($application);
Translate::loadEnglishTranslation();
// needed due to travis build that tests against minimum required piwik
}
示例3: setUp
public function setUp()
{
parent::setUp();
$config = Config::getInstance();
$config->clear();
$config->setTestEnvironment();
$section = Config::getInstance()->Tracker;
$section['default_action_url'] = '/';
$section['campaign_var_name'] = 'campaign_param_name,piwik_campaign,utm_campaign,test_campaign_name';
$section['action_url_category_delimiter'] = '/';
$section['campaign_keyword_var_name'] = 'piwik_kwd,utm_term,test_piwik_kwd';
Config::getInstance()->Tracker = $section;
PluginManager::getInstance()->loadPlugins(array('SitesManager'));
Translate::loadEnglishTranslation();
}
示例4: runScheduledTasks
/**
* Tracker requests will automatically trigger the Scheduled tasks.
* This is useful for users who don't setup the cron,
* but still want daily/weekly/monthly PDF reports emailed automatically.
*
* This is similar to calling the API CoreAdminHome.runScheduledTasks
*/
protected static function runScheduledTasks()
{
$now = time();
// Currently, there are no hourly tasks. When there are some,
// this could be too aggressive minimum interval (some hours would be skipped in case of low traffic)
$minimumInterval = Config::getInstance()->Tracker['scheduled_tasks_min_interval'];
// If the user disabled browser archiving, he has already setup a cron
// To avoid parallel requests triggering the Scheduled Tasks,
// Get last time tasks started executing
$cache = Cache::getCacheGeneral();
if ($minimumInterval <= 0 || empty($cache['isBrowserTriggerEnabled'])) {
Common::printDebug("-> Scheduled tasks not running in Tracker: Browser archiving is disabled.");
return;
}
$nextRunTime = $cache['lastTrackerCronRun'] + $minimumInterval;
if (isset($GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS']) && $GLOBALS['PIWIK_TRACKER_DEBUG_FORCE_SCHEDULED_TASKS'] || $cache['lastTrackerCronRun'] === false || $nextRunTime < $now) {
$cache['lastTrackerCronRun'] = $now;
Cache::setCacheGeneral($cache);
self::initCorePiwikInTrackerMode();
Option::set('lastTrackerCronRun', $cache['lastTrackerCronRun']);
Common::printDebug('-> Scheduled Tasks: Starting...');
// save current user privilege and temporarily assume Super User privilege
$isSuperUser = Piwik::hasUserSuperUserAccess();
// Scheduled tasks assume Super User is running
Piwik::setUserHasSuperUserAccess();
// While each plugins should ensure that necessary languages are loaded,
// we ensure English translations at least are loaded
Translate::loadEnglishTranslation();
ob_start();
CronArchive::$url = SettingsPiwik::getPiwikUrl();
$cronArchive = new CronArchive();
$cronArchive->runScheduledTasksInTrackerMode();
$resultTasks = ob_get_contents();
ob_clean();
// restore original user privilege
Piwik::setUserHasSuperUserAccess($isSuperUser);
foreach (explode('</pre>', $resultTasks) as $resultTask) {
Common::printDebug(str_replace('<pre>', '', $resultTask));
}
Common::printDebug('Finished Scheduled Tasks.');
} else {
Common::printDebug("-> Scheduled tasks not triggered.");
}
Common::printDebug("Next run will be from: " . date('Y-m-d H:i:s', $nextRunTime) . ' UTC');
}
示例5: testIsDefined
/**
* @group Core
*/
public function testIsDefined()
{
// setup the access layer
$pseudoMockAccess = new FakeAccess();
FakeAccess::$superUser = true;
Access::setSingletonInstance($pseudoMockAccess);
\Piwik\Translate::loadEnglishTranslation();
Fixture::createWebsite('2009-01-04 00:11:42', true);
$_GET['idSite'] = 1;
WidgetsList::_reset();
WidgetsList::add('Actions', 'Pages', 'Actions', 'getPageUrls');
$this->assertTrue(WidgetsList::isDefined('Actions', 'getPageUrls'));
$this->assertFalse(WidgetsList::isDefined('Actions', 'inValiD'));
}
示例6: testGetPrettyValue
/**
* @dataProvider getGetPrettyValueTestCases
*/
public function testGetPrettyValue($columnName, $value, $expected)
{
Translate::loadEnglishTranslation();
$access = Access::getInstance();
$access->setSuperUserAccess(true);
$idsite = API::getInstance()->addSite("test", "http://test");
$this->assertEquals($expected, MetricsFormatter::getPrettyValue($idsite, $columnName, $value, false, false));
Translate::unloadEnglishTranslation();
}
示例7: init
/**
* Must be called before dispatch()
* - checks that directories are writable,
* - loads the configuration file,
* - loads the plugin,
* - inits the DB connection,
* - etc.
*
* @throws Exception
* @return void
*/
public function init()
{
static $initialized = false;
if ($initialized) {
return;
}
$initialized = true;
try {
Registry::set('timer', new Timer());
$directoriesToCheck = array('/tmp/', '/tmp/assets/', '/tmp/cache/', '/tmp/logs/', '/tmp/tcpdf/', '/tmp/templates_c/');
Filechecks::dieIfDirectoriesNotWritable($directoriesToCheck);
Translate::loadEnglishTranslation();
$exceptionToThrow = self::createConfigObject();
$this->handleMaintenanceMode();
$this->handleProfiler();
$this->handleSSLRedirection();
Plugin\Manager::getInstance()->loadPluginTranslations('en');
Plugin\Manager::getInstance()->loadActivatedPlugins();
if ($exceptionToThrow) {
throw $exceptionToThrow;
}
// try to connect to the database
try {
Db::createDatabaseObject();
Db::fetchAll("SELECT DATABASE()");
} catch (Exception $exception) {
if (self::shouldRethrowException()) {
throw $exception;
}
Log::debug($exception);
/**
* Triggered when Piwik cannot connect to the database.
*
* This event can be used to start the installation process or to display a custom error
* message.
*
* @param Exception $exception The exception thrown from creating and testing the database
* connection.
*/
Piwik::postEvent('Db.cannotConnectToDb', array($exception), $pending = true);
throw $exception;
}
// try to get an option (to check if data can be queried)
try {
Option::get('TestingIfDatabaseConnectionWorked');
} catch (Exception $exception) {
if (self::shouldRethrowException()) {
throw $exception;
}
Log::debug($exception);
/**
* Triggered when Piwik cannot access database data.
*
* This event can be used to start the installation process or to display a custom error
* message.
*
* @param Exception $exception The exception thrown from trying to get an option value.
*/
Piwik::postEvent('Config.badConfigurationFile', array($exception), $pending = true);
throw $exception;
}
// Init the Access object, so that eg. core/Updates/* can enforce Super User and use some APIs
Access::getInstance();
/**
* Triggered just after the platform is initialized and plugins are loaded.
*
* This event can be used to do early initialization.
*
* _Note: At this point the user is not authenticated yet._
*/
Piwik::postEvent('Request.dispatchCoreAndPluginUpdatesScreen');
\Piwik\Plugin\Manager::getInstance()->installLoadedPlugins();
// ensure the current Piwik URL is known for later use
if (method_exists('Piwik\\SettingsPiwik', 'getPiwikUrl')) {
SettingsPiwik::getPiwikUrl();
}
/**
* Triggered before the user is authenticated, when the global authentication object
* should be created.
*
* Plugins that provide their own authentication implementation should use this event
* to set the global authentication object (which must derive from {@link Piwik\Auth}).
*
* **Example**
*
* Piwik::addAction('Request.initAuthenticationObject', function() {
* Piwik\Registry::set('auth', new MyAuthImplementation());
* });
*/
//.........这里部分代码省略.........
示例8: testGetPrettyString
/**
* @group Core
*/
public function testGetPrettyString()
{
Translate::loadEnglishTranslation();
$week = new Week(Date::factory('2024-10-09'));
$shouldBe = 'From 2024-10-07 to 2024-10-13';
$this->assertEquals($shouldBe, $week->getPrettyString());
}
示例9: testGetPrettyString
/**
* @group Core
*/
public function testGetPrettyString()
{
Translate::loadEnglishTranslation();
$month = new Range('range', '2007-02-09,2007-03-15');
$shouldBe = 'From 2007-02-09 to 2007-03-15';
$this->assertEquals($shouldBe, $month->getPrettyString());
}
示例10: setUp
public function setUp()
{
Translate::loadEnglishTranslation();
}