Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Pomogite dobavit eshe odin jazyk na saite.

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Russian
View previous topic :: View next topic  
Author Message
Villu
Smarty n00b


Joined: 19 Jun 2014
Posts: 1

PostPosted: Thu Jun 19, 2014 9:07 am    Post subject: Pomogite dobavit eshe odin jazyk na saite. Reply with quote

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
View user's profile Send private message
ZeRoLeVeL
Smarty Rookie


Joined: 13 May 2014
Posts: 6

PostPosted: Fri Jun 20, 2014 1:08 pm    Post subject: Reply with quote

Возможно тебе придется сделать файлы с языками. Там либо один массив либо каждый массив со своим блоком строк. Потом при загрузке и настройке шаблона грузить файл с нужным языком и загонять переменную (массив строк с текстовыми строками) в $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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Russian All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP