本文整理汇总了PHP中Piwik\Piwik::translate方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::translate方法的具体用法?PHP Piwik::translate怎么用?PHP Piwik::translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Piwik
的用法示例。
在下文中一共展示了Piwik::translate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
protected function init()
{
parent::init();
$this->reportsToMerge = $this->getReportsToMerge();
$this->module = 'API';
$this->action = 'get';
$this->categoryId = 'API';
$this->name = Piwik::translate('General_MainMetrics');
$this->documentation = '';
$this->processedMetrics = array();
foreach ($this->reportsToMerge as $report) {
if (!is_array($report->processedMetrics)) {
continue;
}
$this->processedMetrics = array_merge($this->processedMetrics, $report->processedMetrics);
}
$this->metrics = array();
foreach ($this->reportsToMerge as $report) {
if (!is_array($report->metrics)) {
continue;
}
$this->metrics = array_merge($this->metrics, $report->metrics);
}
$this->order = 6;
}
示例2: saveSettings
public function saveSettings()
{
Piwik::checkUserIsSuperUser();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$this->checkTokenInUrl();
switch (Common::getRequestVar('form')) {
case "formMaskLength":
$this->handlePluginState(Common::getRequestVar("anonymizeIPEnable", 0));
$trackerConfig = Config::getInstance()->Tracker;
$trackerConfig['ip_address_mask_length'] = Common::getRequestVar("maskLength", 1);
$trackerConfig['use_anonymized_ip_for_visit_enrichment'] = Common::getRequestVar("useAnonymizedIpForVisitEnrichment", 1);
Config::getInstance()->Tracker = $trackerConfig;
Config::getInstance()->forceSave();
break;
case "formDeleteSettings":
$this->checkDataPurgeAdminSettingsIsEnabled();
$settings = $this->getPurgeSettingsFromRequest();
PrivacyManager::savePurgeDataSettings($settings);
break;
default:
//do nothing
break;
}
}
$notification = new Notification(Piwik::translate('General_YourChangesHaveBeenSaved'));
$notification->context = Notification::CONTEXT_SUCCESS;
Notification\Manager::notify('PrivacyManager_ChangesHaveBeenSaved', $notification);
$this->redirectToIndex('PrivacyManager', 'privacySettings', null, null, null, array('updated' => 1));
}
示例3: footerUserCountry
public static function footerUserCountry(&$out)
{
$out = '<div>
<h2>' . Piwik::translate('Provider_WidgetProviders') . '</h2>';
$out .= FrontController::getInstance()->fetchDispatch('Provider', 'getProvider');
$out .= '</div>';
}
示例4: getAnnotationManager
/**
* Controller action that returns HTML displaying annotations for a site and
* specific date range.
*
* Query Param Input:
* - idSite: The ID of the site to get annotations for. Only one allowed.
* - date: The date to get annotations for. If lastN is not supplied, this is the start date,
* otherwise the start date in the last period.
* - period: The period type.
* - lastN: If supplied, the last N # of periods will be included w/ the range specified
* by date + period.
*
* Output:
* - HTML displaying annotations for a specific range.
*
* @param bool $fetch True if the annotation manager should be returned as a string,
* false if it should be echo-ed.
* @param bool|string $date Override for 'date' query parameter.
* @param bool|string $period Override for 'period' query parameter.
* @param bool|string $lastN Override for 'lastN' query parameter.
* @return string|void
*/
public function getAnnotationManager($fetch = false, $date = false, $period = false, $lastN = false)
{
$idSite = Common::getRequestVar('idSite');
if ($date === false) {
$date = Common::getRequestVar('date', false);
}
if ($period === false) {
$period = Common::getRequestVar('period', 'day');
}
if ($lastN === false) {
$lastN = Common::getRequestVar('lastN', false);
}
// create & render the view
$view = new View('@Annotations/getAnnotationManager');
$allAnnotations = Request::processRequest('Annotations.getAll', array('date' => $date, 'period' => $period, 'lastN' => $lastN));
$view->annotations = empty($allAnnotations[$idSite]) ? array() : $allAnnotations[$idSite];
$view->period = $period;
$view->lastN = $lastN;
list($startDate, $endDate) = API::getDateRangeForPeriod($date, $period, $lastN);
$view->startDate = $startDate->toString();
$view->endDate = $endDate->toString();
if ($startDate->toString() !== $endDate->toString()) {
$view->selectedDate = Date::today()->toString();
} else {
$view->selectedDate = $endDate->toString();
}
$dateFormat = Piwik::translate('CoreHome_ShortDateFormatWithYear');
$view->startDatePretty = $startDate->getLocalized($dateFormat);
$view->endDatePretty = $endDate->getLocalized($dateFormat);
$view->canUserAddNotes = AnnotationList::canUserAddNotesFor($idSite);
return $view->render();
}
示例5: configureAdminMenu
public function configureAdminMenu(MenuAdmin $menu)
{
$hasSuperUserAcess = Piwik::hasUserSuperUserAccess();
$isAnonymous = Piwik::isUserIsAnonymous();
$isMarketplaceEnabled = CorePluginsAdmin::isMarketplaceEnabled();
$pluginsUpdateMessage = '';
$themesUpdateMessage = '';
if ($hasSuperUserAcess && $isMarketplaceEnabled) {
$marketplace = new Marketplace();
$pluginsHavingUpdate = $marketplace->getPluginsHavingUpdate($themesOnly = false);
$themesHavingUpdate = $marketplace->getPluginsHavingUpdate($themesOnly = true);
if (!empty($pluginsHavingUpdate)) {
$pluginsUpdateMessage = sprintf(' (%d)', count($pluginsHavingUpdate));
}
if (!empty($themesHavingUpdate)) {
$themesUpdateMessage = sprintf(' (%d)', count($themesHavingUpdate));
}
}
if (!$isAnonymous) {
$menu->addPlatformItem(null, "", $order = 7);
}
if ($hasSuperUserAcess) {
$menu->addPlatformItem(Piwik::translate('General_Plugins') . $pluginsUpdateMessage, $this->urlForAction('plugins', array('activated' => '')), $order = 1);
$menu->addPlatformItem(Piwik::translate('CorePluginsAdmin_Themes') . $themesUpdateMessage, $this->urlForAction('themes', array('activated' => '')), $order = 3);
}
if ($this->isAllowedToSeeMarketPlace()) {
$menu->addPlatformItem('CorePluginsAdmin_Marketplace', $this->urlForAction('extend', array('activated' => '')), $order = 5);
}
}
示例6: configureUserMenu
public function configureUserMenu(MenuUser $menu)
{
$tooltip = Piwik::translate('Widgetize_TopLinkTooltip');
$urlParams = array('module' => 'Widgetize', 'action' => 'index', 'segment' => false);
$menu->add('CorePluginsAdmin_MenuPlatform', null, $urlParams, true, 50, $tooltip);
$menu->add('CorePluginsAdmin_MenuPlatform', 'General_Widgets', $urlParams, true, 5, $tooltip);
}
示例7: init
protected function init()
{
parent::init();
$this->dimension = new EventAction();
$this->name = Piwik::translate('Events_EventActions');
$this->isSubtableReport = true;
}
示例8: getMetrics
public function getMetrics()
{
$metrics = parent::getMetrics();
$metrics['avg_time_on_site'] = Piwik::translate('General_VisitDuration');
$metrics['max_actions'] = Piwik::translate('General_ColumnMaxActions');
return $metrics;
}
示例9: setGetAllHtmlPrefix
/**
* DataTable filter callback that returns the HTML prefix for a label in the
* 'getAll' report based on the row's referrer type.
*
* @param int $referrerType The referrer type.
* @return string
*/
public function setGetAllHtmlPrefix($referrerType)
{
// get singular label for referrer type
$indexTranslation = '';
switch ($referrerType) {
case Common::REFERRER_TYPE_DIRECT_ENTRY:
$indexTranslation = 'Referrers_DirectEntry';
break;
case Common::REFERRER_TYPE_SEARCH_ENGINE:
$indexTranslation = 'General_ColumnKeyword';
break;
case Common::REFERRER_TYPE_WEBSITE:
$indexTranslation = 'Referrers_ColumnWebsite';
break;
case Common::REFERRER_TYPE_CAMPAIGN:
$indexTranslation = 'Referrers_ColumnCampaign';
break;
default:
// case of newsletter, partners, before Piwik 0.2.25
$indexTranslation = 'General_Others';
break;
}
$label = strtolower(Piwik::translate($indexTranslation));
// return html that displays it as grey & italic
return '<span class="datatable-label-category"><em>(' . $label . ')</em></span>';
}
示例10: configureAdminMenu
public function configureAdminMenu(MenuAdmin $menu)
{
$hasSuperUserAcess = Piwik::hasUserSuperUserAccess();
$isAnonymous = Piwik::isUserIsAnonymous();
$isMarketplaceEnabled = CorePluginsAdmin::isMarketplaceEnabled();
$pluginsUpdateMessage = '';
$themesUpdateMessage = '';
if ($hasSuperUserAcess && $isMarketplaceEnabled) {
$marketplace = new Marketplace();
$pluginsHavingUpdate = $marketplace->getPluginsHavingUpdate($themesOnly = false);
$themesHavingUpdate = $marketplace->getPluginsHavingUpdate($themesOnly = true);
if (!empty($pluginsHavingUpdate)) {
$pluginsUpdateMessage = sprintf(' (%d)', count($pluginsHavingUpdate));
}
if (!empty($themesHavingUpdate)) {
$themesUpdateMessage = sprintf(' (%d)', count($themesHavingUpdate));
}
}
$menu->add('CorePluginsAdmin_MenuPlatform', null, "", !$isAnonymous, $order = 7);
$menu->add('CorePluginsAdmin_MenuPlatform', Piwik::translate('General_Plugins') . $pluginsUpdateMessage, array('module' => 'CorePluginsAdmin', 'action' => 'plugins', 'activated' => ''), $hasSuperUserAcess, $order = 1);
$menu->add('CorePluginsAdmin_MenuPlatform', Piwik::translate('CorePluginsAdmin_Themes') . $themesUpdateMessage, array('module' => 'CorePluginsAdmin', 'action' => 'themes', 'activated' => ''), $hasSuperUserAcess, $order = 3);
if ($isMarketplaceEnabled) {
$menu->add('CorePluginsAdmin_MenuPlatform', 'CorePluginsAdmin_Marketplace', array('module' => 'CorePluginsAdmin', 'action' => 'extend', 'activated' => ''), !$isAnonymous, $order = 5);
}
}
示例11: init
function init()
{
HTML_QuickForm2_Factory::registerRule('checkValidFilename', 'Piwik\\Plugins\\Installation\\FormDatabaseSetup_Rule_checkValidFilename');
$checkUserPrivilegesClass = 'Piwik\\Plugins\\Installation\\Rule_checkUserPrivileges';
HTML_QuickForm2_Factory::registerRule('checkUserPrivileges', $checkUserPrivilegesClass);
$availableAdapters = Adapter::getAdapters();
$adapters = array();
foreach ($availableAdapters as $adapter => $port) {
$adapters[$adapter] = $adapter;
}
$types = array('InnoDB' => 'InnoDB');
$this->addElement('text', 'host')->setLabel(Piwik::translate('Installation_DatabaseSetupServer'))->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_DatabaseSetupServer')));
$user = $this->addElement('text', 'username')->setLabel(Piwik::translate('Installation_DatabaseSetupLogin'));
$user->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_DatabaseSetupLogin')));
$requiredPrivileges = Rule_checkUserPrivileges::getRequiredPrivilegesPretty();
$user->addRule('checkUserPrivileges', Piwik::translate('Installation_InsufficientPrivilegesMain', $requiredPrivileges . '<br/><br/>') . Piwik::translate('Installation_InsufficientPrivilegesHelp'));
$this->addElement('password', 'password')->setLabel(Piwik::translate('General_Password'));
$item = $this->addElement('text', 'dbname')->setLabel(Piwik::translate('Installation_DatabaseSetupDatabaseName'));
$item->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_DatabaseSetupDatabaseName')));
$item->addRule('checkValidFilename', Piwik::translate('General_NotValid', Piwik::translate('Installation_DatabaseSetupDatabaseName')));
$this->addElement('text', 'tables_prefix')->setLabel(Piwik::translate('Installation_DatabaseSetupTablePrefix'))->addRule('checkValidFilename', Piwik::translate('General_NotValid', Piwik::translate('Installation_DatabaseSetupTablePrefix')));
$this->addElement('select', 'adapter')->setLabel(Piwik::translate('Installation_DatabaseSetupAdapter'))->loadOptions($adapters)->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_DatabaseSetupAdapter')));
$this->addElement('select', 'type')->setLabel(Piwik::translate('Installation_DatabaseSetupDatabaseEngine'))->loadOptions($types)->addRule('required', Piwik::translate('General_Required', Piwik::translate('Installation_DatabaseSetupDatabaseEngine')));
$this->addElement('submit', 'submit', array('value' => Piwik::translate('General_Next') . ' »', 'class' => 'submit'));
// default values
$this->addDataSource(new HTML_QuickForm2_DataSource_Array(array('host' => '127.0.0.1', 'tables_prefix' => 'piwik_')));
}
示例12: getProvider
public function getProvider()
{
if (isset($this->details['location_provider'])) {
return $this->details['location_provider'];
}
return Piwik::translate('General_Unknown');
}
示例13: getCategory
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return array
* @throws \RuntimeException
*/
protected function getCategory(InputInterface $input, OutputInterface $output)
{
$validate = function ($category) {
if (empty($category)) {
throw new \InvalidArgumentException('Please enter the name of the category your widget should belong to');
}
return $category;
};
$category = $input->getOption('category');
$categories = array();
foreach (Widgets::getAllWidgets() as $widget) {
if ($widget->getCategory()) {
$categories[] = Piwik::translate($widget->getCategory());
}
}
$categories = array_values(array_unique($categories));
if (empty($category)) {
$dialog = $this->getHelperSet()->get('dialog');
$category = $dialog->askAndValidate($output, 'Enter the widget category, for instance "Visitor" (you can reuse any existing category or define a new one): ', $validate, false, null, $categories);
} else {
$validate($category);
}
$translationKey = Translate::findTranslationKeyForTranslation($category);
if (!empty($translationKey)) {
return $translationKey;
}
$category = ucfirst($category);
return $category;
}
示例14: index
public function index()
{
Piwik::checkUserIsNotAnonymous();
$view = new View('@MobileMessaging/index');
$view->isSuperUser = Piwik::hasUserSuperUserAccess();
$mobileMessagingAPI = API::getInstance();
$view->delegatedManagement = $mobileMessagingAPI->getDelegatedManagement();
$view->credentialSupplied = $mobileMessagingAPI->areSMSAPICredentialProvided();
$view->accountManagedByCurrentUser = $view->isSuperUser || $view->delegatedManagement;
$view->strHelpAddPhone = Piwik::translate('MobileMessaging_Settings_PhoneNumbers_HelpAdd', array(Piwik::translate('General_Settings'), Piwik::translate('MobileMessaging_SettingsMenu')));
if ($view->credentialSupplied && $view->accountManagedByCurrentUser) {
$view->provider = $mobileMessagingAPI->getSMSProvider();
$view->creditLeft = $mobileMessagingAPI->getCreditLeft();
}
$view->smsProviders = SMSProvider::$availableSMSProviders;
// construct the list of countries from the lang files
$countries = array();
foreach (Common::getCountriesList() as $countryCode => $continentCode) {
if (isset(CountryCallingCodes::$countryCallingCodes[$countryCode])) {
$countries[$countryCode] = array('countryName' => \Piwik\Plugins\UserCountry\countryTranslate($countryCode), 'countryCallingCode' => CountryCallingCodes::$countryCallingCodes[$countryCode]);
}
}
$view->countries = $countries;
$view->defaultCountry = Common::getCountry(LanguagesManager::getLanguageCodeForCurrentUser(), true, IP::getIpFromHeader());
$view->phoneNumbers = $mobileMessagingAPI->getPhoneNumbers();
$this->setBasicVariablesView($view);
return $view->render();
}
示例15: configureSegmentsFor
protected function configureSegmentsFor($segmentNameSuffix)
{
$numCustomVariables = CustomVariables::getNumUsableCustomVariables();
$segment = new Segment();
$segment->setType('dimension');
$segment->setSegment('customVariable' . $segmentNameSuffix);
$segment->setName($this->getName() . ' (' . Piwik::translate('CustomVariables_ScopeVisit') . ')');
$segment->setUnionOfSegments($this->getSegmentColumns('customVariable' . $segmentNameSuffix, $numCustomVariables));
$this->addSegment($segment);
$segment = new Segment();
$segment->setType('dimension');
$segment->setSegment('customVariablePage' . $segmentNameSuffix);
$segment->setName($this->getName() . ' (' . Piwik::translate('CustomVariables_ScopePage') . ')');
$segment->setUnionOfSegments($this->getSegmentColumns('customVariablePage' . $segmentNameSuffix, $numCustomVariables));
$this->addSegment($segment);
$segmentSuffix = 'v';
if (strtolower($segmentNameSuffix) === 'name') {
$segmentSuffix = 'k';
}
for ($i = 1; $i <= $numCustomVariables; $i++) {
$segment = new Segment();
$segment->setSegment('customVariable' . $segmentNameSuffix . $i);
$segment->setSqlSegment('log_visit.custom_var_' . $segmentSuffix . $i);
$segment->setName(Piwik::translate('CustomVariables_ColumnCustomVariable' . $segmentNameSuffix) . ' ' . $i . ' (' . Piwik::translate('CustomVariables_ScopeVisit') . ')');
$this->addSegment($segment);
$segment = new Segment();
$segment->setSegment('customVariablePage' . $segmentNameSuffix . $i);
$segment->setSqlSegment('log_link_visit_action.custom_var_' . $segmentSuffix . $i);
$segment->setName(Piwik::translate('CustomVariables_ColumnCustomVariable' . $segmentNameSuffix) . ' ' . $i . ' (' . Piwik::translate('CustomVariables_ScopePage') . ')');
$this->addSegment($segment);
}
}