Ignore:
Timestamp:
Oct 19, 2013, 11:21:01 AM (7 years ago)
Author:
mistic100
Message:

feature 2978: l10n() and {translate} with additional arguments
TODO: apply in core

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/template.class.php

    r23688 r24988  
    9696    $this->smarty->registerPlugin('modifiercompiler', 'translate_dec', array('Template', 'modcompiler_translate_dec') );
    9797    $this->smarty->registerPlugin('modifier', 'explode', array('Template', 'mod_explode') );
    98     $this->smarty->registerPlugin( 'modifier', 'get_extent', array($this, 'get_extent') );
     98    $this->smarty->registerPlugin('modifier', 'get_extent', array($this, 'get_extent') );
    9999    $this->smarty->registerPlugin('block', 'html_head', array($this, 'block_html_head') );
    100100    $this->smarty->registerPlugin('block', 'html_style', array($this, 'block_html_style') );
     
    488488  }
    489489
    490   static function get_php_str_val($str)
     490  private static function get_php_str_val($str)
    491491  {
    492492    if (is_string($str) && strlen($str)>1)
     
    508508  {
    509509    global $conf, $lang;
    510     if ( $conf['compiled_template_cache_language']
    511       && ($key=self::get_php_str_val($params[0])) !== null)
    512     {
    513       if (isset($lang[$key]))
     510
     511    switch (count($params))
     512    {
     513    case 1:
     514      if ($conf['compiled_template_cache_language']
     515        && ($key=self::get_php_str_val($params[0])) !== null
     516        && isset($lang[$key])
     517      ) {
    514518        return var_export($lang[$key], true);
    515     }
    516     return 'l10n('.$params[0].')';
     519      }
     520      return 'l10n('.$params[0].')';
     521     
     522    default:
     523      if ($conf['compiled_template_cache_language'])
     524      {
     525        $ret = 'sprintf(';
     526        $ret .= self::modcompiler_translate( array($params[0]) );
     527        $ret .= ','. implode(',', array_slice($params, 1));
     528        $ret .= ')';
     529        return $ret;
     530      }
     531      return 'l10n('.$params[0].','.implode(',', array_slice($params, 1)).')';
     532    }
    517533  }
    518534
     
    520536  {
    521537    global $conf, $lang, $lang_info;
    522     if ( $conf['compiled_template_cache_language'])
     538    if ($conf['compiled_template_cache_language'])
    523539    {
    524540      $ret = 'sprintf(';
Note: See TracChangeset for help on using the changeset viewer.