本文整理汇总了PHP中Piwik\Translate::findTranslationKeyForTranslation方法的典型用法代码示例。如果您正苦于以下问题:PHP Translate::findTranslationKeyForTranslation方法的具体用法?PHP Translate::findTranslationKeyForTranslation怎么用?PHP Translate::findTranslationKeyForTranslation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Translate
的用法示例。
在下文中一共展示了Translate::findTranslationKeyForTranslation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: getEnglishTranslationForFeatureName
private function getEnglishTranslationForFeatureName($featureName)
{
if (Translate::getLanguageLoaded() == 'en') {
return $featureName;
}
$translationKeyForFeature = Translate::findTranslationKeyForTranslation($featureName);
return Piwik::translate($translationKeyForFeature, array(), 'en');
}
示例3: 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;
}
示例4: getCategory
/**
* @param InputInterface $input
* @param OutputInterface $output
* @param string $pluginName
* @return array
* @throws \RuntimeException
*/
protected function getCategory(InputInterface $input, OutputInterface $output, $pluginName)
{
$path = $this->getPluginPath($pluginName) . '/Reports/Base.php';
if (file_exists($path)) {
// category is already defined in base.php
return '';
}
$validate = function ($category) {
if (empty($category)) {
throw new \InvalidArgumentException('Please enter the name of the category your report belongs to');
}
return $category;
};
$category = $input->getOption('category');
$reports = new ReportsProvider();
$categories = array();
foreach ($reports->getAllReports() as $report) {
if ($report->getCategoryId()) {
$categories[] = Piwik::translate($report->getCategoryId());
}
}
$categories = array_values(array_unique($categories));
if (empty($category)) {
$dialog = $this->getHelperSet()->get('dialog');
$category = $dialog->askAndValidate($output, 'Enter the report 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;
}