• Курсы Академии Кодебай, стартующие в мае - июне, от команды The Codeby

    1. Цифровая криминалистика и реагирование на инциденты
    2. ОС Linux (DFIR) Старт: 16 мая
    3. Анализ фишинговых атак Старт: 16 мая Устройства для тестирования на проникновение Старт: 16 мая

    Скидки до 10%

    Полный список ближайших курсов ...

Интернационализация

  • Автор темы nws
  • Дата начала
N

nws

Kак сделать интернализацию в cake_1.2.0.6311-beta для динамического текста?

Статьи, которые я нашел по этой теме:





но в них описано только для статического текста ((
 
A

Andrew Stephanoff

а что такое динамический текст?
 
N

nws

Уже разобрался:

Component:

Код:
<?php
class P28nComponent extends Object
{
var $components = array('Session', 'Cookie');

function startup()
{
if (!$this->Session->check('Config.language')) {
$this->change(($this->Cookie->read('lang') ? $this->Cookie->read('lang') :
DEFAULT_LANGUAGE));
}
}

function change($lang = null)
{
if (!empty($lang)) {
$this->Session->write('Config.language', $lang);
$this->Cookie->write('lang', $lang, null, '+350 day');
}
}
}
?>

p28n_controller:

Код:
<?php
class P28nController extends AppController
{
var $name = 'P28n';
var $uses = null;
var $components = array('P28n');

function change($lang = null)
{
$this->P28n->change($lang);

$this->redirect($this->referer(null, true));
}

function shuntRequest()
{
$this->P28n->change($this->params['lang']);

$args = func_get_args();
$this->redirect("/" . implode("/", $args));
}
}
?>

Some controller:

Код:
<?php

class PostsController extends AppController
{
var $name = 'Posts';
var $components = array('P28n', 'Cookie');
var $paginate = array('limit' => 4, 'order' => array('Post.id' => 'DESC'));
var $helpers = array('Html', 'Form');


function archive($id = null)
{

$this->pageTitle = __('logo', true) . ' :: ' . __('nazvanie stranici', true);
$this->set('lang', $this->Cookie->read('lang'));

$this->Post->id = $id;
$this->set('post', $this->Post->read());

$data = $this->paginate('Post');
$this->set(compact('data'));
}

}
?>

View:

Код:
<? foreach($data as $post):?>
<table >
<tr>
<td>
<?echo $html->link($post['Post'][$lang.'_title'],'/posts/view1/'.$post['Post']['id']);?>
<br> <?php echo $post['Post']['created']; ?>
</td>
</tr>
<tr>
<td >
<?echo $html->image('uploads/' . $post['Post']['image'], array('border' => 0, 'width'=>120));?>	
</td>
<td>
<?php echo $post['Post'][$lang.'_short'];?>
<?php echo $html->link(__('Dalee', true), '/posts/view1/'.$post['Post']['id']);?>
</td>
</tr>
</table>
<?php endforeach; ?>
<table>
<tr>
<td align="center">
<?echo $paginator->Prev(__('<<Preced', true),null,null,array('class'=>'disabled'))?>
|<?php echo $paginator->numbers();?>
<?echo $paginator->next(__('Urmat>>',true),null,null,array('class'=>'disabled'))?>
</td>
</tr>
</table>
 
Мы в соцсетях:

Обучение наступательной кибербезопасности в игровой форме. Начать игру!