本文整理汇总了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);
}
}
}
示例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.");
}
示例3: completeKey
protected function completeKey($cacheKey)
{
$pluginManager = PluginManager::getInstance();
$pluginNames = $pluginManager->getLoadedPluginsName();
$cacheKey = $cacheKey . md5(implode('', $pluginNames)) . Translate::getLanguageLoaded();
return $cacheKey;
}
示例4: testGetPrettyString
/**
* @group Core
*/
public function testGetPrettyString()
{
Translate::loadEnglishTranslation();
$year = new Year(Date::factory('2024-10-09'));
$shouldBe = '2024';
$this->assertEquals($shouldBe, $year->getPrettyString());
}
示例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);
}
示例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;
}
示例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);
}
示例8: getEnglishTranslationForFeatureName
private function getEnglishTranslationForFeatureName($featureName)
{
if (Translate::getLanguageLoaded() == 'en') {
return $featureName;
}
$translationKeyForFeature = Translate::findTranslationKeyForTranslation($featureName);
return Piwik::translate($translationKeyForFeature, array(), 'en');
}
示例9: setUp
public function setUp()
{
parent::setUp();
StaticCache::clearAll();
PluginAwareStaticCache::clearAll();
Translate::reloadLanguage('en');
$this->api = API::getInstance();
}
示例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();
}
示例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
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}