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


PHP Translation::translate方法代码示例

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


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

示例1: smarty_block_translation

/**
 * Translate a string
 */
function smarty_block_translation($params, $content, $smarty, &$repeat)
{
    return $content;
    if ($content !== null) {
        return Translation::translate($content, $smarty->tpl_vars['env']->value['translation']);
    }
}
开发者ID:tigron,项目名称:skeleton-template-smarty,代码行数:10,代码来源:smarty_extensions.php

示例2: stringify

 public function stringify()
 {
     if (empty($this->errors)) {
         return '{"error_msgs": [{"title": "' . Translation::translate('Sorry!') . '", "message": "' . Translation::translate('Something went wrong!') . '"}]}';
     }
     $error_output = "{";
     foreach ($this->errors as $error) {
         if ($error_output != "{") {
             $error_output .= ",";
         }
         if (is_array($error) == true) {
             $error_output .= '"' . $error[0] . '": ' . $error[1] . '';
         } else {
             $error_output .= '"' . $error . '": "error"';
         }
     }
     $error_output .= "}";
     return $error_output;
 }
开发者ID:iekadou,项目名称:lightpainting,代码行数:19,代码来源:ValidationError.php

示例3: View

<?php

namespace Iekadou\Webapp;

if (!isset($INIT_LOADED)) {
    require_once "../../inc/include.php";
}
new View('404', Translation::translate('404'), 'errors/404.html');
View::render();
开发者ID:iekadou,项目名称:lightpainting,代码行数:9,代码来源:404.php

示例4: View

<?php

namespace Iekadou\Webapp;

require_once "../inc/include.php";
new View('Activate', Translation::translate('Activate'), "activate.html");
$User = new User();
$activation_key = isset($_GET['activation_key']) ? htmlspecialchars($_GET['activation_key']) : false;
$User = $User->get_by(array(array("activation_key", "=", $activation_key)));
if ($User == false) {
    raise404();
    die;
}
$User->activate()->save();
View::render();
开发者ID:iekadou,项目名称:lightpainting,代码行数:15,代码来源:activate.php

示例5: View

<?php

namespace Iekadou\Webapp;

require_once "../inc/include.php";
new View('Forgot password', Translation::translate('Forgot password'), "forgot_password.html");
View::render();
开发者ID:iekadou,项目名称:lightpainting,代码行数:7,代码来源:forgot_password.php

示例6: testPluralTranslation

 public function testPluralTranslation()
 {
     $options = array('plural' => '{number} messages', 'locale' => 'ru');
     $options['count'] = 0;
     $result = Translation::translate('1 message', $options);
     $this->assertSame('ends in 5,6,7,8,9,0 message', $result);
     $options['count'] = 1;
     $result = Translation::translate('1 message', $options);
     $this->assertSame('It\'s one message', $result);
     $options['count'] = 2;
     $result = Translation::translate('1 message', $options);
     $this->assertSame('ends in 2,3,4 message', $result);
     $options['count'] = 3;
     $result = Translation::translate('1 message', $options);
     $this->assertSame('ends in 2,3,4 message', $result);
     $options['count'] = 4;
     $result = Translation::translate('1 message', $options);
     $this->assertSame('ends in 2,3,4 message', $result);
     $options['count'] = 5;
     $result = Translation::translate('1 message', $options);
     $this->assertSame('ends in 5,6,7,8,9,0 message', $result);
     $options['count'] = 6;
     $result = Translation::translate('1 message', $options);
     $this->assertSame('ends in 5,6,7,8,9,0 message', $result);
     $options['count'] = 7;
     $result = Translation::translate('1 message', $options);
     $this->assertSame('ends in 5,6,7,8,9,0 message', $result);
     $options['count'] = 8;
     $result = Translation::translate('1 message', $options);
     $this->assertSame('ends in 5,6,7,8,9,0 message', $result);
     $options['count'] = 9;
     $result = Translation::translate('1 message', $options);
     $this->assertSame('ends in 5,6,7,8,9,0 message', $result);
     $options['count'] = 10;
     $result = Translation::translate('1 message', $options);
     $this->assertSame('ends in 5,6,7,8,9,0 message', $result);
 }
开发者ID:nodesagency,项目名称:Translations,代码行数:37,代码来源:TranslationTest.php

示例7: View

<?php

namespace Iekadou\Webapp;

require_once "../inc/include.php";
new View('Logout', Translation::translate('Logout'), 'logout.html');
Account::logout();
View::render();
开发者ID:iekadou,项目名称:lightpainting,代码行数:8,代码来源:logout.php

示例8: View

<?php

namespace Iekadou\Webapp;

require_once "../inc/include.php";
new View('Login', Translation::translate('Login'), "login.html");
$referrer = isset($_GET['referrer']) ? htmlspecialchars($_GET['referrer']) : false;
Globals::set_var('referrer', $referrer);
View::render();
开发者ID:iekadou,项目名称:lightpainting,代码行数:9,代码来源:login.php

示例9: _translate

 /**
  * _translate
  *
  * Translate one field value. If there is no translation at all - return the original
  *
  * @param string $key
  * @param string $value
  * @return string
  */
 protected function _translate($key, $value, $id)
 {
     $field = preg_replace('@.*\\.@', '', $key);
     $key = sprintf('%s.%s.%s', $this->_settings['modelName'], $id, $field);
     $translated = Translation::translate($key, array('domain' => $this->_settings['domain']));
     if ($translated === $key) {
         Translation::update($key, $value, array('locale' => Configure::read('Config.defaultLanguage'), 'domain' => $this->_settings['domain']));
         return $value;
     }
     return $translated;
 }
开发者ID:nodesagency,项目名称:Translations,代码行数:20,代码来源:TranslateInjector.php

示例10: raise404

<?php

namespace Iekadou\Webapp;

require_once "../../inc/include.php";
if (Account::is_logged_in() != true) {
    raise404();
    die;
}
new View('Profile', Translation::translate('Profile'), 'account/profile.html');
Globals::set_var('profile_active', true);
View::render();
开发者ID:iekadou,项目名称:lightpainting,代码行数:12,代码来源:profile.php

示例11: Image

<?php

namespace Iekadou\Webapp;

require_once "../../inc/include.php";
$Image = new Image();
$img_path = isset($_GET['id']) ? htmlspecialchars($_GET['id']) : false;
if ($img_path != false) {
    $Image = $Image->get_by(array(array("id", "=", $img_path), array("userid", "=", Account::get_user_id())));
    Globals::set_var('form_method', 'PUT');
} else {
    Globals::set_var('form_method', 'POST');
}
Globals::set_var('Image', $Image);
if (Account::is_logged_in() != true || !$Image) {
    raise404();
    die;
}
new View('Image', Translation::translate('Image'), 'account/image.html');
Globals::set_var('dashboard_active', true);
View::render();
开发者ID:iekadou,项目名称:lightpainting,代码行数:21,代码来源:image.php

示例12: send_new_password

    public function send_new_password()
    {
        $new_password = '';
        for ($length = 0; $length < 20; $length++) {
            $chr_cat = rand(0, 1);
            switch ($chr_cat) {
                case 0:
                    $char = chr(rand(50, 57));
                    break;
                default:
                    $char = chr(rand(97, 122));
            }
            $new_password .= $char;
        }
        $subject = Translation::translate('Your new password at {{ SITE_NAME }}', array('{{ SITE_NAME }}' => SITE_NAME));
        $content = Translation::translate('Hey {{ username }},
your new password is: {{ new_password }}

Have fun on {{ SITE_NAME }}', array('{{ SITE_NAME }}' => SITE_NAME, '{{ username }}' => $this->get_username(), '{{ new_password }}' => $new_password));
        $header = 'From: noreply@quickies.io';
        if (mail($this->get_email(), $subject, $content, $header)) {
            $this->set_password($new_password);
            $this->save();
            return $this;
        } else {
            throw new ValidationError(array());
        }
    }
开发者ID:iekadou,项目名称:lightpainting,代码行数:28,代码来源:User.php

示例13: generateHtml

 /**
  * $table - a string for the table name, or an array of rows to be used as the option values
  * $id      - option value to select as default
  * $jsonUrl - do not begin or end with slash or add output type
  */
 public static function generateHtml($table, $column, $id = false, $jsonUrl = false, $disabled = false, $allowIds = false, $multiple = false, $attributes = array(), $set_default = true)
 {
     $mutliple_id = false;
     if (is_int($multiple) or $multiple === 0) {
         $mutliple_id = $multiple;
     }
     $multiple = $multiple !== false ? '[]' : '';
     // allow multiple drop-downs w/same table
     if (is_string($table)) {
         $tableObj = new ITechTable(array('name' => $table));
         $info = $tableObj->info();
         $cols = array($column);
         if ($set_default) {
             if (array_search('is_default', $info['cols'])) {
                 $cols = array($column, 'is_default');
             }
         }
         $rows = $tableObj->fetchAll($tableObj->select($cols));
     } else {
         if (is_array($table) or is_object($table)) {
             $rows = $table;
             $info = $rows->getTable()->info();
             $table = $info['name'];
         }
     }
     $name = $table . '_id' . $multiple;
     if (isset($attributes['name'])) {
         $name = $attributes['name'];
         unset($attributes['name']);
     }
     $html = '<select name="' . $name . '" id="select_' . $table . ($multiple && $mutliple_id !== false ? '_' . $mutliple_id : '') . '"' . ($disabled ? ' disabled="disabled" ' : ' ');
     foreach ($attributes as $k => $v) {
         $html .= " {$k}=\"{$v}\"";
     }
     $html .= ' >';
     $html .= "\t<option value=\"\">&mdash; " . t('select') . " &mdash;</option>\n";
     foreach ($rows as $r) {
         if ($allowIds === false or array_search($r->id, $allowIds) !== false) {
             $isSelected = '';
             //check for default value in table
             if ($set_default && isset($r->is_default) && $r->is_default && ($id === false || $id === null)) {
                 $isSelected = ' selected="selected" ';
             } else {
                 if ($r->id === $id) {
                     //assign default value
                     $isSelected = ' selected="selected" ';
                 }
             }
             $html .= "\t<option value=\"{$r->id}\"{$isSelected}>{$r->{$column}}</option>\n";
         }
     }
     $html .= "</select>\n\n";
     // add edit link
     if ($jsonUrl && !$disabled) {
         $fieldlabel = explode('_', str_replace('_phrase', '', $column));
         $label = $fieldlabel[0];
         if (isset($fieldlabel[1])) {
             $label .= ' ' . $fieldlabel[1];
         }
         //$label = substr($column, strpos($column, '_'));
         //$label = str_replace('phrase', '', $label);
         //$label = trim(str_replace('_', ' ', $label));
         if (trim($label)) {
             switch ($label) {
                 // modify so label translates nicely, if needed
                 case 'training got':
                     $label = "GOT Curriculum";
                     break;
                 default:
                     break;
             }
             require_once 'models/table/Translation.php';
             $translate = @Translation::translate(ucwords($label));
             if ($translate) {
                 $label = $translate;
             }
         }
         $jsonUrl = "{$jsonUrl}/table/{$table}/column/{$column}";
         $jsonUrl = Settings::$COUNTRY_BASE_URL . '/' . $jsonUrl . '/outputType/json';
         $html .= " <a href=\"#\" onclick=\"addToSelect('" . str_replace("'", "\\" . "'", t('Please enter your new')) . " {$label}:', 'select_{$table}', '{$jsonUrl}'); return false;\">" . t('Insert new') . "</a>";
     }
     return $html;
 }
开发者ID:falafflepotatoe,项目名称:trainsmart-code,代码行数:88,代码来源:DropDown.php

示例14: Image

<?php

namespace Iekadou\Webapp;

require_once "../inc/include.php";
$Image = new Image();
$id = isset($_GET['id']) ? htmlspecialchars($_GET['id']) : false;
$Image = $Image->get_by(array(array("id", "=", $id), array("userid", "=", Account::get_user_id())));
if ($Image == false) {
    raise404();
    die;
}
new View('Image', Translation::translate('Image'), "image.html");
Globals::set_var('Image', $Image);
View::render();
开发者ID:iekadou,项目名称:lightpainting,代码行数:15,代码来源:image.php

示例15: translate

function translate($string, $args = array())
{
    return Translation::translate($string, $args);
}
开发者ID:socialapparatus,项目名称:socialapparatus,代码行数:4,代码来源:shortcuts.php


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