Index: config.php.sample
===================================================================
--- config.php.sample	(revision 1044)
+++ config.php.sample	(working copy)
@@ -151,4 +151,7 @@
 define("IA_CAPTCHA_PUBLIC_KEY", "6LesuwQAAAAAAPHgdh9Hem1KJfvd5Ng1yRoIweio");
 define("IA_CAPTCHA_PRIVATE_KEY", "6LesuwQAAAAAAF3FUPWFGQD1xPITFagjqWUO9Urs");
 
+// Current LANGUAGE
+define("IA_CURRENT_LANGUAGE", "en");
+
 ?>
Index: lang/driver.php
===================================================================
--- lang/driver.php	(revision 0)
+++ lang/driver.php	(revision 0)
@@ -0,0 +1,23 @@
+<?php
+
+// load the language file if language is not romanian
+if(IA_CURRENT_LANGUAGE != 'ro') {
+    require_once(IA_CURRENT_LANGUAGE . ".php");
+}
+
+function translate($string) {
+    global $txt;
+
+    $key = $string;
+    while(stripslashes($key) != $key) {
+        $key = stripslashes($key);
+    }
+
+    if(isset($txt[IA_CURRENT_LANGUAGE][$key])) {
+        return $txt[IA_CURRENT_LANGUAGE][$key];
+    } else {
+        return $string;
+    }
+}
+
+?>
Index: lang/en.php
===================================================================
--- lang/en.php	(revision 0)
+++ lang/en.php	(revision 0)
@@ -0,0 +1,24 @@
+<?php
+$txt["en"]["Arhiva de probleme"] = "Archive issues";
+$txt["en"]["Arhiva educationala"] = "Educational Archive";
+$txt["en"]["Concursuri"] = "Contests";
+$txt["en"]["Concursuri virtuale"] = "Virtual Contests";
+$txt["en"]["nou!"] = "new!";
+$txt["en"]["Clasament"] = "Rating";
+$txt["en"]["Articole"] = "Articles";
+$txt["en"]["Downloads"] = "Downloads";
+$txt["en"]["Links"] = "Links";
+$txt["en"]["Documentatie"] = "Documentation";
+$txt["en"]["Despre infoarena"] = "About infoarena";
+$txt["en"]["Monitorul de evaluare"] = "Monitor assessment";
+$txt["en"]["Trimite solutii"] = "Send solutions";
+$txt["en"]["Contul meu"] = "My Account";
+$txt["en"]["Ma inregistrez!"] = "I register!";
+$txt["en"]["Mi-am uitat parola..."] = "I forgot my password ...";
+$txt["en"]["membri inregistrati"] = "Registered members";
+$txt["en"]["Pagini recente"] = "Recent Pages";
+$txt["en"]["Autentificare"] = "Login";
+$txt["en"]["Cont de utilizator"] = "User account";
+$txt["en"]["Parola"] = "Password";
+$txt["en"]["Pastreaza-ma autentificat 5 zile"] = "Keep me logged in 5 days";
+?>
Index: lang/lib/google.translator.php
===================================================================
--- lang/lib/google.translator.php	(revision 0)
+++ lang/lib/google.translator.php	(revision 0)
@@ -0,0 +1,78 @@
+<?php
+
+/**
+ * Translating language with Google API
+ * @author gabe@fijiwebdesign.com
+ * @version $Id$
+ * @license - Share-Alike 3.0 (http://creativecommons.org/licenses/by-sa/3.0/)
+ * 
+ * Google requires attribution for their Language API, please see: http://code.google.com/apis/ajaxlanguage/documentation/#Branding
+ * 
+ */
+class Google_Translate_API {
+
+        /**
+         * Translate a piece of text with the Google Translate API
+         * @return String
+         * @param $text String
+         * @param $from String[optional] Original language of $text. An empty String will let google decide the language of origin
+         * @param $to String[optional] Language to translate $text to
+         */
+        function translate($text, $from = '', $to = 'en') {
+                $url = 'http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q='.rawurlencode($text).'&langpair='.rawurlencode($from.'|'.$to);
+                $response = file_get_contents(
+                        $url,
+                        null,
+                        stream_context_create(
+                                array(
+                                        'http'=>array(
+                                        'method'=>"GET",
+                                        'header'=>"Referer: http://".$_SERVER['HTTP_HOST']."/\r\n"
+                                        )
+                                )
+                        )
+                );
+                if (preg_match("/{\"translatedText\":\"([^\"]+)\"/i", $response, $matches)) {
+                        return self::_unescapeUTF8EscapeSeq($matches[1]);
+                }
+                return false;
+        }
+        
+        /**
+         * Convert UTF-8 Escape sequences in a string to UTF-8 Bytes. Old version.
+         * @return UTF-8 String
+         * @param $str String
+         */
+        function __unescapeUTF8EscapeSeq($str) {
+                return preg_replace_callback("/\\\u([0-9a-f]{4})/i", create_function('$matches', 'return html_entity_decode(\'&#x\'.$matches[1].\';\', ENT_NOQUOTES, \'UTF-8\');'), $str);
+        }
+        
+        /**
+         * Convert UTF-8 Escape sequences in a string to UTF-8 Bytes
+         * @return UTF-8 String
+         * @param $str String
+         */
+        function _unescapeUTF8EscapeSeq($str) {
+                return preg_replace_callback("/\\\u([0-9a-f]{4})/i", create_function('$matches', 'return Google_Translate_API::_bin2utf8(hexdec($matches[1]));'), $str);
+        }
+        
+        /**
+         * Convert binary character code to UTF-8 byte sequence
+         * @return String
+         * @param $bin Mixed Interger or Hex code of character
+         */
+        function _bin2utf8($bin) {
+                if ($bin <= 0x7F) {
+                        return chr($bin);
+                } else if ($bin >= 0x80 && $bin <= 0x7FF) {
+                        return pack("C*", 0xC0 | $bin >> 6, 0x80 | $bin & 0x3F);
+                } else if ($bin >= 0x800 && $bin <= 0xFFF) {
+                        return pack("C*", 11100000 | $bin >> 11, 0x80 | $bin >> 6 & 0x3F, 0x80 | $bin & 0x3F);
+                } else if ($bin >= 0x10000 && $bin <= 0x10FFFF) {
+                        return pack("C*", 11100000 | $bin >> 17, 0x80 | $bin >> 12 & 0x3F, 0x80 | $bin >> 6& 0x3F, 0x80 | $bin & 0x3F);
+                }
+        }
+        
+}
+
+?>
Index: lang/update.php
===================================================================
--- lang/update.php	(revision 0)
+++ lang/update.php	(revision 0)
@@ -0,0 +1,137 @@
+<?php
+set_time_limit(0);
+
+require_once("lib/google.translator.php");
+require_once("update_settings.inc");
+
+/* returns the extension of the $filename */
+function get_extension($filename) {
+    $path_info = pathinfo($filename);
+    return strtolower($path_info['extension']);
+}
+
+/* returns an array of files with "good_extensions" inside $dir;
+   for translation purpose, good extensions will be php, php5, etc. */
+function get_file_structure($dir, $good_extensions) {
+    $fd = opendir($dir);
+    $return_array = array();
+    while($fs = readdir($fd)) {
+        if($fs != "." && $fs != "..") {
+            if(is_file($dir . "/$fs")) {
+                $extension = get_extension($fs);
+                if(in_array($extension, $good_extensions)) {
+                    $return_array[] = $dir . "/$fs";
+                }
+            } else {
+                $return_array = array_merge($return_array, get_file_structure($dir . "/$fs", $good_extensions));
+            }
+        }
+    }
+    return $return_array;
+}
+
+/* returns the content of a specific file */
+function get_file_content($filename) {
+    $fh = fopen($filename, "r");
+    $text = "";
+    while($s = fgets($fh)) {
+        $text .= $s;
+    }
+    fclose($fh);
+    return $text;
+}
+
+/* return all terms which need to be translated at the end of this script
+   the terms are found by parsing the contents for the translate function */
+function get_file_translations($filename) {
+    $return_array = array();
+
+    $contents = get_file_content($filename);
+    while(stripos($contents, "translate(") !== false) {
+        $translate_pos = stripos($contents, "translate(");
+        $current_word = "";
+        for($j = $translate_pos + strlen("translate('"); !(($contents[$j] == '"' || $contents[$j] == '\'') && $contents[$j + 1] == ')'); $j++) {
+            $current_word .= $contents[$j];
+        }
+
+        $return_array[] = $current_word;
+        $contents = substr($contents, $translate_pos + 1);
+    }
+
+    return $return_array;
+}
+
+echo "Creating the file structure...\n";
+$file_array = get_file_structure($base_dir, $translate_extensions);
+echo "Finished creating the file structure\n\n";
+
+echo "Searching for terms which will be translated...\n";
+$translation_strings = array();
+foreach($file_array as $filename) {
+    $translation_strings = array_merge($translation_strings, get_file_translations($filename));
+}
+
+$total_translations = count($translation_strings);
+echo "Finished searching for terms to be translated... found " . $total_translations . " terms\n\n";
+
+$last_percent = 0;
+
+// go over each language one by one and create it's own language file
+foreach($languages as $translate_to) {
+    echo "Creating $translate_to language file..\n";
+    $current_translations = 0;
+
+    if(is_file($translate_to . ".php")) {
+        @require_once($translate_to . ".php");
+    }
+
+    if(!isset($txt[$translate_to])) {
+        $txt[$translate_to] = array();
+    }
+
+    foreach($translation_strings as $phrase) {
+        while(stripslashes($phrase) != $phrase) {
+            $phrase = stripslashes($phrase);
+        }
+
+        $current_translations++;
+        $new_percent = (int)($current_translations / $total_translations * 100);
+
+        // show some percents.. useful to know where you stand
+        if($new_percent != $last_percent && (int)($new_percent / 10) > (int)($last_percent / 10)) {
+            echo "$new_percent % completed\n";
+        }
+
+        $last_percent = $new_percent;
+
+        $key = $phrase;
+        while($key != stripslashes($key)) {
+            $key = stripslashes($key);
+        }
+        
+        if(isset($txt[$translate_to][$key])) {
+            continue;
+        } else {
+            $trans_text = Google_Translate_API::translate($phrase, $initial_language, $translate_to);
+            $txt[$translate_to][$key] = $trans_text;
+        }
+
+    }
+
+    $fh = fopen($translate_to . ".php", "w");
+    fwrite($fh, "<?php\n");
+    foreach($txt[$translate_to] as $key => $value) {
+        $new_key = $key;
+        while(stripslashes($new_key) != $new_key) {
+            $new_key = stripslashes($new_key);
+        }
+        $new_key = addslashes($new_key);
+
+        fwrite($fh, "\$txt[\"$translate_to\"][\"$new_key\"] = \"$value\";\n");
+    }
+    fwrite($fh, "?>\n");
+    fclose($fh);
+
+}
+
+?>
Index: lang/update_settings.inc
===================================================================
--- lang/update_settings.inc	(revision 0)
+++ lang/update_settings.inc	(revision 0)
@@ -0,0 +1,8 @@
+<?php
+
+$languages = array("en");
+$initial_language = "ro";
+$translate_extensions = array("php", "php5", "html");
+$base_dir = "../www";
+
+?>
Index: www/index.php
===================================================================
--- www/index.php	(revision 1044)
+++ www/index.php	(working copy)
@@ -12,6 +12,7 @@
 require_once(IA_ROOT_DIR."www/utilities.php");
 require_once(IA_ROOT_DIR."www/identity.php");
 require_once(IA_ROOT_DIR."common/db/db.php");
+require_once(IA_ROOT_DIR."lang/driver.php");
 db_connect();
 
 // restore identity (if such a session exists)
Index: www/views/form_login.php
===================================================================
--- www/views/form_login.php	(revision 1044)
+++ www/views/form_login.php	(working copy)
@@ -1,24 +1,24 @@
 <form action="<?= html_escape(url_login()) ?>" method="post" class="login">
 <fieldset>
-    <legend><img src="<?= html_escape(url_static('images/icons/login.png')) ?>" alt="!" /> Autentificare</legend>
+    <legend><img src="<?= html_escape(url_static('images/icons/login.png')) ?>" alt="!" /> <?= translate('Autentificare') ?></legend>
     <ul class="form">
 <?= view_form_field_li(array(
-        'name' => 'Cont de utilizator',
+        'name' => translate('Cont de utilizator'),
         'type' => 'string',
         'access_key' => 'c',
 ), 'username') ?>
 <?= view_form_field_li(array(
-        'name' => 'Parola',
+        'name' => translate('Parola'),
         'type' => 'string',
         'is_password' => true,
         'access_key' => 'p',
 ), 'password') ?>
         <li>
             <input type="checkbox" value="on" id="form_remember" name="remember" class="checkbox"<?= fval('remember') ? ' checked="checked"' : '' ?>/>
-            <label class="checkbox" for="form_remember">Pastreaza-ma autentificat 5 zile</label>
+            <label class="checkbox" for="form_remember"><?= translate('Pastreaza-ma autentificat 5 zile') ?></label>
         </li>
         <li>
-            <input type="submit" value="Autentificare" id="form_submit" class="button important" />
+            <input type="submit" value="<?= translate("Autentificare") ?>" id="form_submit" class="button important" />
         </li>
     </ul>
 </fieldset>
Index: www/views/header.php
===================================================================
--- www/views/header.php	(revision 1044)
+++ www/views/header.php	(working copy)
@@ -90,21 +90,21 @@
 <div id="sidebar">
     <ul id="nav" class="clear">
         <li><a href="<?= html_escape(url_home()) ?>">Home</a></li>
-        <li><?= format_link_access(url_textblock('arhiva'), "Arhiva de probleme", 'a') ?></li>
-        <li><a href="<?= html_escape(url_textblock('arhiva-educationala')) ?>">Arhiva educationala</a></li>
-        <li><a href="<?= html_escape(url_textblock('concursuri')) ?>">Concursuri</a></li>
-        <li><a href="<?= html_escape(url_textblock('concursuri-virtuale')) ?>">Concursuri virtuale<span style="color: red; font-weight:bold;"><sup>nou!</sup></span></a></li> 
-        <li><a href="<?= html_escape(url_textblock('clasament-rating')) ?>">Clasament</a></li>
-        <li><a href="<?= html_escape(url_textblock('articole')) ?>">Articole</a></li>
-        <li><a href="<?= html_escape(url_textblock('downloads')) ?>">Downloads</a></li>
-        <li><a href="<?= html_escape(url_textblock('links')) ?>">Links</a></li>
-        <li><a href="<?= html_escape(url_textblock('documentatie')) ?>">Documentatie</a></li>
-        <li><a href="<?= html_escape(url_textblock('despre-infoarena')) ?>">Despre infoarena</a></li>
+        <li><?= format_link_access(url_textblock('arhiva'), translate("Arhiva de probleme"), 'a') ?></li>
+        <li><a href="<?= html_escape(url_textblock('arhiva-educationala')) ?>"><?= translate("Arhiva educationala") ?></a></li>
+        <li><a href="<?= html_escape(url_textblock('concursuri')) ?>"><?= translate('Concursuri') ?></a></li>
+        <li><a href="<?= html_escape(url_textblock('concursuri-virtuale')) ?>"><?= translate("Concursuri virtuale") ?><span style="color: red; font-weight:bold;"><sup><?= translate('nou!') ?></sup></span></a></li> 
+        <li><a href="<?= html_escape(url_textblock('clasament-rating')) ?>"><?= translate("Clasament") ?></a></li>
+        <li><a href="<?= html_escape(url_textblock('articole')) ?>"><?= translate('Articole') ?></a></li>
+        <li><a href="<?= html_escape(url_textblock('downloads')) ?>"><?= translate("Downloads")?></a></li>
+        <li><a href="<?= html_escape(url_textblock('links')) ?>"><?= translate('Links')?></a></li>
+        <li><a href="<?= html_escape(url_textblock('documentatie')) ?>"><?=translate("Documentatie")?></a></li>
+        <li><a href="<?= html_escape(url_textblock('despre-infoarena')) ?>"><?=  translate('Despre infoarena')   ?></a></li>
         <li class="separator"><hr/></li>
-        <li><?= format_link_access(url_monitor(array('user' => identity_get_username())), "Monitorul de evaluare", 'm') ?></li>
+        <li><?= format_link_access(url_monitor(array('user' => identity_get_username())), translate("Monitorul de evaluare"), 'm') ?></li>
         <?php if (!identity_is_anonymous()) { ?>
-        <li><a href="<?= html_escape(url_submit()) ?>"><strong>Trimite solutii</strong></a></li>
-        <li><?= format_link_access(url_account(), "Contul meu", 'c') ?></li>
+        <li><a href="<?= html_escape(url_submit()) ?>"><strong><?= translate('Trimite solutii') ?></strong></a></li>
+        <li><?= format_link_access(url_account(), translate("Contul meu"), 'c') ?></li>
         <?php } ?>
         </ul>
 
@@ -122,12 +122,12 @@
     <div id="login">
         <?php if (!isset($no_sidebar_login)) include(IA_ROOT_DIR.'www/views/form_login.php') ?>
         <p>
-        <?= format_link(url_register(), "Ma inregistrez!" ) ?><br/>
-        <?= format_link(url_resetpass(), "Mi-am uitat parola..." ) ?>
+        <?= format_link(url_register(), translate("Ma inregistrez!") ) ?><br/>
+        <?= format_link(url_resetpass(), translate("Mi-am uitat parola...") ) ?>
         </p>
     </div>
     <?php } ?>
-    <p class="user-count"><?php echo user_count(); ?> membri inregistrati</p>
+    <p class="user-count"><?php echo user_count(); ?> <?= translate('membri inregistrati') ?></p>
     <div id="srv_time" class="user-count" align="center"></div>
     <script type="text/javascript" src="<?= html_escape(url_static('js/time.js')) ?>"></script>
     <script type="text/javascript">loadTime(<?= format_date(null, "%H, %M, %S");?>);</script>
@@ -156,7 +156,7 @@
             $bstring .= "<a href=\"" . html_escape($rec_url) . "\">{$rec_title}</a>";
         }
     }
-    echo '<p id="breadcrumbs">Pagini recente &raquo; ' . $bstring . '</p>';
+    echo '<p id="breadcrumbs">' . translate('Pagini recente') . ' &raquo; ' . $bstring . '</p>';
 }
 
 ?>
