本文整理汇总了PHP中Translate类的典型用法代码示例。如果您正苦于以下问题:PHP Translate类的具体用法?PHP Translate怎么用?PHP Translate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Translate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: translate
/**
* translate to english
*
* @throws NotFoundException
* @param string text
* @return the text were translated
* @author quyhoa
* @create day: 11/05/2015
*/
public function translate($fromLanguage, $toLanguage, $text)
{
$translate = new Translate();
$rs = '';
$rs = $translate->tranlated($fromLanguage, $toLanguage, $text);
return $rs;
}
示例2: strtolower
/**
* Constructor
*
* @param DoliDB $db Database handler
* @param Conf $conf Handler de conf
* @param Translate $langs Handler de langue
* @param User $user Handler du user connecte
*/
function __construct($db, $conf, $langs, $user)
{
$this->id = "Perso";
$this->length = $langs->trans("SetupPerso");
$this->db = $db;
$this->conf = $conf;
$this->langs = $langs;
$this->user = $user;
if (empty($conf->global->USER_PASSWORD_PATTERN)) {
// default value (8carac, 1maj, 1digit, 1spe, 3 repeat, no ambi at auto generation.
dolibarr_set_const($db, "USER_PASSWORD_PATTERN", '8;1;1;1;3;1', 'chaine', 0, '', $conf->entity);
}
$this->Maj = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$this->Min = strtolower($this->Maj);
$this->Nb = "0123456789";
$this->Spe = "!@#\$%&*()_-+={}[]\\|:;'/";
$this->Ambi = array("1", "I", "l", "|", "O", "0");
$tabConf = explode(";", $conf->global->USER_PASSWORD_PATTERN);
$this->length2 = $tabConf[0];
$this->NbMaj = $tabConf[1];
$this->NbNum = $tabConf[2];
$this->NbSpe = $tabConf[3];
$this->NbRepeat = $tabConf[4];
$this->WithoutAmbi = $tabConf[5];
if ($this->WithoutAmbi) {
$this->Maj = str_replace($this->Ambi, "", $this->Maj);
$this->Min = str_replace($this->Ambi, "", $this->Min);
$this->Nb = str_replace($this->Ambi, "", $this->Nb);
$this->Spe = str_replace($this->Ambi, "", $this->Spe);
}
$this->All = str_shuffle($this->Maj . $this->Min . $this->Nb . $this->Spe);
//$this->All = $this->Maj. $this->Min. $this->Nb. $this->Spe;
//$this->All = $this->Spe;
}
示例3: testConstruct
public function testConstruct()
{
try {
$dataObject = new Translate(array('invalid' => 'foo'));
$this->fail('Expected \\UnexpectedValueException exception not thrown.');
} catch (\UnexpectedValueException $e) {
}
$dataObject = new Translate(array('translations' => 'foo'));
$this->assertEquals($dataObject->getTranslations(), 'foo');
}
示例4: index
public function index()
{
//$profiler = new Profiler;
if (isset($_GET['emailtest'])) {
$this->emailtest();
die;
}
if (isset($_GET['database'])) {
$this->alterDatabase();
}
if (isset($_GET['cronjob'])) {
$this->cronjob();
die;
}
@session_start();
// $lan = (@$_GET['l']<>'en') ? "es" : 'en';
if (@$_GET['l'] != '') {
$_SESSION['lan'] = @$_GET['l'] != 'en' ? array("es_ES", 'España') : array("en_US", 'USA');
}
if (@$_SESSION['lan'] != "") {
Kohana::config_set("locale.language", $_SESSION['lan']);
}
$lang = new Translate();
$lang->currency();
$defaultobj = "category";
$defaultact = "index";
$module = $this->uri->segment("index") != '' ? $this->uri->segment("index") : $defaultobj;
$action = $this->uri->segment($module) != '' ? $this->uri->segment($module) : $defaultact;
$module = ucfirst($lang->word->{$module});
$lib = new $module();
$action = @$lang->word->{$action};
$this->template->widget = $lib->GetWidgets();
if (method_exists($lib, $action) === FALSE) {
$lib = new $module();
$lib->{$defaultact}();
} else {
$lib->{$action}();
}
$table_page = new fpp_page_Model();
$header = $table_page->db2cls(46);
$footer = $table_page->db2cls(47);
$meta_description = $table_page->db2cls(48);
$tr_content_page = Basic::TransVar("content_page");
$this->template->header = strip_tags($header->{$tr_content_page});
$this->template->footer = $footer->{$tr_content_page};
$this->template->meta_description = strip_tags($meta_description->{$tr_content_page});
//Executes Action's
$this->template->title = $this->uri->segment() == '' ? 'floreria Rosabel | florerias peru | floreria | enviar flores peru' : Kohana::config("core.title_page") . $lib->GetTitle();
$this->template->content = $lib->GetContent();
$this->template->keywords = $lib->GetKeywords() != '' ? $lib->GetKeywords() : 'enviar flores peru, florerías en lima, florerias en lima, envio de flores a peru,florerías,florerias lima, florerias en Lima,floreria lima, Florerias de Lima, Flores domicilio Lima, Florerias en San Isidro, envio de flores a lima, envio de flores en peru,floreria amor y amistad,flores dia de las madres,arreglos florales, floreria san borja peru, florerias en trujillo, florerias en arequipa, floreria los olivos, florerias unidas,envio de flores lima, delivery flores lima, envio flores, floreria san isidro, arreglos flores, rosas, orquideas, giraloes, tulipanes, delivery flowers, send flowers lima, roses, flower shop lima';
if (request::is_ajax()) {
$this->auto_render = FALSE;
echo $lib->GetContent();
}
}
示例5: getState
/**
* Define array with couple subtitution key => subtitution value
*
* @param Object $object Object
* @param Translate $outputlangs Language object for output
* @return array Array of substitution key->code
*/
function get_substitutionarray_thirdparty($object, $outputlangs)
{
global $conf;
if (empty($object->country) && !empty($object->country_code)) {
$object->country = $outputlangs->transnoentitiesnoconv("Country" . $object->country_code);
}
if (empty($mysoc->state) && !empty($mysoc->state_code)) {
$object->state = getState($object->state_code, 0);
}
return array('company_name' => $object->name, 'company_email' => $object->email, 'company_phone' => $object->phone, 'company_fax' => $object->fax, 'company_address' => $object->address, 'company_zip' => $object->zip, 'company_town' => $object->town, 'company_country' => $object->country, 'company_country_code' => $object->country_code, 'company_state' => $object->state, 'company_state_code' => $object->state_code, 'company_web' => $object->url, 'company_barcode' => $object->barcode, 'company_vatnumber' => $object->tva_intra, 'company_customercode' => $object->code_client, 'company_suppliercode' => $object->code_fournisseur, 'company_customeraccountancycode' => $object->code_compta, 'company_supplieraccountancycode' => $object->code_compta_fournisseur, 'company_juridicalstatus' => $object->forme_juridique, 'company_capital' => $object->capital, 'company_idprof1' => $object->idprof1, 'company_idprof2' => $object->idprof2, 'company_idprof3' => $object->idprof3, 'company_idprof4' => $object->idprof4, 'company_idprof5' => $object->idprof5, 'company_idprof6' => $object->idprof6, 'company_note' => $object->note);
}
示例6: actionIndex
public function actionIndex()
{
$taxModel = LbTax::model()->getTaxes();
$list = UserList::model()->getList();
$translate = Translate::model()->search();
$translate = new Translate('search');
$translate->unsetAttributes();
// clear any default values
if (isset($_GET['Translate'])) {
$translate->attributes = $_GET['Translate'];
}
LBApplication::render($this, 'index', array('taxModel' => $taxModel, 'list' => $list, 'translate' => $translate));
// $this->render('index');
}
示例7: actionCreate
/**
* Action для страницы "Добавить категорию"
*/
public function actionCreate()
{
// Проверка доступа
self::checkAdmin();
// Обработка формы
if (isset($_POST['submit'])) {
// Если форма отправлена
// Получаем данные из формы
$name = $_POST['name'];
$sortOrder = $_POST['sort_order'];
$status = $_POST['status'];
//Транслетелируем для ЧПУ
$translate = $name;
$url = Translate::GetInTranslate($translate);
// Флаг ошибок в форме
$errors = false;
// При необходимости можно валидировать значения нужным образом
if (!isset($name) || empty($name)) {
$errors[] = 'Заполните поля';
}
if ($errors == false) {
// Если ошибок нет
// Добавляем новую категорию
Category::createCategory($name, $sortOrder, $status, $url);
// Перенаправляем пользователя на страницу управлениями категориями
header("Location: /admin/category");
}
}
require_once ROOT . '/views/admin_category/create.php';
return true;
}
示例8: testExecuteRequest
public function testExecuteRequest()
{
try {
$response = $this->clientStub->executeRequest();
$this->fail('Excepted \\RuntimeException to be thrown.');
} catch (\RuntimeException $e) {
}
$this->clientStub->setApiKey('key');
try {
$response = $this->clientStub->executeRequest();
$this->fail('Excepted \\RuntimeException to be thrown.');
} catch (\RuntimeException $e) {
}
$this->clientStub->addSourceText('The quick brown fox jumps over the lazy dog.');
try {
$response = $this->clientStub->executeRequest();
$this->fail('Excepted \\RuntimeException to be thrown.');
} catch (\RuntimeException $e) {
}
$this->clientStub->setTargetLanguage('fr');
$response = $this->clientStub->executeRequest();
$this->assertInstanceOf('\\Google\\Api\\Response', $response);
$this->assertTrue($response->isSuccess());
$this->assertInstanceOf('\\Google\\Api\\Response\\Data\\Translate', $response->getData());
}
示例9: defaultAction
public function defaultAction()
{
if (Translate::getId() != '') {
$config = Config::getArray();
$languages = $config['backendLanguages']['list'];
$language_id = Translate::getId();
$strings = array();
if (is_array($languages[$language_id]['translationClientside'])) {
if (count($languages[$language_id]['translationClientside']) > 0) {
foreach ($languages[$language_id]['translationClientside'] as $translation_file) {
$temp = (include $translation_file);
$strings = array_merge($strings, $temp);
}
}
} else {
if ($languages[$language_id]['translationClientside'] != '') {
$strings = (include $languages[$language_id]['translationClientside']);
}
}
$this->view->assign('backendTranslation', $strings);
} else {
$this->view->assign('backendTranslation', array());
}
$useGlobalElementsPage = false;
$pages = new Pages();
if ($pages->isGlobalElementsPageTemplateAvailable()) {
if ($pages->isGlobalElementsPageAvailable()) {
$useGlobalElementsPage = true;
}
}
$this->view->assign('useGlobalElementsPage', $useGlobalElementsPage);
$this->view->assign('globalElementsPageId', $pages->getGlobalElementsPageId());
}
示例10: getHtml
public function getHtml()
{
$users = $this->users->getAll();
$userGroups = new UserGroups();
$html = '';
foreach ($users as $user) {
$user_groups = $this->users->getUserGroups($user['id']);
$user_groups_html = '';
if ($user_groups !== false) {
if (count($user_groups) > 0) {
foreach ($user_groups as $user_group_id) {
$user_group_data = $this->user_groups->getById($user_group_id);
if ($user_groups_html != '') {
$user_groups_html .= ', ';
}
$user_groups_html .= $user_group_data['name'];
}
}
}
$html .= '
<tr data-id="' . $user['id'] . '">
<td><input type="checkbox" name="users[' . $user['id'] . ']" value="1" id="user_' . $user['id'] . '"></td>
<td>' . $user['screenname'] . '</td>
<td>' . ($user['privileges'] == Auth::PRIVILEGES_ADMIN ? Translate::get('Administrator') : Translate::get('User')) . '</td>
<td>' . $user['login'] . '</td>
<td>' . $user_groups_html . '</td>
</tr>
';
}
return $html;
}
示例11: smartyTranslate
function smartyTranslate($params, &$smarty)
{
$htmlentities = !isset($params['js']);
$pdf = isset($params['pdf']);
$addslashes = isset($params['slashes']);
$sprintf = isset($params['sprintf']) ? $params['sprintf'] : false;
if ($pdf) {
return Translate::getPdfTranslation($params['s']);
}
$filename = !isset($smarty->compiler_object) || !is_object($smarty->compiler_object->template) ? $smarty->template_resource : $smarty->compiler_object->template->getTemplateFilepath();
// If the template is part of a module
if (!empty($params['mod'])) {
return Translate::getModuleTranslation($params['mod'], $params['s'], basename($filename, '.tpl'), $sprintf);
}
// If the tpl is at the root of the template folder
if (dirname($filename) == '.') {
$class = 'index';
} elseif (strpos($filename, 'helpers') === 0) {
$class = 'Helper';
} else {
// Split by \ and / to get the folder tree for the file
$folder_tree = preg_split('#[/\\\\]#', $filename);
$key = array_search('controllers', $folder_tree);
// If there was a match, construct the class name using the child folder name
// Eg. xxx/controllers/customers/xxx => AdminCustomers
if ($key !== false) {
$class = 'Admin' . Tools::toCamelCase($folder_tree[$key + 1], true);
} else {
$class = null;
}
}
return Translate::getAdminTranslation($params['s'], $class, $addslashes, $htmlentities, $sprintf);
}
示例12: l
public static function l($string, $specific = false, $name = '')
{
if (empty($name)) {
$name = self::MODULE_NAME;
}
return Translate::getModuleTranslation($name, $string, $specific ? $specific : $name);
}
示例13: init
public function init($inmueble, $pagina)
{
if (!Session::getInstance()->usuario) {
return '/admin/ingresar';
}
$this->inmuebleCodigo = $inmueble;
$this->inmueble = new Inmuebles();
$this->inmueble->codigo = $inmueble;
$this->inmueble->queryAll();
if (!$this->inmueble->found()) {
return true;
}
$this->paginaCodigo = $pagina;
$this->pagina = new Inmuebles_Paginas();
$this->pagina->inmueble_id = $this->inmueble->id;
$this->pagina->codigo = $pagina;
$this->pagina->queryAll();
if (!$this->pagina->found()) {
return true;
}
$this->idiomas = Translate::all();
$inmuebleContenidos = Inmuebles_Contenidos::all(array('inmueble_id' => $this->inmueble->id));
foreach ($inmuebleContenidos as $inmuebleContenido) {
$this->inmuebleContenidos[$inmuebleContenido->idioma] = $inmuebleContenido;
}
$paginaContenidos = Inmuebles_Paginas_Contenidos::all(array('inmueble_pagina_id' => $this->pagina->id));
foreach ($paginaContenidos as $paginaContenido) {
$this->paginaContenidos[$paginaContenido->idioma] = $paginaContenido;
}
return true;
}
示例14: renderParameter
private function renderParameter()
{
$field_days = array(array('short_day' => 'L', 'name' => Translate::getAdminTranslation('Monday')), array('short_day' => 'M', 'name' => Translate::getAdminTranslation('Tuesday')), array('short_day' => 'C', 'name' => Translate::getAdminTranslation('Wednesday')), array('short_day' => 'J', 'name' => Translate::getAdminTranslation('Thursday')), array('short_day' => 'V', 'name' => Translate::getAdminTranslation('Friday')), array('short_day' => 'S', 'name' => Translate::getAdminTranslation('Saturday')), array('short_day' => 'D', 'name' => Translate::getAdminTranslation('Sunday')));
$this->fields_form = array('legend' => array('title' => $this->module->l('Campaign configuration (step 1)', 'adminmarketingsstep1'), 'icon' => 'icon-cogs'), 'input' => array(array('type' => _PS_MODE_DEV_ ? 'text' : 'hidden', 'lang' => false, 'label' => 'Ref :', 'name' => 'campaign_id', 'col' => 1, 'readonly' => 'readonly'), array('type' => 'text', 'lang' => false, 'label' => $this->module->l('Give a name to this campaign :', 'adminmarketingsstep1'), 'name' => 'campaign_name', 'col' => 7, 'required' => true), array('type' => 'datetime', 'lang' => false, 'name' => 'campaign_date_send', 'label' => $this->module->l('Sending date :', 'adminmarketingsstep1'), 'col' => 5, 'required' => true), array('type' => 'checkbox', 'label' => $this->module->l('Limit by day of the week :', 'adminmarketingsstep1'), 'class' => 'checkbox-inline', 'name' => 'week_day_limit', 'values' => array('query' => $field_days, 'id' => 'short_day', 'name' => 'name', 'class' => 'checkbox-inline')), array('type' => 'free', 'name' => 'schedule_sending', 'label' => $this->module->l('Schedule sending :', 'adminmarketingsstep1'))), 'submit' => array('title' => $this->module->l('Next', 'adminmarketingsstep1'), 'name' => 'submitSmsStep1', 'icon' => 'process-icon-next'));
$output = parent::renderForm();
return $this->getFormWrapperElement($output);
}
示例15: getRenderedShopList
/**
* Render shop list
*
* @return string
*/
public function getRenderedShopList()
{
if (!Shop::isFeatureActive() || Shop::getTotalShops(false, null) < 2) {
return '';
}
$shop_context = Shop::getContext();
$context = Context::getContext();
$tree = Shop::getTree();
if ($shop_context == Shop::CONTEXT_ALL || $context->controller->multishop_context_group == false && $shop_context == Shop::CONTEXT_GROUP) {
$current_shop_value = '';
$current_shop_name = Translate::getAdminTranslation('All shops');
} elseif ($shop_context == Shop::CONTEXT_GROUP) {
$current_shop_value = 'g-' . Shop::getContextShopGroupID();
$current_shop_name = sprintf(Translate::getAdminTranslation('%s group'), $tree[Shop::getContextShopGroupID()]['name']);
} else {
$current_shop_value = 's-' . Shop::getContextShopID();
foreach ($tree as $group_id => $group_data) {
foreach ($group_data['shops'] as $shop_id => $shop_data) {
if ($shop_id == Shop::getContextShopID()) {
$current_shop_name = $shop_data['name'];
break;
}
}
}
}
$tpl = $this->createTemplate('helpers/shops_list/list.tpl');
$tpl->assign(array('tree' => $tree, 'current_shop_name' => $current_shop_name, 'current_shop_value' => $current_shop_value, 'multishop_context' => $context->controller->multishop_context, 'multishop_context_group' => $context->controller->multishop_context_group, 'is_shop_context' => $context->controller->multishop_context & Shop::CONTEXT_SHOP, 'is_group_context' => $context->controller->multishop_context & Shop::CONTEXT_GROUP, 'shop_context' => $shop_context, 'url' => $_SERVER['REQUEST_URI'] . ($_SERVER['QUERY_STRING'] ? '&' : '?') . 'setShopContext='));
return $tpl->fetch();
}