forked from simpleinvoices/simpleinvoices
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
$LANG strings insertion script added
Usage: http://si.domain.tld/lang/lang_insert.php?l=tr_TR to get the lang.php file for Turkish. Edit output to update Date of update and manually translate and update the translation status flag at the end of each line
- Loading branch information
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?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 | ||
// | ||
// 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 | ||
*/ | ||
|
||
$lang_cmp = (isset($_REQUEST['l']) ? trim($_REQUEST['l']) : false); | ||
|
||
if ($lang_cmp === false) die('No language given'); | ||
|
||
// $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; | ||
// } elseif ((substr($line, 0, 6) == '$LANG[') && (substr($line, -5) == '";//0')) { | ||
} elseif ( (!(preg_match('/^\$LANG\[.*;\s*\/\/\s*1/', $line))) | ||
&& (preg_match('/^\$LANG\[.*;\s*\/\/\s*0/', $line)) ) { | ||
// Untranslated strings in lang file | ||
$ukeyarr = explode("'", $line, 3); | ||
$ukey = $ukeyarr[1]; | ||
unset($ukeyarr); | ||
unset($LANG[$ukey]); | ||
} | ||
} | ||
|
||
foreach ($LANG_en AS $k => $v) { | ||
if (! isset($LANG[$k])) { | ||
// Untranslated String | ||
$LANG[$k][0] = $v; | ||
$LANG[$k][1] = 0; | ||
} else { | ||
// Translated String | ||
$v = $LANG[$k]; | ||
unset($LANG[$k]); | ||
$LANG[$k][0] = $v; | ||
$LANG[$k][1] = 1; | ||
} | ||
} | ||
|
||
$LANG_gen = Array(); | ||
$LANG_title = Array(); | ||
foreach ($LANG as $k => $v) { | ||
$basestr = '$LANG[' . "'" . $k ."'" . '] = "' . $v[0] . '";//' . $v[1]; | ||
if (substr($k, 0, 5) == 'title') $LANG_title[$k] = $basestr; | ||
else $LANG_gen[$k] = $basestr; | ||
} | ||
|
||
ksort($LANG_gen); | ||
|
||
echo $preamble; | ||
|
||
foreach ($LANG_gen as $v) echo $v . $nl; | ||
echo $nl; | ||
foreach ($LANG_title as $v) echo $v . $nl; | ||
|
||
echo $nl; | ||
echo '?>'; | ||
echo $nl; | ||
|
||
?> |