Jump to content

Translation by User, two files


Tanja

Recommended Posts

I want that User can help with translation ( it will be only possible for registered Users and will not update the actual files by itself). For my own I translate with google (therefore are the notranslation span) but everyone knows how bad translation is sometimes and so Users should be able to edit the translation...

What I want to have: a form with translation - english text - edit translation

 

At the moment i have this:

if (! isset ($_POST["submit"]))
   {
      
      $data = file ("landneu.php");

    
      echo "<form method='POST' action='" . $_SERVER["PHP_SELF"] . "'>\n";
      echo "<table>\n";
     
      foreach ($data as $line)
      {
        $line = trim($line);

        if (strpos ($line, "=") !== false)
        {
           $values = explode ("=", $line);
		   $text = preg_replace('/";/','', $values);
		   $text1 = preg_replace('/"/','', $text);

           echo " <tr>\n";
           echo "   <td>\n";
           echo "   <span class='notranslate'>$text1[1]</span><input type='hidden' name='namen[]' value='" . $text1[0] . "'>\n";
           echo "   </td>\n";
		   
		   echo "   <td>\n";
           echo "   <span class='notranslate'>";

		HERE SHOULD BE THE ENGLISH TRANSLATION;
		  
	   echo "</span> \n";
           echo "   </td>\n";
		   
		   
           echo "   <td>\n";
           echo "    <input type='text' size='100' name='values[]' value='" . $text1[1] . "'>\n";
           echo "   <td>\n";
           echo " </tr>\n";
        }
      }
      echo " <tr>\n";
      echo "  <td colspan='2' align='center'><input type='submit' name='submit' value='Speichern'></td>\n";
      echo " <tr>\n";
      echo "</table>\n";
      echo "</form>\n";
   }
   else
   {

      if (isset($_POST["namen"]) && isset($_POST["values"]))
      {
         $namen  = $_POST["namen"];
         $values = $_POST["values"];

         $count = count($namen);

         $data = array();

         for ($i = 0; $i < $count; $i++)
         {
		 $data[] = '
		 '. $namen[$i] .' ="' . stripslashes($values[$i]) . '";
		 ';
         }

         $fp = fopen ("landneu.php", "w");

         if ($fp)
         {
            fputs ($fp, "<?");
 

            foreach ($data as $line)
              fputs($fp, $line);

            fputs ($fp, "?>");

            fclose ($fp);
         }
      }
   }

How can I get always the english translation in the middle from lang_en.php? So that everyone can see, which words have to translate?

For example, in landneu.php $dog="Perro"; in lang_en.php $dog="Dog"; form should be Perro - Dog - field for translation.  Maybe google will translate dog with cat, then (at the moment) i see only the wrong translation and don´t know originally

word.

 

Link to comment
https://forums.phpfreaks.com/topic/276996-translation-by-user-two-files/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.