Translate using array_slice!?
Posted: Sun Oct 05, 2008 5:06 pm
I have a page where I have all the language saved in a mysql db. Now I want to create a script so I can translate the page to different languages in a easy way. Everything written on my page is generated by language snippets like this:
It reffers to a page with the refering line like this:
This page is generated from mysql like this:
Now what I want is an easy way to translate this, and I thourgt I would do it like this:
Now this should give the benefit, that if new tagnames is added I would be able to see it in this script and then translate, but...
I keep getting this error:
Warning: array_slice() expects parameter 1 to be array, null given in /home/mypage/public_html/admin/translate.php on line 71
I can't figure out where it goes wrong.
I have these fields in my DB:
id
lang_id
tagname
string
Can somebody please help!!!
Code: Select all
<? echo ''._TOOLBAR_ADDLINK_TEXT_HEADER.''; ?>Code: Select all
define("_TOOLBAR_ADDLINK_TEXT_HEADER","Welcome to the ToolBar");Code: Select all
$sql = mysql_query("SELECT * FROM ".$prefix."_lang_code WHERE lang_id = '1'");
while($row = mysql_fetch_array($sql)) {
define("_".$row['tagname']."","".$row['string']."");
}Code: Select all
$langs = array();
$langs[2] = array();
$sql = mysql_query("SELECT * FROM ".$prefix."_lang_code WHERE lang_id = '1'");
while($row = mysql_fetch_array($sql)) {
$langs[$row['lang_id']][] = $row['tagname'];
}
$sql = mysql_query("SELECT * FROM ".$prefix."_lang_code WHERE lang_id = '2'");
while($row = mysql_fetch_array($sql)) {
if(!in_array($row['tagname'], $langs['2'])) {
$edit[] = $row;
}
}
echo "Still needs to be translated: ".count($edit);
$slice = array_slice($edit, 0, 1);I keep getting this error:
Warning: array_slice() expects parameter 1 to be array, null given in /home/mypage/public_html/admin/translate.php on line 71
I can't figure out where it goes wrong.
I have these fields in my DB:
id
lang_id
tagname
string
Can somebody please help!!!