Esempio n. 1
0
 function generate_properties_file($filepath, $keys2values)
 {
     preg_match("/^((.*)\\/)?(.+?)\$/", $filepath, $matches);
     exec("mkdir -p \"" . $matches[1] . "\"");
     $outp = fopen($filepath, "w");
     fwrite($outp, "# Copyright by many contributors; see http://babel.eclipse.org/\n");
     foreach ($keys2values as $key => $trans) {
         fwrite($outp, "\n" . $key . "=");
         # echo "${leader1S}${leaderS}${leaderS}${leaderS}" . $key . "=";
         if ($trans) {
             # json_encode returns the string with quotes fore and aft.  Need to strip them.
             # $tr_string = preg_replace('/^"(.*)"$/', '${1}', json_encode($trans));
             # $tr_string = str_replace('\\\\', '\\', $tr_string);
             $tr_string = toescapedunicode($trans);
             fwrite($outp, $tr_string);
             # echo $trans;
         }
         fwrite($outp, "\n");
     }
     fclose($outp);
 }
Esempio n. 2
0
             if (strlen($value) > 100) {
                 $value = substr($value, 0, 100) . " ...";
             }
             $pseudo_translations_indexes[$properties_file['project_id']][] = "\n\t\t<li><a href=\"http://babel.eclipse.org/babel/translate.php?project=" . $properties_file['project_id'] . "&version=" . $properties_file['version'] . "&file=" . $properties_file['origname'] . "&string=" . $strings_row['name'] . "\">" . $properties_file['project_id'] . $strings_row['string_id'] . "</a>&nbsp;" . $value . "</li>";
         }
     } else {
         $sql = "SELECT\n\t\t\t\t\t\tstrings.name AS 'key', \n\t\t\t\t\t\tstrings.value AS orig, \n\t\t\t\t\t\ttranslations.value AS trans\n\t\t\t\t\t\tFROM strings, translations\n\t\t\t\t\t\tWHERE strings.string_id = translations.string_id\n\t\t\t\t\t\tAND strings.file_id = " . $properties_file['file_id'] . "\n\t\t\t\t\t\tAND strings.is_active\n\t\t\t\t\t\tAND strings.non_translatable = 0\n\t\t\t\t\t\tAND translations.language_id = " . $language_id . "\n\t\t\t\t\t\tAND translations.is_active";
         $strings_result = mysql_query($sql);
         while (($strings_row = mysql_fetch_assoc($strings_result)) != null) {
             fwrite($outp, "\n" . $strings_row['key'] . "=");
             # echo "${leader1S}${leaderS}${leaderS}${leaderS}" . $strings_row['key'] . "=";
             if ($strings_row['trans']) {
                 # json_encode returns the string with quotes fore and aft.  Need to strip them.
                 # $tr_string = preg_replace('/^"(.*)"$/', '${1}', json_encode($strings_row['trans']));
                 # $tr_string = str_replace('\\\\', '\\', $tr_string);
                 $tr_string = toescapedunicode($strings_row['trans']);
                 fwrite($outp, $tr_string);
                 # echo $strings_row['trans'];
             } else {
                 fwrite($outp, $strings_row['orig']);
             }
         }
     }
     /*
      * Finish the properties file
      */
     fclose($outp);
     echo "{$leader}{$leader}{$leader}Completed  properties file " . $dirname . $filename . "\n";
 }
 /*
  * Copy in the various legal files