Location: PHPKode > projects > O - OpenSource GroupWare > osgw/config/install_languages.php
<?php
/**************************************************************************
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   @Authors:	Ryan Thompson(hide@address.com)
***************************************************************************/
$service['no_session'] = TRUE;
require('../config.inc.php');

//First we clean out the database. My effect administrative changes to the messages but we're assuming it's
//NOT an upgrade.
$db->query("DELETE FROM o_text");

$languages = unserialize(urldecode(stripslashes($_GET['langs'])));

foreach($languages AS $lang)
{
	//There seems to be a problem with the languages being added to the database with 
	//whitespace (This is a temporary fix)
	$tmp = rtrim(strtolower($lang));
		
	$handle = opendir('../');
	while (false !== ($d = readdir($handle))) 
	{
		if(!in_array($d, $system_dirs) && is_dir($root_dir. "/".$d) )
		{
			if(file_exists($root_dir ."/$d/config/text/". $tmp))
			{
				include($root_dir ."/$d/data.php");
				
				
				
				
				$fp = fopen($root_dir ."/$d/config/text/". $tmp, 'r');
				while(!feof($fp))
				{
					$data = explode('=>', fgets($fp, 1024));
					$id_text = trim($data[0]);
					$message = trim($data[1]);
					if(strlen($id_text) != 0)
					{

		$query = "INSERT INTO o_text (id_text, service, language, messages) 
			VALUES	('$id_text', '{$service['code']}', '$tmp', '$message')";
						
						$db->query($query);
					}
				}
				fclose($fp);
			} else {
				echo "File $tmp in service $d doesn't exist";
			}
		}
	}
	$sql = "UPDATE o_languages SET enabled = '1' WHERE lg_id='$lang'";
	$db->query($sql);	
	
		
}
$sql = "INSERT INTO o_preferences (service, user_id, preference, value)
		VALUES ('gl','1','language','$lang')";
$db->query($sql);

header('Location: ./general_config.php');
Return current item: O - OpenSource GroupWare