|
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 |
NewfieBilko Smarty Regular
Joined: 21 Jun 2004 Posts: 41
|
Posted: Thu Jul 08, 2004 3:35 pm Post subject: The Newest Build (2.6.3) - Lang Built in? |
|
|
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! PLEASE |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Thu Jul 08, 2004 3:48 pm Post subject: |
|
|
Where do you see that? It's not part of the official distribution. |
|
Back to top |
|
NewfieBilko Smarty Regular
Joined: 21 Jun 2004 Posts: 41
|
Posted: Thu Jul 08, 2004 4:05 pm Post subject: |
|
|
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 |
|
NewfieBilko Smarty Regular
Joined: 21 Jun 2004 Posts: 41
|
Posted: Thu Jul 08, 2004 4:08 pm Post subject: |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
|
Back to top |
|
NewfieBilko Smarty Regular
Joined: 21 Jun 2004 Posts: 41
|
Posted: Thu Jul 08, 2004 6:01 pm Post subject: |
|
|
LOL
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 LOL anyway , some help!!! $$$$ |
|
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
|
|