|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Villu Smarty n00b
Joined: 19 Jun 2014 Posts: 1
|
Posted: Thu Jun 19, 2014 9:07 am Post subject: Pomogite dobavit eshe odin jazyk na saite. |
|
|
Vsem privet!
Pomogite pozaluista. Nuzno dobavit jazyk na saite no neznaju kak. Systema SMARTY. Uzhe est dvva jazyka. S 4ego na4at?
Zaranee spasibo! |
|
Back to top |
|
ZeRoLeVeL Smarty Rookie
Joined: 13 May 2014 Posts: 6
|
Posted: Fri Jun 20, 2014 1:08 pm Post subject: |
|
|
Возможно тебе придется сделать файлы с языками. Там либо один массив либо каждый массив со своим блоком строк. Потом при загрузке и настройке шаблона грузить файл с нужным языком и загонять переменную (массив строк с текстовыми строками) в $tpl->assign( 'lng_str', $lng_str );
Например файл ru.php с русским языком
Code: | <?php
$lng_str = array(
.....
'Jan' =>'Январь',
'Dec' => 'Декабрь'
);
?> |
Например файл init.php
Code: | ...
// ==========[ Ш А Б Л О Н ]========== \\
if ( !$config['template_name'] or $config['template_name'] == "" ) {
$config['template_name'] = "default";
}
define( 'TEMPLATE_PATH', '/template/' . $config['template_name'] . '/' );
define( 'SMARTY_TEMPLATE_PATH', ROOT_DIR . TEMPLATE_PATH );
require_once ( ENGINE_DIR.'libs/Smarty.class.php' );
$tpl = new Smarty;
$tpl->setTemplateDir( SMARTY_TEMPLATE_PATH );
$tpl->setCacheDir( SMARTY_TEMPLATE_PATH . '/cache' );
$tpl->setConfigDir( SMARTY_TEMPLATE_PATH . '/configs' );
$tpl->setCompileDir( SMARTY_TEMPLATE_PATH . '/compile' );
if ( !$config['charset'] or $config['charset'] == "" ) {
$config['charset'] = "utf-8";
// header('Content-Type: text/html; charset=utf-8');
}
$tpl->assign( 'charset', $config['charset'] );
if ( isset( $config['description'] ) and $config['description'] != "" ) {
$tpl->assign( 'description', $config['description'] );
} else {
$tpl->assign( 'description', "" );
}
if ( isset( $config['keywords'] ) and $config['keywords'] != "" ) {
$tpl->assign( 'keywords', $config['keywords'] );
} else {
$tpl->assign( 'keywords', "" );
}
if ( isset( $config['language'] ) and $config['language'] != "" ) {
$tpl->assign( 'language', $config['language'] );
} else {
$tpl->assign( 'language', "ru" );
}
// Загрузка файла с языком
if ( @file_exists( ROOT_DIR . '/language/' . $language . '.php' ) ) {
include ROOT_DIR . '/language/' . $language . '.php';
} else {
echo "Ошибка при загрузке файла " . ROOT_DIR . '/language/' . $language . '.php';
exit;
}
$tpl->assign( 'lng_str', $lng_str );
$tpl->assign( 'Template', TEMPLATE_PATH );
//$tpl->debugging = true;
// ==========[ Ш А Б Л О Н ]========== \\ |
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|