/** * 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']); } }
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; }
<?php namespace Iekadou\Webapp; if (!isset($INIT_LOADED)) { require_once "../../inc/include.php"; } new View('404', Translation::translate('404'), 'errors/404.html'); View::render();
<?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();
<?php namespace Iekadou\Webapp; require_once "../inc/include.php"; new View('Forgot password', Translation::translate('Forgot password'), "forgot_password.html"); View::render();
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); }
<?php namespace Iekadou\Webapp; require_once "../inc/include.php"; new View('Imprint', Translation::translate('Imprint'), "imprint.html"); View::render();
<?php namespace Iekadou\Webapp; require_once "../inc/include.php"; new View('Logout', Translation::translate('Logout'), 'logout.html'); Account::logout(); View::render();
<?php namespace Iekadou\Webapp; require_once "../inc/include.php"; new View('Register', Translation::translate('Register'), 'register.html'); View::render();
<?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();
/** * _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; }
<?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();
<?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();
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()); } }
/** * $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=\"\">— " . t('select') . " —</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; }
<?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();
function translate($string, $args = array()) { return Translation::translate($string, $args); }
<?php namespace Iekadou\Webapp; require_once "../inc/include.php"; new View('Home', Translation::translate('Home'), 'index.html'); View::render();
<?php namespace Iekadou\Webapp; require_once "../../inc/include.php"; if (Account::is_logged_in() != true) { raise404(); die; } new View('Dashboard', Translation::translate('Dashboard'), 'account/index.html'); Globals::set_var('dashboard_active', true); View::render();
<?php namespace Iekadou\Webapp; require_once "../../inc/include.php"; if (Account::is_logged_in() != true) { raise404(); die; } new View('Activate', Translation::translate('Activate'), 'account/activate.html'); Globals::set_var('dashboard_active', true); View::render();
/** * The category argument allows a specific category of the locale settings to be used for fetching a message. * Valid categories are: LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES and LC_ALL. * * @param string $msg String to translate * @param integer|string $category Category * @param mixed $args Array with arguments or multiple arguments in function * @return translated string * @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__c */ function __c($msg, $category, $args = null) { if (!is_null($args)) { $args = is_array($args) ? $args : array_slice(func_get_args(), 2); } if (!$msg || !class_exists('Translation')) { return __replace($msg, $args); } $translated = Translation::translate($singular, compact('category')); return __replace($translated, $args); }