php Piwik-Translation-Translator类(方法)实例源码

下面列出了php Piwik-Translation-Translator 类(方法)源码代码实例,从而了解它的用法。

作者:mgou-ne    项目:piwi   
public function test_addDirectory_shouldImportOverExistingTranslations()
 {
     $translator = new Translator(new JsonFileLoader(), array(__DIR__ . '/Loader/fixtures/dir1'));
     $this->assertEquals('Hello', $translator->translate('General_test2'));
     $translator->addDirectory(__DIR__ . '/Loader/fixtures/dir2');
     $this->assertEquals('Hello 2', $translator->translate('General_test2'));
 }

作者:cem    项目:piwi   
/**
  * Loads all required data from Intl plugin
  *
  * TODO: instead of going directly through Translator, there should be a specific class
  * that gets needed characters (ie, NumberFormatSource). The default implementation
  * can use the Translator. This will make it easier to unit test NumberFormatter,
  * w/o needing the Piwik Environment.
  *
  * @return NumberFormatter
  */
 public function __construct(Translator $translator)
 {
     $this->patternNumber = $translator->translate('Intl_NumberFormatNumber');
     $this->patternCurrency = $translator->translate('Intl_NumberFormatCurrency');
     $this->patternPercent = $translator->translate('Intl_NumberFormatPercent');
     $this->symbolPlus = $translator->translate('Intl_NumberSymbolPlus');
     $this->symbolMinus = $translator->translate('Intl_NumberSymbolMinus');
     $this->symbolPercent = $translator->translate('Intl_NumberSymbolPercent');
     $this->symbolGroup = $translator->translate('Intl_NumberSymbolGroup');
     $this->symbolDecimal = $translator->translate('Intl_NumberSymbolDecimal');
 }

作者:piwi    项目:piwi   
public function getSparklines()
 {
     $idGoal = Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER;
     $view = new View('@Ecommerce/getSparklines');
     $view->onlyConversionOverview = false;
     $view->conversionsOverViewEnabled = true;
     if ($idGoal == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER) {
         $goalDefinition['name'] = $this->translator->translate('Goals_Ecommerce');
         $goalDefinition['allow_multiple'] = true;
     } else {
         $goals = GoalsApi::getInstance()->getGoals($this->idSite);
         if (!isset($goals[$idGoal])) {
             Piwik::redirectToModule('Goals', 'index', array('idGoal' => null));
         }
         $goalDefinition = $goals[$idGoal];
     }
     $this->setGeneralVariablesView($view);
     $goal = $this->getMetricsForGoal($idGoal);
     foreach ($goal as $name => $value) {
         $view->{$name} = $value;
     }
     if ($idGoal == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER) {
         $goal = $this->getMetricsForGoal(Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART);
         foreach ($goal as $name => $value) {
             $name = 'cart_' . $name;
             $view->{$name} = $value;
         }
     }
     $view->idGoal = $idGoal;
     $view->goalAllowMultipleConversionsPerVisit = $goalDefinition['allow_multiple'];
     return $view->render();
 }

作者:Govanif    项目:piwi   
private function getLongErrorMessage()
    {
        $message = '<p>';

        if (SettingsServer::isWindows()) {
            $message .= $this->translator->translate(
                'Installation_SystemCheckWinPdoAndMysqliHelp',
                array('<br /><br /><code>extension=php_mysqli.dll</code><br /><code>extension=php_pdo.dll</code><br /><code>extension=php_pdo_mysql.dll</code><br />')
            );
        } else {
            $message .= $this->translator->translate(
                'Installation_SystemCheckPdoAndMysqliHelp',
                array(
                    '<br /><br /><code>--with-mysqli</code><br /><code>--with-pdo-mysql</code><br /><br />',
                    '<br /><br /><code>extension=mysqli.so</code><br /><code>extension=pdo.so</code><br /><code>extension=pdo_mysql.so</code><br />'
                )
            );
        }

        $message .= $this->translator->translate('Installation_RestartWebServer') . '<br/><br/>';
        $message .= $this->translator->translate('Installation_SystemCheckPhpPdoAndMysqli', array(
            '<a style="color:red" href="http://php.net/pdo">',
            '</a>',
            '<a style="color:red" href="http://php.net/mysqli">',
            '</a>',
        ));
        $message .= '</p>';

        return $message;
    }

作者:FluentDevelopmen    项目:piwi   
public function execute()
 {
     $isPiwikInstalling = !Config::getInstance()->existsLocalConfig();
     if ($isPiwikInstalling) {
         // Skip the diagnostic if Piwik is being installed
         return array();
     }
     $label = $this->translator->translate('Installation_DatabaseAbilities');
     $optionTable = Common::prefixTable('option');
     $testOptionNames = array('test_system_check1', 'test_system_check2');
     $loadDataInfile = false;
     $errorMessage = null;
     try {
         $loadDataInfile = Db\BatchInsert::tableInsertBatch($optionTable, array('option_name', 'option_value'), array(array($testOptionNames[0], '1'), array($testOptionNames[1], '2')), $throwException = true);
     } catch (\Exception $ex) {
         $errorMessage = str_replace("\n", "<br/>", $ex->getMessage());
     }
     // delete the temporary rows that were created
     Db::exec("DELETE FROM `{$optionTable}` WHERE option_name IN ('" . implode("','", $testOptionNames) . "')");
     if ($loadDataInfile) {
         return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK, 'LOAD DATA INFILE'));
     }
     $comment = sprintf('LOAD DATA INFILE<br/>%s<br/>%s', $this->translator->translate('Installation_LoadDataInfileUnavailableHelp', array('LOAD DATA INFILE', 'FILE')), $this->translator->translate('Installation_LoadDataInfileRecommended'));
     if ($errorMessage) {
         $comment .= sprintf('<br/><strong>%s:</strong> %s<br/>%s', $this->translator->translate('General_Error'), $errorMessage, 'Troubleshooting: <a target="_blank" href="?module=Proxy&action=redirect&url=http://piwik.org/faq/troubleshooting/%23faq_194">FAQ on piwik.org</a>');
     }
     return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
 }

作者:FluentDevelopmen    项目:piwi   
public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckWriteDirs');
     $result = new DiagnosticResult($label);
     $directories = Filechecks::checkDirectoriesWritable($this->getDirectories());
     $error = false;
     foreach ($directories as $directory => $isWritable) {
         if ($isWritable) {
             $status = DiagnosticResult::STATUS_OK;
         } else {
             $status = DiagnosticResult::STATUS_ERROR;
             $error = true;
         }
         $result->addItem(new DiagnosticResultItem($status, $directory));
     }
     if ($error) {
         $longErrorMessage = $this->translator->translate('Installation_SystemCheckWriteDirsHelp');
         $longErrorMessage .= '<ul>';
         foreach ($directories as $directory => $isWritable) {
             if (!$isWritable) {
                 $longErrorMessage .= sprintf('<li><pre>chmod a+w %s</pre></li>', $directory);
             }
         }
         $longErrorMessage .= '</ul>';
         $result->setLongErrorMessage($longErrorMessage);
     }
     return array($result);
 }

作者:CaptainShar    项目:SSAD_Projec   
private function setManageVariables(View $view)
 {
     $view->isSuperUser = Piwik::hasUserSuperUserAccess();
     $mobileMessagingAPI = API::getInstance();
     $view->delegatedManagement = $mobileMessagingAPI->getDelegatedManagement();
     $view->credentialSupplied = $mobileMessagingAPI->areSMSAPICredentialProvided();
     $view->accountManagedByCurrentUser = $view->isSuperUser || $view->delegatedManagement;
     $view->strHelpAddPhone = $this->translator->translate('MobileMessaging_Settings_PhoneNumbers_HelpAdd', array($this->translator->translate('General_Settings'), $this->translator->translate('MobileMessaging_SettingsMenu')));
     $view->creditLeft = 0;
     $view->provider = '';
     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 ($this->regionDataProvider->getCountryList() 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);
 }

作者:Govanif    项目:piwi   
public function execute()
    {
        $label = $this->translator->translate('Installation_SystemCheckSettings');

        $result = new DiagnosticResult($label);

        foreach ($this->getRequiredSettings() as $setting) {
            list($settingName, $requiredValue) = explode('=', $setting);

            $currentValue = (int) ini_get($settingName);

            if ($currentValue != $requiredValue) {
                $status = DiagnosticResult::STATUS_ERROR;
                $comment = sprintf(
                    '%s <br/><br/><em>%s</em><br/><em>%s</em><br/>',
                    $setting,
                    $this->translator->translate('Installation_SystemCheckPhpSetting', array($setting)),
                    $this->translator->translate('Installation_RestartWebServer')
                );
            } else {
                $status = DiagnosticResult::STATUS_OK;
                $comment = $setting;
            }

            $result->addItem(new DiagnosticResultItem($status, $comment));
        }

        return array($result);
    }

作者:diosmosi    项目:piwi   
/**
  * Renders and echo's HTML that displays the Piwik promo video.
  */
 public function getPromoVideo()
 {
     $view = new View('@CoreHome/getPromoVideo');
     $view->shareText = $this->translator->translate('CoreHome_SharePiwikShort');
     $view->shareTextLong = $this->translator->translate('CoreHome_SharePiwikLong');
     $view->promoVideoUrl = 'https://www.youtube.com/watch?v=OslfF_EH81g';
     return $view->render();
 }

作者:piwi    项目:piwi   
public function render()
 {
     $footerMessage = null;
     if (Common::getRequestVar('widget', false) && Piwik::hasUserSuperUserAccess()) {
         $footerMessage = $this->translator->translate('CoreHome_OnlyForSuperUserAccess');
     }
     return $this->renderTemplate('getDonateForm', array('footerMessage' => $footerMessage));
 }

作者:FluentDevelopmen    项目:piwi   
public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckGDFreeType');
     if (SettingsServer::isGdExtensionEnabled()) {
         return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK));
     }
     $comment = sprintf('%s<br />%s', $this->translator->translate('Installation_SystemCheckGDFreeType'), $this->translator->translate('Installation_SystemCheckGDHelp'));
     return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
 }

作者:FluentDevelopmen    项目:piwi   
public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckPageSpeedDisabled');
     if (!$this->isPageSpeedEnabled()) {
         return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK));
     }
     $comment = $this->translator->translate('Installation_SystemCheckPageSpeedWarn', array('(eg. Apache, Nginx or IIS)'));
     return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
 }

作者:FluentDevelopmen    项目:piwi   
public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckUpdateHttps');
     if (CoreUpdater\Controller::isUpdatingOverHttps()) {
         return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK));
     }
     $comment = $this->translator->translate('Installation_SystemCheckUpdateHttpsNotSupported');
     return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
 }

作者:bossrabbi    项目:piwi   
public function execute()
 {
     $label = $this->translator->translate('SitesManager_Timezone');
     if (SettingsServer::isTimezoneSupportEnabled()) {
         return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK));
     }
     $comment = sprintf('%s<br />%s.', $this->translator->translate('SitesManager_AdvancedTimezoneSupportNotFound'), '<a href="http://php.net/manual/en/datetime.installation.php" rel="noreferrer" target="_blank">Timezone PHP documentation</a>');
     return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
 }

作者:FluentDevelopmen    项目:piwi   
public function ecommerceReport()
 {
     if (!\Piwik\Plugin\Manager::getInstance()->isPluginActivated('CustomVariables')) {
         throw new Exception("Ecommerce Tracking requires that the plugin Custom Variables is enabled. Please enable the plugin CustomVariables (or ask your admin).");
     }
     $view = $this->getGoalReportView($idGoal = Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER);
     $view->displayFullReport = false;
     $view->headline = $this->translator->translate('General_EvolutionOverPeriod');
     return $view->render();
 }

作者:dorelljame    项目:piwi   
public function updatePiwik($https = true)
 {
     // Simulate that the update over HTTPS fails
     if ($https) {
         // The actual error message depends on the OS, the HTTP method etc.
         // This is what I get on my machine, but it doesn't really matter
         throw new ArchiveDownloadException(new \Exception('curl_exec: SSL certificate problem: Invalid certificate chain. Hostname requested was: piwik.org'), array());
     }
     // Simulate that the update over HTTP succeeds
     return array($this->translator->translate('CoreUpdater_DownloadingUpdateFromX', ''), $this->translator->translate('CoreUpdater_UnpackingTheUpdate'), $this->translator->translate('CoreUpdater_VerifyingUnpackedFiles'), $this->translator->translate('CoreUpdater_InstallingTheLatestVersion'));
 }

作者:bossrabbi    项目:piwi   
public function renderReportMenu(Report $report)
 {
     Piwik::checkUserHasSomeViewAccess();
     $this->checkSitePermission();
     $report->checkIsEnabled();
     $menuTitle = $report->getMenuTitle();
     if (empty($menuTitle)) {
         throw new Exception('This report is not supposed to be displayed in the menu, please define a $menuTitle in your report.');
     }
     $menuTitle = $this->translator->translate($menuTitle);
     $content = $this->renderReportWidget($report);
     return View::singleReport($menuTitle, $content);
 }

作者:bossrabbi    项目:piwi   
public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckTracker');
     $trackerStatus = Common::getRequestVar('trackerStatus', 0, 'int');
     if ($trackerStatus == 0) {
         $status = DiagnosticResult::STATUS_OK;
         $comment = '';
     } else {
         $status = DiagnosticResult::STATUS_WARNING;
         $comment = sprintf('%s<br />%s<br />%s', $trackerStatus, $this->translator->translate('Installation_SystemCheckTrackerHelp'), $this->translator->translate('Installation_RestartWebServer'));
     }
     return array(DiagnosticResult::singleResult($label, $status, $comment));
 }

作者:Govanif    项目:piwi   
private function getHelpMessage($missingExtension)
    {
        $messages = array(
            'zlib'       => 'Installation_SystemCheckZlibHelp',
            'SPL'        => 'Installation_SystemCheckSplHelp',
            'iconv'      => 'Installation_SystemCheckIconvHelp',
            'json'       => 'Installation_SystemCheckWarnJsonHelp',
            'mbstring'   => 'Installation_SystemCheckMbstringHelp',
            'Reflection' => 'Required extension that is built in PHP, see http://www.php.net/manual/en/book.reflection.php',
        );

        return $this->translator->translate($messages[$missingExtension]);
    }

作者:bossrabbi    项目:piwi   
public function execute()
 {
     $label = $this->translator->translate('Installation_SystemCheckMemoryLimit');
     SettingsServer::raiseMemoryLimitIfNecessary();
     $memoryLimit = SettingsServer::getMemoryLimitValue();
     $comment = $memoryLimit . 'M';
     if ($memoryLimit >= $this->minimumMemoryLimit) {
         $status = DiagnosticResult::STATUS_OK;
     } else {
         $status = DiagnosticResult::STATUS_WARNING;
         $comment .= sprintf('<br />%s<br />%s', $this->translator->translate('Installation_SystemCheckMemoryLimitHelp'), $this->translator->translate('Installation_RestartWebServer'));
     }
     return array(DiagnosticResult::singleResult($label, $status, $comment));
 }


问题


面经


文章

微信
公众号

扫码关注公众号