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


PHP Translate::getGenericAdminTranslation方法代码示例

本文整理汇总了PHP中Translate::getGenericAdminTranslation方法的典型用法代码示例。如果您正苦于以下问题:PHP Translate::getGenericAdminTranslation方法的具体用法?PHP Translate::getGenericAdminTranslation怎么用?PHP Translate::getGenericAdminTranslation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Translate的用法示例。


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

示例1: getModuleTranslation

 /**
  * Get a translation for a module
  *
  * @param string|Module $module
  * @param string $string
  * @param string $source
  * @return string
  */
 public static function getModuleTranslation($module, $string, $source, $sprintf = null, $js = false)
 {
     global $_MODULES, $_MODULE, $_LANGADM;
     static $lang_cache = array();
     // $_MODULES is a cache of translations for all module.
     // $translations_merged is a cache of wether a specific module's translations have already been added to $_MODULES
     static $translations_merged = array();
     $name = $module instanceof Module ? $module->name : $module;
     $language = Context::getContext()->language;
     if (!isset($translations_merged[$name]) && isset(Context::getContext()->language)) {
         $files_by_priority = array(_PS_THEME_DIR_ . 'modules/' . $name . '/translations/' . $language->iso_code . '.php', _PS_THEME_DIR_ . 'modules/' . $name . '/' . $language->iso_code . '.php', _PS_MODULE_DIR_ . $name . '/translations/' . $language->iso_code . '.php', _PS_MODULE_DIR_ . $name . '/' . $language->iso_code . '.php');
         foreach ($files_by_priority as $file) {
             if (file_exists($file)) {
                 include_once $file;
                 $_MODULES = !empty($_MODULES) ? $_MODULES + $_MODULE : $_MODULE;
                 //we use "+" instead of array_merge() because array merge erase existing values.
                 $translations_merged[$name] = true;
             }
         }
     }
     $string = preg_replace("/\\\\*'/", "\\'", $string);
     $key = md5($string);
     $cache_key = $name . '|' . $string . '|' . $source . '|' . (int) $js;
     if (!isset($lang_cache[$cache_key])) {
         if ($_MODULES == null) {
             if ($sprintf !== null) {
                 $string = Translate::checkAndReplaceArgs($string, $sprintf);
             }
             return str_replace('"', '"', $string);
         }
         $current_key = strtolower('<{' . $name . '}' . _THEME_NAME_ . '>' . $source) . '_' . $key;
         $default_key = strtolower('<{' . $name . '}prestashop>' . $source) . '_' . $key;
         if ('controller' == substr($source, -10, 10)) {
             +($file = substr($source, 0, -10));
             $current_key_file = strtolower('<{' . $name . '}' . _THEME_NAME_ . '>' . $file) . '_' . $key;
             $default_key_file = strtolower('<{' . $name . '}prestashop>' . $file) . '_' . $key;
         }
         if (isset($current_key_file) && !empty($_MODULES[$current_key_file])) {
             $ret = stripslashes($_MODULES[$current_key_file]);
         } elseif (isset($default_key_file) && !empty($_MODULES[$default_key_file])) {
             $ret = stripslashes($_MODULES[$default_key_file]);
         } elseif (!empty($_MODULES[$current_key])) {
             $ret = stripslashes($_MODULES[$current_key]);
         } elseif (!empty($_MODULES[$default_key])) {
             $ret = stripslashes($_MODULES[$default_key]);
         } elseif (!empty($_LANGADM)) {
             $ret = stripslashes(Translate::getGenericAdminTranslation($string, $key, $_LANGADM));
         } else {
             $ret = stripslashes($string);
         }
         if ($sprintf !== null) {
             $ret = Translate::checkAndReplaceArgs($ret, $sprintf);
         }
         if ($js) {
             $ret = addslashes($ret);
         } else {
             $ret = htmlspecialchars($ret, ENT_COMPAT, 'UTF-8');
         }
         if ($sprintf === null) {
             $lang_cache[$cache_key] = $ret;
         } else {
             return $ret;
         }
     }
     return $lang_cache[$cache_key];
 }
开发者ID:jpodracky,项目名称:dogs,代码行数:74,代码来源:Translate.php

示例2: getModuleTranslation

 /**
  * Get a translation for a module
  *
  * @param string|Module $module
  * @param string $string
  * @param string $source
  * @return string
  */
 public static function getModuleTranslation($module, $string, $source, $sprintf = null, $js = false)
 {
     global $_MODULES, $_MODULE, $_LANGADM;
     static $lang_cache = array();
     // $_MODULES is a cache of translations for all module.
     // $translations_merged is a cache of wether a specific module's translations have already been added to $_MODULES
     static $translations_merged = array();
     $name = $module instanceof Module ? $module->name : $module;
     if (!isset($translations_merged[$name])) {
         $filesByPriority = array(_PS_THEME_DIR_ . 'modules/' . $name . '/translations/' . Context::getContext()->language->iso_code . '.php', _PS_THEME_DIR_ . 'modules/' . $name . '/' . Context::getContext()->language->iso_code . '.php', _PS_MODULE_DIR_ . $name . '/translations/' . Context::getContext()->language->iso_code . '.php', _PS_MODULE_DIR_ . $name . '/' . Context::getContext()->language->iso_code . '.php');
         foreach ($filesByPriority as $file) {
             if (Tools::file_exists_cache($file)) {
                 include_once $file;
                 $_MODULES = !empty($_MODULES) ? $_MODULES + $_MODULE : $_MODULE;
                 //we use "+" instead of array_merge() because array merge erase existing values.
                 $translations_merged[$name] = true;
             }
         }
     }
     $key = md5(str_replace('\'', '\\\'', $string));
     $cache_key = $name . '|' . $string . '|' . $source;
     if (!isset($lang_cache[$cache_key])) {
         if ($_MODULES == null) {
             if ($sprintf !== null) {
                 $string = Translate::checkAndReplaceArgs($string, $sprintf);
             }
             return str_replace('"', '&quot;', $string);
         }
         $current_key = strtolower('<{' . $name . '}' . _THEME_NAME_ . '>' . $source) . '_' . $key;
         $default_key = strtolower('<{' . $name . '}prestashop>' . $source) . '_' . $key;
         if (isset($_MODULES[$current_key])) {
             $ret = stripslashes($_MODULES[$current_key]);
         } elseif (isset($_MODULES[$default_key])) {
             $ret = stripslashes($_MODULES[$default_key]);
         } elseif (!empty($_LANGADM)) {
             $ret = Translate::getGenericAdminTranslation($string, $key, $_LANGADM);
         } else {
             $ret = stripslashes($string);
         }
         if ($sprintf !== null) {
             $ret = Translate::checkAndReplaceArgs($ret, $sprintf);
         }
         if ($js) {
             $ret = addslashes($ret);
         }
         $lang_cache[$cache_key] = str_replace('"', '&quot;', $ret);
     }
     return $lang_cache[$cache_key];
 }
开发者ID:FAVHYAN,项目名称:a3workout,代码行数:57,代码来源:Translate.php


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