Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

The Newest Build (2.6.3) - Lang Built in?

 
Post new topic   Reply to topic    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
NewfieBilko
Smarty Regular


Joined: 21 Jun 2004
Posts: 41

PostPosted: Thu Jul 08, 2004 3:35 pm    Post subject: The Newest Build (2.6.3) - Lang Built in? Reply with quote

Hi guys, I have been working very hard trying to get Internationization of Smarty going, but anyway, While I was working with it , i noticed that Smarty already has some sort of language support built in with the block function.

In my main setup I see:

[php:1:d6f31718d8]<?php
global $lang;
include_once('lang/language.php');
function tra($content)
{
global $lang;
if ($content) {
if(isset($lang[$content])) {
return '+'.$lang[$content].'+';
} else {
return '-'.$content.'-';
}
}
}
?>[/php:1:d6f31718d8]

Will this interfere with any plugin that I installed, in which I am also trying to make a block delimitor to translate? It seems this built in Smarty thing operates with {tr}.. Is this a translation mechinism? Have I been left in the dark? Have i been trying to internationalize yet its already done and built in? just what is this mysterious {tr}, someone help! Smile PLEASE Smile
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Thu Jul 08, 2004 3:48 pm    Post subject: Reply with quote

Where do you see that? It's not part of the official distribution.
Back to top
View user's profile Send private message
NewfieBilko
Smarty Regular


Joined: 21 Jun 2004
Posts: 41

PostPosted: Thu Jul 08, 2004 4:05 pm    Post subject: Reply with quote

well i dont know but I got this version off the net and it has {tr}'s built in.. Does this mean that my vertsion is already internationalized? lkike WTF!!!! really....

It has TR's and some sort of block function, but I can't seem to get it working, its very dummie.

That code is in my setup.php

It refers to code in /lang/languge.php:

[php:1:c5fbbed4bb]<?php

<?php
$lang=Array(
"Administration" => "admi",
"Links/Commands" => "Links/Commands",
"Preferences" => "Preferences",
"Wiki Features" => "Wiki Features",
"##end###" => "###end###");
?>


?>[/php:1:c5fbbed4bb]

but i really dont rmemeber trying to impliment this one. Although I have tried implimenting johns IntSmarty.. I hope the 2 arn't conflicting.... When I tried johns, i get the errors back:
[php:1:c5fbbed4bb]<?php


Warning: Smarty plugin error: [in leftbar.tpl line 4]: unknown tag - 'l' in /var/www/php2/Smarty/Smarty.class.php on line 1889

Warning: Smarty plugin error: [in leftbar.tpl line 4]: unknown tag - '/l' in /var/www/php2/Smarty/Smarty.class.php on line 1889

Fatal error: Call to undefined function: () in /var/www/php2/templates_c/N626/N626615291/leftbar.tpl.php on line 8


?>[/php:1:c5fbbed4bb]



PS why can't someone just impliment it correctly and have a download for international smarty ARG , thanks btw
Back to top
View user's profile Send private message
NewfieBilko
Smarty Regular


Joined: 21 Jun 2004
Posts: 41

PostPosted: Thu Jul 08, 2004 4:08 pm    Post subject: Reply with quote

sorry, i think the build i am using is actually like 2.4 or something.. anyhow, i just found this code in my system, i didn't even know it was there and dont know how to use it.. it is in the file "get_strings.php"

[php:1:fa031bd405]<?php
<?
// Cambiar lo que busca segun sea .php o .tpl

$languages = Array('en','sp');

$files = Array();

$handle=opendir('templates');
while ($file = readdir($handle))
{
if($file=='.'||$file=='..')
continue;
if(substr($file,strlen($file)-3,3)=="tpl") {
print("File: $file<br/>");
$files[] = 'templates/'.$file;
}
}
closedir($handle);

$handle=opendir('.');
while ($file = readdir($handle))
{
if($file=='.'||$file=='..')
continue;
if(substr($file,strlen($file)-3,3)=="php") {
print("File: $file<br/>");
$files[] = $file;
}
}
closedir($handle);



foreach($languages as $sel) {
include_once("lang/$sel/language.php");
$fw = fopen("lang/$sel/new_language.php",'w+');
print("&?php\n<br/>\$lang=Array(\n<br/>");
fwrite($fw,"<?php\n\$lang=Array(\n");
foreach($files as $file) {
$fp = fopen($file,"r");
$data = fread($fp,filesize($file));
fclose($fp);
preg_match_all("/\{tr\}([^\{]+)\{\/tr\}/",$data,$words);
foreach(array_unique($words[1]) as $word) {
if(isset($lang[$word])) {
print('"'.$word.'" => "'.$lang[$word].'",'."\n<br/>");
fwrite($fw,'"'.$word.'" => "'.$lang[$word].'",'."\n");
} else {
print('+++"'.$word.'" => "'.$word.'",'."\n<br/>");
fwrite($fw,'"'.$word.'" => "'.$word.'",'."\n");
}
}
preg_match_all("/tra\(\"([^\"]+)\"\)/",$data,$words);
foreach(array_unique($words[1]) as $word) {
if(isset($lang[$word])) {
print('<b>"'.$word.'" => "'.$lang[$word].'",'."</b>\n<br/>");
fwrite($fw,'"'.$word.'" => "'.$lang[$word].'",'."\n");
} else {
print('<b>+++"'.$word.'" => "'.$word.'",'."</b>\n<br/>");
fwrite($fw,'"'.$word.'" => "'.$word.'",'."\n");
}
}
}
print('"'.'##end###'.'" => "'.'###end###'.'"'.");?&\n<br/>");
fwrite($fw,'"'.'##end###'.'" => "'.'###end###'.'");'."\n".'?>'."\n");
fclose($fw);
unlink("lang/$sel/old.php");
rename("lang/$sel/language.php","lang/$sel/old.php");
rename("lang/$sel/new_language.php","lang/$sel/language.php");
}
?>

?>[/php:1:fa031bd405]

!!!!!
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7367
Location: Lincoln Nebraska, USA

PostPosted: Thu Jul 08, 2004 4:22 pm    Post subject: Reply with quote

Get your virus-free Smarty here:

http://smarty.php.net/

Wink
Back to top
View user's profile Send private message Visit poster's website
NewfieBilko
Smarty Regular


Joined: 21 Jun 2004
Posts: 41

PostPosted: Thu Jul 08, 2004 6:01 pm    Post subject: Reply with quote

LOL Razz


God knows where this code came from.. From all the tries i've put into making this international already it probably belongs to IntSmarty.

All i know is I need to get my Smarty Internationalized. I need to have it so that for the session, the user will have his language of choice selected. I am looking at taking the goods from News-Maniac and putting them into the regular smarty, but this seems hard.. He re-wrote the whole thing in order to make it so that every word /title/header is all variables and hotswaps the lang files. This would be cool to have in the normal smarty,kind of a cross of moodle/smarty then. But in the mean time i've alos been working on the more NORMAL, and accepted way, that people have todl me about, by using block delimiters such as {L} to draw language tables and such.. then there is get-text, whatever that is. I am willing to do anything for a bit of advice here guys, preferably from someone who already has made an international smarty, what do you guys think is the best way to go about this problemuse variable hot swapping or draing language tables like John's IntSmarty? If someone arleady has a coded international system do send the source Wink LOL anyway , some help!!! $$$$
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Plugins 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