本文整理汇总了PHP中Pimcore\Tool\Admin::getLanguageFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Admin::getLanguageFile方法的具体用法?PHP Admin::getLanguageFile怎么用?PHP Admin::getLanguageFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Tool\Admin
的用法示例。
在下文中一共展示了Admin::getLanguageFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: jsonTranslationsSystemAction
public function jsonTranslationsSystemAction()
{
$this->getResponse()->setHeader("Content-Type", "text/javascript", true);
$language = $this->getParam("language");
$languageFile = Tool\Admin::getLanguageFile($language);
if (!is_file($languageFile)) {
$languageFile = Tool\Admin::getLanguageFile("en");
}
$row = 1;
$handle = fopen($languageFile, "r");
while (($data = fgetcsv($handle, 0, ",")) !== FALSE) {
$translations[$data[0]] = $data[1];
}
fclose($handle);
$broker = \Pimcore\API\Plugin\Broker::getInstance();
$pluginTranslations = $broker->getTranslations($language);
//$pluginTranslations = $this->getApiPluginBroker()->getTranslations($language);
$translations = array_merge($pluginTranslations, $translations);
$this->view->translations = $translations;
}
示例2: jsonTranslationsSystemAction
public function jsonTranslationsSystemAction()
{
$this->getResponse()->setHeader("Content-Type", "text/javascript", true);
$language = $this->getParam("language");
$languageFiles = [$language => Tool\Admin::getLanguageFile($language), "en" => Tool\Admin::getLanguageFile("en")];
$translations = [];
foreach ($languageFiles as $langKey => $languageFile) {
if (file_exists($languageFile)) {
$rawTranslations = json_decode(file_get_contents($languageFile), true);
foreach ($rawTranslations as $entry) {
if (!isset($translations[$entry["term"]])) {
$translations[$entry["term"]] = $entry["definition"];
}
}
}
}
$broker = \Pimcore\API\Plugin\Broker::getInstance();
$pluginTranslations = $broker->getTranslations($language);
$translations = array_merge($pluginTranslations, $translations);
$this->view->translations = $translations;
}
示例3: initTranslations
/**
* @param $instance
* @throws \Zend_Exception
*/
public static function initTranslations($instance)
{
$language = "en";
$locale = $instance->getLanguage();
if ($locale) {
$locale = new \Zend_Locale($locale);
foreach ([(string) $locale, $locale->getLanguage()] as $localeVariant) {
if (in_array($localeVariant, AdminTool::getLanguages())) {
$language = $localeVariant;
break;
}
}
}
//add translations to registry
$coreLanguageFile = AdminTool::getLanguageFile($language);
$translator = new \Zend_Translate('Pimcore\\Translate\\Adapter\\Json', $coreLanguageFile, $language);
$languageFile = AdminTool::getLanguageFile($language);
$translator->addTranslation($languageFile, $language);
if (\Zend_Registry::isRegistered("Zend_Locale")) {
$locale = \Zend_Registry::get("Zend_Locale");
@$translator->setLocale($locale);
}
\Zend_Registry::set("Zend_Translate", $translator);
if ($instance) {
$instance->setTranslator($translator);
}
}
示例4: initTranslations
/**
* @param $instance
* @throws \Zend_Exception
*/
public static function initTranslations($instance)
{
//add translations to registry
$coreLanguageFile = AdminTool::getLanguageFile("en");
$translator = new \Zend_Translate('Pimcore\\Translate\\Adapter\\Json', $coreLanguageFile, 'en');
$availableLanguages = AdminTool::getLanguages();
foreach ($availableLanguages as $lang) {
if ($lang != "en") {
$languageFile = AdminTool::getLanguageFile($lang);
$translator->addTranslation($languageFile, $lang);
}
}
if (\Zend_Registry::isRegistered("Zend_Locale")) {
$locale = \Zend_Registry::get("Zend_Locale");
@$translator->setLocale($locale);
}
\Zend_Registry::set("Zend_Translate", $translator);
if ($instance) {
$instance->setTranslator($translator);
}
}