当前位置: 首页>>代码示例>>PHP>>正文


PHP Piwik\Translate类代码示例

本文整理汇总了PHP中Piwik\Translate的典型用法代码示例。如果您正苦于以下问题:PHP Translate类的具体用法?PHP Translate怎么用?PHP Translate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Translate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: configureReportingMenu

 public function configureReportingMenu(MenuReporting $menu)
 {
     $idSite = Common::getRequestVar('idSite', null, 'int');
     $goals = API::getInstance()->getGoals($idSite);
     $mainGoalMenu = $this->getGoalCategoryName($idSite);
     $site = new Site($idSite);
     if (count($goals) == 0) {
         $menu->add($mainGoalMenu, '', array('module' => 'Goals', 'action' => $site->isEcommerceEnabled() ? 'ecommerceReport' : 'addNewGoal', 'idGoal' => $site->isEcommerceEnabled() ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER : null), true, 25);
         if ($site->isEcommerceEnabled()) {
             $menu->add($mainGoalMenu, 'Goals_Ecommerce', array('module' => 'Goals', 'action' => 'ecommerceReport', 'idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER), true, 1);
         }
         $menu->add($mainGoalMenu, 'Goals_AddNewGoal', array('module' => 'Goals', 'action' => 'addNewGoal'));
     } else {
         $menu->add($mainGoalMenu, '', array('module' => 'Goals', 'action' => $site->isEcommerceEnabled() ? 'ecommerceReport' : 'index', 'idGoal' => $site->isEcommerceEnabled() ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER : null), true, 25);
         if ($site->isEcommerceEnabled()) {
             $menu->add($mainGoalMenu, 'Goals_Ecommerce', array('module' => 'Goals', 'action' => 'ecommerceReport', 'idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER), true, 1);
         }
         $menu->add($mainGoalMenu, 'Goals_GoalsOverview', array('module' => 'Goals', 'action' => 'index'), true, 2);
         $group = new Group();
         foreach ($goals as $goal) {
             $subMenuName = str_replace('%', '%%', Translate::clean($goal['name']));
             $params = array('module' => 'Goals', 'action' => 'goalReport', 'idGoal' => $goal['idgoal']);
             $tooltip = sprintf('%s (id = %d)', $subMenuName, $goal['idgoal']);
             if (count($goals) <= 3) {
                 $menu->add($mainGoalMenu, $subMenuName, $params, true, 50, $tooltip);
             } else {
                 $group->add($subMenuName, $params, $tooltip);
             }
         }
         if (count($goals) > 3) {
             $menu->addGroup($mainGoalMenu, 'Goals_ChooseGoal', $group, $orderId = 50, $tooltip = false);
         }
     }
 }
开发者ID:emersonmatsumoto,项目名称:piwik,代码行数:34,代码来源:Menu.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getHelperSet()->get('dialog');
     $command = $this->getApplication()->find('translations:fetch');
     $arguments = array('command' => 'translations:fetch', '--username' => $input->getOption('username'), '--password' => $input->getOption('password'), '--keep-english' => true);
     $inputObject = new ArrayInput($arguments);
     $inputObject->setInteractive($input->isInteractive());
     $command->run($inputObject, $output);
     $englishFromOTrance = FetchFromOTrance::getDownloadPath() . DIRECTORY_SEPARATOR . 'en.json';
     if (!file_exists($englishFromOTrance)) {
         $output->writeln("English file from oTrance missing. Aborting");
         return;
     }
     $englishFromOTrance = json_decode(file_get_contents($englishFromOTrance), true);
     Translate::reloadLanguage('en');
     $availableTranslations = $GLOBALS['Piwik_translations'];
     $categories = array_unique(array_merge(array_keys($englishFromOTrance), array_keys($availableTranslations)));
     sort($categories);
     $unnecessary = $outdated = $missing = array();
     foreach ($categories as $category) {
         if (!empty($englishFromOTrance[$category])) {
             foreach ($englishFromOTrance[$category] as $key => $value) {
                 if (!array_key_exists($category, $availableTranslations) || !array_key_exists($key, $availableTranslations[$category])) {
                     $unnecessary[] = sprintf('%s_%s', $category, $key);
                     continue;
                 } else {
                     if (html_entity_decode($availableTranslations[$category][$key]) != html_entity_decode($englishFromOTrance[$category][$key])) {
                         $outdated[] = sprintf('%s_%s', $category, $key);
                         continue;
                     }
                 }
             }
         }
         if (!empty($availableTranslations[$category])) {
             foreach ($availableTranslations[$category] as $key => $value) {
                 if (!array_key_exists($category, $englishFromOTrance) || !array_key_exists($key, $englishFromOTrance[$category])) {
                     $missing[] = sprintf('%s_%s', $category, $key);
                     continue;
                 }
             }
         }
     }
     $output->writeln("");
     if (!empty($missing)) {
         $output->writeln("<bg=yellow;options=bold>-- Following keys are missing on oTrance --</bg=yellow;options=bold>");
         $output->writeln(implode("\n", $missing));
         $output->writeln("");
     }
     if (!empty($unnecessary)) {
         $output->writeln("<bg=yellow;options=bold>-- Following keys might be unnecessary on oTrance --</bg=yellow;options=bold>");
         $output->writeln(implode("\n", $unnecessary));
         $output->writeln("");
     }
     if (!empty($outdated)) {
         $output->writeln("<bg=yellow;options=bold>-- Following keys are outdated on oTrance --</bg=yellow;options=bold>");
         $output->writeln(implode("\n", $outdated));
         $output->writeln("");
     }
     $output->writeln("Finished.");
 }
开发者ID:kreynen,项目名称:elmsln,代码行数:60,代码来源:CompareKeys.php

示例3: completeKey

 protected function completeKey($cacheKey)
 {
     $pluginManager = PluginManager::getInstance();
     $pluginNames = $pluginManager->getLoadedPluginsName();
     $cacheKey = $cacheKey . md5(implode('', $pluginNames)) . Translate::getLanguageLoaded();
     return $cacheKey;
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:7,代码来源:PluginAwareStaticCache.php

示例4: testGetPrettyString

 /**
  * @group Core
  */
 public function testGetPrettyString()
 {
     Translate::loadEnglishTranslation();
     $year = new Year(Date::factory('2024-10-09'));
     $shouldBe = '2024';
     $this->assertEquals($shouldBe, $year->getPrettyString());
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:10,代码来源:YearTest.php

示例5: init

 public function init()
 {
     $__languages = array('bg', 'cz', 'de', 'en', 'es', 'fr', 'hu', 'id', 'it', 'ja', 'nl', 'pl', 'pt', 'ro', 'ru', 'sr', 'tr', 'uk', 'zh');
     if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] !== '') {
         $realPath =& $_SERVER['REQUEST_URI'];
     } elseif (isset($_SERVER['SCRIPT_NAME']) && $_SERVER['SCRIPT_NAME'] !== '') {
         $realPath =& $_SERVER['SCRIPT_NAME'];
     } else {
         exit(LANG_UNKNOWN_DIR);
     }
     /** First of all, check if we are inside Piwik */
     $dirName = dirname($realPath);
     if ($dirName === '/') {
         $dirName = '';
     }
     define('CLICKHEAT_PATH', $dirName . '/plugins/ClickHeat/libs/');
     define('CLICKHEAT_INDEX_PATH', 'index.php?module=ClickHeat&');
     define('CLICKHEAT_ROOT', PIWIK_INCLUDE_PATH . '/plugins/ClickHeat/libs/');
     define('CLICKHEAT_CONFIG', PIWIK_INCLUDE_PATH . '/plugins/ClickHeat/clickheat.php');
     define('IS_PIWIK_MODULE', true);
     if (Piwik::hasUserSuperUserAccess()) {
         define('CLICKHEAT_ADMIN', true);
     } else {
         define('CLICKHEAT_ADMIN', false);
     }
     define('CLICKHEAT_LANGUAGE', Translate::getLanguageToLoad());
     require_once CLICKHEAT_CONFIG;
     /** Specific definitions */
     $clickheatConf['__screenSizes'] = array(0, 640, 800, 1024, 1280, 1440, 1600, 1800);
     $clickheatConf['__browsersList'] = array('all' => '', 'firefox' => 'Firefox', 'chrome' => 'Google Chrome', 'msie' => 'Internet Explorer', 'safari' => 'Safari', 'opera' => 'Opera', 'kmeleon' => 'K-meleon', 'unknown' => '');
     self::conf($clickheatConf);
 }
开发者ID:NikitaEgorov,项目名称:plugin-clickheat,代码行数:32,代码来源:Controller.php

示例6: 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;
 }
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:35,代码来源:GenerateWidget.php

示例7: configureReportingMenu

 public function configureReportingMenu(MenuReporting $menu)
 {
     $idSite = $this->getIdSite();
     $goals = API::getInstance()->getGoals($idSite);
     $mainGoalMenu = 'Goals_Goals';
     if (count($goals) == 0) {
         $linkToAddNewGoal = $this->urlForAction('addNewGoal', array('idGoal' => null));
         $menu->addItem($mainGoalMenu, '', $linkToAddNewGoal, 25);
         $menu->addItem($mainGoalMenu, 'Goals_AddNewGoal', $linkToAddNewGoal, 1);
         return;
     }
     $order = 1;
     $url = $this->urlForAction('index', array('idGoal' => null));
     $menu->addItem($mainGoalMenu, '', $url, 25);
     $menu->addItem($mainGoalMenu, 'General_Overview', $url, ++$order);
     $group = new Group();
     foreach ($goals as $goal) {
         $subMenuName = str_replace('%', '%%', Translate::clean($goal['name']));
         $params = $this->urlForAction('goalReport', array('idGoal' => $goal['idgoal']));
         $tooltip = sprintf('%s (id = %d)', $subMenuName, $goal['idgoal']);
         if (count($goals) > 3) {
             $group->add($subMenuName, $params, $tooltip);
         } else {
             $menu->addItem($mainGoalMenu, $subMenuName, $params, ++$order, $tooltip);
         }
     }
     if (count($goals) > 3) {
         $menu->addGroup($mainGoalMenu, 'Goals_ChooseGoal', $group, ++$order, $tooltip = false);
     }
     $menu->addItem($mainGoalMenu, 'Goals_ManageGoals', $this->urlForAction('editGoals'), ++$order);
 }
开发者ID:CaptainSharf,项目名称:SSAD_Project,代码行数:31,代码来源:Menu.php

示例8: getEnglishTranslationForFeatureName

 private function getEnglishTranslationForFeatureName($featureName)
 {
     if (Translate::getLanguageLoaded() == 'en') {
         return $featureName;
     }
     $translationKeyForFeature = Translate::findTranslationKeyForTranslation($featureName);
     return Piwik::translate($translationKeyForFeature, array(), 'en');
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:8,代码来源:API.php

示例9: setUp

 public function setUp()
 {
     parent::setUp();
     StaticCache::clearAll();
     PluginAwareStaticCache::clearAll();
     Translate::reloadLanguage('en');
     $this->api = API::getInstance();
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:8,代码来源:ApiTest.php

示例10: setUp

 public function setUp()
 {
     parent::setUp();
     for ($i = 1; $i <= $this->numSitesToCreate; $i++) {
         Fixture::createWebsite('2012-12-12 00:00:00', $ecommerce = 0, 'Site ' . $i);
     }
     Translate::loadAllTranslations();
     $this->dashboard = $this->getMockBuilder('Piwik\\Plugins\\MultiSites\\Dashboard')->setMethods(null)->disableOriginalConstructor()->getMock();
 }
开发者ID:normimuc,项目名称:piwik,代码行数:9,代码来源:DashboardTest.php

示例11: 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
 }
开发者ID:heiglandreas,项目名称:plugin-LoginLdap,代码行数:14,代码来源:RegenerateTokenAuthTest.php

示例12: 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();
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:15,代码来源:ActionTest.php

示例13: filter

 /**
  * Decodes all encoded entities in the given translations
  *
  * @param array $translations
  *
  * @return array   filtered translations
  */
 public function filter($translations)
 {
     foreach ($translations as $pluginName => $pluginTranslations) {
         foreach ($pluginTranslations as $key => $translation) {
             // remove encoded entities
             $decoded = Translate::clean($translation);
             if ($translation != $decoded) {
                 $this->filteredData[$pluginName][$key] = $translation;
                 $translations[$pluginName][$key] = $decoded;
                 continue;
             }
         }
     }
     return $translations;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:22,代码来源:EncodedEntities.php

示例14: getEnglishTranslationForFeatureName

 private function getEnglishTranslationForFeatureName($featureName)
 {
     $loadedLanguage = Translate::getLanguageLoaded();
     if ($loadedLanguage == 'en') {
         return $featureName;
     }
     $translationKeyForFeature = Translate::findTranslationKeyForTranslation($featureName);
     if (!empty($translationKeyForFeature)) {
         Translate::reloadLanguage('en');
         $featureName = Piwik::translate($translationKeyForFeature);
         Translate::reloadLanguage($loadedLanguage);
         return $featureName;
     }
     return $featureName;
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:15,代码来源:API.php

示例15: dispatch

 /**
  * @param \Exception|null $exception
  */
 public function dispatch($exception = null)
 {
     if ($exception) {
         $message = $exception->getMessage();
     } else {
         $message = '';
     }
     Translate::loadCoreTranslation();
     $action = Common::getRequestVar('action', 'welcome', 'string');
     if ($this->isAllowedAction($action)) {
         echo FrontController::getInstance()->dispatch('Installation', $action, array($message));
     } else {
         Piwik::exitWithErrorMessage(Piwik::translate('Installation_NoConfigFound'));
     }
     exit;
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:19,代码来源:Installation.php


注:本文中的Piwik\Translate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。