コード例 #1
0
ファイル: lang_insert.php プロジェクト: dadigo/simpleinvoices
<?php

/* **************
//	Purpose: To insert untranslated strings into language file
//			 and arrange the non title_* keys in alphabetical order
//	Author : Ap.Muthu
//	Release: 2013-10-18
//	Updated: 2013-10-19
//
//	Usage  : http://si_domain.com/lang/lang_insert.php?l=vi_VN
//			 The Source HTML would be the raw text for the lang.php file
*/
include_once "lang_functions.php";
$langs_defined = get_defined_langs();
// Ensure that the lang folder name is of correct format and get it
$lang_cmp = isset($_REQUEST['l']) && preg_match('/^[a-z]{2}_[a-z]{2}$/i', $_REQUEST['l']) ? $_REQUEST['l'] : (isset($argv[1]) ? trim($argv[1]) : false);
// Ensure that the requested lang folder exists
if (!in_array($lang_cmp, $langs_defined, true)) {
    die("Invalid Language.");
}
// $lang_cmp = "nb_NO";
include "en_GB/lang.php";
$LANG_en = $LANG;
unset($LANG);
$preamble = '';
$nl = chr(10);
include "{$lang_cmp}/lang.php";
$h = fopen("{$lang_cmp}/lang.php", "r");
while ($line = fgets($h)) {
    if (substr($line, 0, 6) != '$LANG[' && substr($line, 0, 2) != '?>') {
        $preamble .= $line;
コード例 #2
0
print sprintf("%-11s", 'New strings') . " | ";
print sprintf("%15s", 'Strings in file') . " | ";
print sprintf("%16s", 'Total translated') . " | ";
print sprintf("%8s", '% Done') . " | ";
//print sprintf("%10s", 'Authors');
print "\n";
print str_repeat("=", 106);
print "\n";


// The main language. Needed to compare the % done of the other languages.
$en_lang = process_lang_file('en_GB');
//echo "debug: en-gb, $en_lang[0], $en_lang[1]\n";

// Lets process the language folders.
foreach (get_defined_langs() as $lang_code) {

  // Redo the XML part thanks to a sugestion by Nicolas Ruflin.
  // Nicolas, thanks for the PHP lesson.
  $xml = simplexml_load_file("$lang_code/info.xml");

  $tmp = split(',', $xml->author);
  $xml->author = join(', ', $tmp);
  //echo "debug: $xml->name, $xml->author\n";
  
  /*
   Process the language files
  */
  
  $count = process_lang_file($lang_code);
  //echo "debug: $lang_code, $count[0], $count[1]\n";