mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-18 08:19:05 +01:00
Rework/improve generate_lang_file.php / generate_ldapsaisie.pot.sh scripts
This commit is contained in:
parent
b3f208aa60
commit
30daa59c8e
7 changed files with 1544 additions and 1099 deletions
|
@ -54,11 +54,17 @@ class LSconfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Récupération d'une valeur
|
* Get a specific configuration variable value
|
||||||
*
|
*
|
||||||
* @param[in] $var string Le nom de valeur à récupérer (Exemple : cacheSearch)
|
* @param[in] $var string The configuration variable name
|
||||||
|
* @param[in] $default mixed The default value to return if configuration variable
|
||||||
|
* is not set (Default : null)
|
||||||
|
* @param[in] $cast string The type of expected value. The configuration variable
|
||||||
|
* value will be cast as this type. Could be : bool, int,
|
||||||
|
* float or string. (Optional, default : raw value)
|
||||||
|
* @param[in] $data array The configuration data (optional)
|
||||||
*
|
*
|
||||||
* @retval mixed La valeur de la variable, ou false si son nom n'est parsable
|
* @retval mixed The configuration variable value
|
||||||
**/
|
**/
|
||||||
public static function get($var, $default=null, $cast=null, $data=null) {
|
public static function get($var, $default=null, $cast=null, $data=null) {
|
||||||
$vars = explode('.', $var);
|
$vars = explode('.', $var);
|
||||||
|
@ -87,6 +93,59 @@ class LSconfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get list of keys of a specific configuration variable
|
||||||
|
*
|
||||||
|
* @param[in] $var string The configuration variable name
|
||||||
|
* @param[in] $data array The configuration data (optional)
|
||||||
|
*
|
||||||
|
* @retval array An array of the keys of a specific configuration variable
|
||||||
|
**/
|
||||||
|
public static function keys($var, $data=null) {
|
||||||
|
$value = self :: get($var, null, null, $data);
|
||||||
|
return (is_array($value)?array_keys($value):array());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get list of configuration variables with their value that matching a specific pattern
|
||||||
|
*
|
||||||
|
* The character '*' could replace any part (expect the first one) of the configuration
|
||||||
|
* variable name. In this case, the keys of the parent value will be iterated to compose
|
||||||
|
* the result.
|
||||||
|
*
|
||||||
|
* @param[in] $pattern string The configuration variable pattern
|
||||||
|
* @param[in] $default mixed The default value to return if configuration variable
|
||||||
|
* is not set (optional, see self :: get())
|
||||||
|
* @param[in] $cast string The type of expected value (optional, see self :: get())
|
||||||
|
* @param[in] $data array The configuration data (optional, see self :: get())
|
||||||
|
*
|
||||||
|
* @retval array The list of matching configuration variables with their value
|
||||||
|
**/
|
||||||
|
public static function getMatchingKeys($pattern, $default=null, $cast=null, $data=null, $prefix=null) {
|
||||||
|
$return = array();
|
||||||
|
if ($pos = strpos($pattern, '*')) {
|
||||||
|
// Handle subkey
|
||||||
|
$root_key = (is_string($prefix)?"$prefix.":"").substr($pattern, 0, ($pos-1));
|
||||||
|
$suffix = substr($pattern, $pos+2, (strlen($pattern)-$pos));
|
||||||
|
$subkeys = self :: keys($root_key);
|
||||||
|
if ($suffix) {
|
||||||
|
foreach ($subkeys as $subkey)
|
||||||
|
$return = array_merge($return, self :: getMatchingKeys($suffix, $default, $cast, $data, "$root_key.$subkey"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
foreach ($subkeys as $subkey) {
|
||||||
|
$key = "$root_key.$subkey";
|
||||||
|
$return[$key] = self :: get($key, $default, $cast, $data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$key = (is_string($prefix)?"$prefix.":"").$pattern;
|
||||||
|
$return[$key] = self :: get($key, $default, $cast, $data);
|
||||||
|
}
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Définition d'une valeur
|
* Définition d'une valeur
|
||||||
*
|
*
|
||||||
|
|
2
public_html/lang/.gitignore
vendored
Normal file
2
public_html/lang/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
ldapsaisie-main.pot
|
||||||
|
ldapsaisie-templates.pot
|
Binary file not shown.
File diff suppressed because it is too large
Load diff
|
@ -30,26 +30,67 @@ chdir(dirname(__FILE__).'/../');
|
||||||
require_once('core.php');
|
require_once('core.php');
|
||||||
require_once('conf/config.inc.php');
|
require_once('conf/config.inc.php');
|
||||||
|
|
||||||
$withoutselectlist=False;
|
$available_onlys = array("config", "templates", "addons");
|
||||||
|
$only = null;
|
||||||
|
$available_withouts = array_merge($available_onlys, array("select-list"));
|
||||||
|
$withouts = array();
|
||||||
$copyoriginalvalue=False;
|
$copyoriginalvalue=False;
|
||||||
$interactive=False;
|
$interactive=False;
|
||||||
$output=False;
|
$output=False;
|
||||||
$additionalfileformat=False;
|
$additionalfileformat=False;
|
||||||
$lang=False;
|
$lang=False;
|
||||||
$encoding=False;
|
$encoding=False;
|
||||||
|
$available_formats=array('php', 'pot');
|
||||||
|
$format=$available_formats[0];
|
||||||
$translations=array();
|
$translations=array();
|
||||||
|
$debug = false;
|
||||||
|
$load_files = array();
|
||||||
|
function usage($error, $exit_code=0) {
|
||||||
|
global $argv, $available_withouts, $available_onlys;
|
||||||
|
if ($error)
|
||||||
|
echo "$error\n\n";
|
||||||
|
echo "Usage : ".$argv[0]." [file1] [file2] [-h] [options]\n";
|
||||||
|
echo " -W/--without Disable specified messages. Must be one of the following values :\n";
|
||||||
|
echo " '".implode("','", $available_withouts)."'\n";
|
||||||
|
echo " -O/--only Only handle specified messages. Must be one of the following values :\n";
|
||||||
|
echo " '".implode("','", $available_onlys)."'\n";
|
||||||
|
echo " -c/--copy-original-value Copy original value as translated value when no translated value exists\n";
|
||||||
|
echo " -i/--interactive Interactive mode : ask user to enter translated on each translation needed\n";
|
||||||
|
echo " -a/--additional-file-format Additional file format output\n";
|
||||||
|
echo " -l/--lang Load this specify lang (format : [lang].[encoding])\n";
|
||||||
|
echo " -o/--output Output file (default : stdout)\n";
|
||||||
|
echo " -f/--format Output file format : php or pot (default : php)\n";
|
||||||
|
echo " -d/--debug Enable debug mode\n";
|
||||||
|
exit($exit_code);
|
||||||
|
}
|
||||||
|
|
||||||
|
function realtive_path($path) {
|
||||||
|
if ($path[0] == '/')
|
||||||
|
return $path;
|
||||||
|
global $curdir;
|
||||||
|
return realpath($curdir)."/".$path;
|
||||||
|
}
|
||||||
|
|
||||||
if ($argc > 1) {
|
if ($argc > 1) {
|
||||||
// Change dir again to manage file input
|
|
||||||
chdir($curdir);
|
|
||||||
for ($i=1;$i<$argc;$i++) {
|
for ($i=1;$i<$argc;$i++) {
|
||||||
if (is_file($argv[$i])) {
|
if($argv[$i]=='--without' || $argv[$i]=='-W') {
|
||||||
@include($argv[$i]);
|
$i++;
|
||||||
foreach($GLOBALS['LSlang'] as $msg => $trans) {
|
$without = strtolower($argv[$i]);
|
||||||
$translations[$msg]=$trans;
|
if (!in_array($without, $available_withouts))
|
||||||
}
|
die("Invalid -W/--without parameter. Must be one of the following values : '".implode("','", $available_withouts)."'.\n");
|
||||||
|
elseif ($only)
|
||||||
|
die("You could not use only -W/--without parameter combined with -O/--only parameter.\n");
|
||||||
|
$withouts[] = $without;
|
||||||
}
|
}
|
||||||
elseif($argv[$i]=='--without-select-list' || $argv[$i]=='-W') {
|
elseif($argv[$i]=='--only' || $argv[$i]=='-O') {
|
||||||
$withoutselectlist=True;
|
$i++;
|
||||||
|
if ($only)
|
||||||
|
die("You could specify only on -O/--only parameter.\n");
|
||||||
|
$only = strtolower($argv[$i]);
|
||||||
|
if (!in_array($only, $available_onlys))
|
||||||
|
die("Invalid -O/--only parameter. Must be one of the following values : '".implode("','", $available_onlys)."'.\n");
|
||||||
|
elseif ($without)
|
||||||
|
die("You could not use only -O/--only parameter combined with -W/--without parameter.\n");
|
||||||
}
|
}
|
||||||
elseif($argv[$i]=='--copy-original-value' || $argv[$i]=='-c') {
|
elseif($argv[$i]=='--copy-original-value' || $argv[$i]=='-c') {
|
||||||
$copyoriginalvalue=True;
|
$copyoriginalvalue=True;
|
||||||
|
@ -75,54 +116,105 @@ if ($argc > 1) {
|
||||||
$i++;
|
$i++;
|
||||||
$output = $argv[$i];
|
$output = $argv[$i];
|
||||||
}
|
}
|
||||||
|
elseif($argv[$i]=='--format' || $argv[$i]=='-f') {
|
||||||
|
$i++;
|
||||||
|
$format = strtolower($argv[$i]);
|
||||||
|
if (!in_array($format, $available_formats)) {
|
||||||
|
die("Invalid -f/--format parameter. Must be one of the following values : '".implode("','", $available_formats)."'.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif($argv[$i]=='--debug' || $argv[$i]=='-d') {
|
||||||
|
$debug = true;
|
||||||
|
}
|
||||||
elseif($argv[$i]=='-h') {
|
elseif($argv[$i]=='-h') {
|
||||||
echo "Usage : ".$argv[0]." [file1] [file2] [-h] [options]\n";
|
usage();
|
||||||
echo " -W/--without-select-list Don't add possibles values of select list\n";
|
}
|
||||||
echo " -c/--copy-original-value Copy original value as translated value when no translated value exists\n";
|
else {
|
||||||
echo " -i/--interactive Interactive mode : ask user to enter translated on each translation needed\n";
|
$path = realtive_path($argv[$i]);
|
||||||
echo " -a/--additional-file-format Additional file format output\n";
|
if (is_file($path))
|
||||||
echo " -l/--lang Load this specify lang (format : [lang].[encoding])\n";
|
$load_files[] = $path;
|
||||||
echo " -o/--output Output file (default : stdout)\n";
|
else
|
||||||
exit(0);
|
usage($argv[$i]." : Invalid lang file to load.", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chdir(dirname(__FILE__).'/../');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$data=array();
|
$data=array();
|
||||||
|
|
||||||
function add($msg) {
|
function debug($msg) {
|
||||||
|
global $debug, $output;
|
||||||
|
if (!$debug) return true;
|
||||||
|
$fd = ($output?STDOUT: STDERR);
|
||||||
|
fwrite($fd, "$msg\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
function add($msg, $context=null) {
|
||||||
|
debug("add($msg, $context)");
|
||||||
if ($msg!='' && _($msg) == "$msg") {
|
if ($msg!='' && _($msg) == "$msg") {
|
||||||
global $data, $translations, $interactive, $copyoriginalvalue;
|
global $data, $translations, $interactive, $copyoriginalvalue, $format;
|
||||||
|
|
||||||
|
// Message already exists ?
|
||||||
if (array_key_exists($msg, $data)) {
|
if (array_key_exists($msg, $data)) {
|
||||||
|
if ($context && !in_array($context, $data[$msg]['contexts']))
|
||||||
|
$data[$msg]['contexts'][] = $context;
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
elseif (array_key_exists($msg, $translations)) {
|
|
||||||
$data[$msg]=$translations[$msg];
|
// Handle translation
|
||||||
|
$translation = "";
|
||||||
|
if (array_key_exists($msg, $translations)) {
|
||||||
|
$translation = $translations[$msg];
|
||||||
}
|
}
|
||||||
elseif ($interactive) {
|
elseif ($interactive && $format != 'pot') {
|
||||||
if ($copyoriginalvalue) {
|
if ($copyoriginalvalue) {
|
||||||
fwrite(STDERR, "\"$msg\"\n\n => Please enter translated string (or leave empty to copy original string) : ");
|
fwrite(STDERR, "\"$msg\"\n\n => Please enter translated string (or leave empty to copy original string) : ");
|
||||||
$in = trim(fgets(STDIN));
|
$in = trim(fgets(STDIN));
|
||||||
if ($in)
|
if ($in)
|
||||||
$data[$msg]=$in;
|
$translation = $in;
|
||||||
else
|
else
|
||||||
$data[$msg]=$msg;
|
$translation = $msg;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fwrite(STDERR, "\"$msg\"\n\n => Please enter translated string (or 'c' to copy original message, leave empty to pass) : ");
|
fwrite(STDERR, "\"$msg\"\n\n => Please enter translated string (or 'c' to copy original message, leave empty to pass) : ");
|
||||||
$in = trim(fgets(STDIN));
|
$in = trim(fgets(STDIN));
|
||||||
if ($in) {
|
if ($in) {
|
||||||
if ($in=="c")
|
if ($in=="c")
|
||||||
$data[$msg]=$msg;
|
$translation = $msg;
|
||||||
else
|
else
|
||||||
$data[$msg]=$in;
|
$translation = $in;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
$data[$msg] = array (
|
||||||
$data[$msg]="";
|
'translation' => $translation,
|
||||||
|
'contexts' => ($context?array($context):array()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addFromLSconfig($pattern, $value='value', $excludes=array()) {
|
||||||
|
debug("addFromLSconfig($pattern, array(".implode(',', $excludes)."))");
|
||||||
|
$keys = LSconfig :: getMatchingKeys($pattern);
|
||||||
|
debug("addFromLSconfig : ".count($keys)." matching key(s)");
|
||||||
|
foreach ($keys as $key => $value) {
|
||||||
|
debug("addFromLSconfig : $key = $value");
|
||||||
|
if ($value == 'key') {
|
||||||
|
// Get the last key parts as value and all other as key
|
||||||
|
$key_parts = explode('.', $key);
|
||||||
|
$value = $key_parts[count($key_parts)-1];
|
||||||
|
$key = implode('.', array_slice($key_parts, 0, count($key_parts)-1));
|
||||||
}
|
}
|
||||||
|
if (!in_array($value, $excludes) && is_string($value))
|
||||||
|
add($value, $key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load translation files
|
||||||
|
foreach($load_files as $path) {
|
||||||
|
debug("Load $path lang file");
|
||||||
|
@include($path);
|
||||||
|
foreach($GLOBALS['LSlang'] as $msg => $trans) {
|
||||||
|
$translations[$msg]=$trans;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,196 +228,184 @@ if ($lang && $encoding) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// LDAP Servers
|
/*
|
||||||
foreach($GLOBALS['LSconfig']['ldap_servers'] as $conf) {
|
* Manage configuration parameters
|
||||||
add($conf['name']);
|
*/
|
||||||
add($conf['subDnLabel']);
|
if (!in_array('config', $withouts) && (!$only || $only == 'config')) {
|
||||||
add($conf['recoverPassword']['recoveryHashMail']['subject']);
|
// LDAP Servers
|
||||||
add($conf['recoverPassword']['recoveryHashMail']['msg']);
|
$objects = array();
|
||||||
add($conf['recoverPassword']['newPasswordMail']['subject']);
|
foreach(LSconfig :: keys('ldap_servers') as $ldap_server_id) {
|
||||||
add($conf['recoverPassword']['newPasswordMail']['msg']);
|
addFromLSconfig("ldap_servers.$ldap_server_id.name");
|
||||||
if (is_array($conf['subDn'])) {
|
addFromLSconfig("ldap_servers.$ldap_server_id.subDnLabel");
|
||||||
foreach($conf['subDn'] as $name => $cf) {
|
addFromLSconfig("ldap_servers.$ldap_server_id.recoverPassword.recoveryHashMail.subject");
|
||||||
if ($name!='LSobject') {
|
addFromLSconfig("ldap_servers.$ldap_server_id.recoverPassword.recoveryHashMail.msg");
|
||||||
add($name);
|
addFromLSconfig("ldap_servers.$ldap_server_id.recoverPassword.newPasswordMail.subject");
|
||||||
|
addFromLSconfig("ldap_servers.$ldap_server_id.recoverPassword.newPasswordMail.msg");
|
||||||
|
addFromLSconfig("ldap_servers.$ldap_server_id.subDn.*", 'key', array("LSobject"));
|
||||||
|
|
||||||
|
// LSaccess
|
||||||
|
foreach (LSconfig :: get("ldap_servers.$ldap_server_id.LSaccess", array()) as $LSobject) {
|
||||||
|
if (is_string($LSobject) && !in_array($LSobject, $objects) && LSsession :: loadLSobject($LSobject)) {
|
||||||
|
$objects[] = $LSobject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sub DN LSobjects
|
||||||
|
foreach (LSconfig :: getMatchingKeys("ldap_servers.$ldap_server_id.subDn.*.LSobjects.*") as $LSobject)
|
||||||
|
if (is_string($LSobject) && !in_array($LSobject, $objects) && LSsession :: loadLSobject($LSobject))
|
||||||
|
$objects[] = $LSobject;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
debug('LSobjects list : '.implode(', ', $objects));
|
||||||
|
|
||||||
|
// LSobject
|
||||||
|
foreach($objects as $obj) {
|
||||||
|
addFromLSconfig("LSobjects.$obj.label");
|
||||||
|
|
||||||
// LSobject
|
|
||||||
if (loadDir(LS_OBJECTS_DIR) && loadDir(LS_LOCAL_DIR.LS_OBJECTS_DIR)) {
|
|
||||||
foreach($GLOBALS['LSobjects'] as $name => $conf) {
|
|
||||||
add($conf['label']);
|
|
||||||
|
|
||||||
// LSrelation
|
// LSrelation
|
||||||
if (is_array($conf['LSrelation'])) {
|
addFromLSconfig("LSobjects.$obj.LSrelation.*.label");
|
||||||
foreach($conf['LSrelation'] as $rel) {
|
addFromLSconfig("LSobjects.$obj.LSrelation.*.emptyText");
|
||||||
add($rel['label']);
|
|
||||||
add($rel['emptyText']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Custom Actions
|
// Custom Actions
|
||||||
if (is_array($conf['customActions'])) {
|
addFromLSconfig("LSobjects.$obj.customActions.*.label");
|
||||||
foreach($conf['customActions'] as $act) {
|
addFromLSconfig("LSobjects.$obj.customActions.*.helpInfo");
|
||||||
add($act['label']);
|
addFromLSconfig("LSobjects.$obj.customActions.*.question_format");
|
||||||
add($act['helpInfo']);
|
addFromLSconfig("LSobjects.$obj.customActions.*.onSuccessMsgFormat");
|
||||||
add($act['question_format']);
|
|
||||||
add($act['onSuccessMsgFormat']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// LSform
|
// LSform
|
||||||
if (is_array($conf['LSform']['layout'])) {
|
addFromLSconfig("LSobjects.$obj.LSform.layout.*.label");
|
||||||
foreach($conf['LSform']['layout'] as $lay) {
|
addFromLSconfig("LSobjects.$obj.LSform.dataEntryForm.*.label");
|
||||||
add($lay['label']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (is_array($conf['LSform']['dataEntryForm'])) {
|
|
||||||
foreach($conf['LSform']['dataEntryForm'] as $def) {
|
|
||||||
add($def['label']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// LSsearch
|
// LSsearch
|
||||||
if (is_array($conf['LSsearch']['predefinedFilters'])) {
|
addFromLSconfig("LSobjects.$obj.LSsearch.predefinedFilters.*");
|
||||||
foreach($conf['LSsearch']['predefinedFilters'] as $lay) {
|
addFromLSconfig("LSobjects.$obj.LSsearch.extraDisplayedColumns.*.label");
|
||||||
add($lay);
|
addFromLSconfig("LSobjects.$obj.LSsearch.customActions.*.label");
|
||||||
}
|
addFromLSconfig("LSobjects.$obj.LSsearch.customActions.*.question_format");
|
||||||
}
|
addFromLSconfig("LSobjects.$obj.LSsearch.customActions.*.onSuccessMsgFormat");
|
||||||
if (is_array($conf['LSsearch']['extraDisplayedColumns'])) {
|
|
||||||
foreach($conf['LSsearch']['extraDisplayedColumns'] as $cid => $cconf) {
|
|
||||||
add($cconf['label']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (is_array($conf['LSsearch']['customActions'])) {
|
|
||||||
foreach($conf['LSsearch']['customActions'] as $act) {
|
|
||||||
add($act['label']);
|
|
||||||
add($act['question_format']);
|
|
||||||
add($act['onSuccessMsgFormat']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Attributes
|
||||||
|
foreach(LSconfig :: keys("LSobjects.$obj.attrs") as $attr) {
|
||||||
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.label");
|
||||||
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.help_info");
|
||||||
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.no_value_label");
|
||||||
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.check_data.*.msg");
|
||||||
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.validation.*.msg");
|
||||||
|
|
||||||
|
// HTML Options
|
||||||
if(is_array($conf['attrs'])) {
|
$html_type = LSconfig :: get("LSobjects.$obj.attrs.$attr.html_type");
|
||||||
foreach($conf['attrs'] as $attr) {
|
switch($html_type) {
|
||||||
add($attr['label']);
|
case 'boolean':
|
||||||
add($attr['help_info']);
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.true_label");
|
||||||
add($attr['no_value_label']);
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.false_label");
|
||||||
add($attr['html_options']['mail']['subject']);
|
break;
|
||||||
add($attr['html_options']['mail']['msg']);
|
case 'jsonCompositeAttribute':
|
||||||
|
$components = LSconfig :: keys("LSobjects.$obj.attrs.$attr.html_options.components");
|
||||||
// LSattr_html_select_list
|
foreach($components as $c) {
|
||||||
if (($attr['html_type']=='select_list' || $attr['html_type']=='select_box') && is_array($attr['html_options']['possible_values']) && (!isset($attr['html_options']['translate_labels']) || $attr['html_options']['translate_labels']) && !$withoutselectlist) {
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.$c.label");
|
||||||
foreach($attr['html_options']['possible_values'] as $pkey => $pname) {
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.$c.help_info");
|
||||||
if (is_array($pname)) {
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.$c.check_data.*.msg");
|
||||||
add($pname['label']);
|
|
||||||
if (is_array($pname['possible_values'])) {
|
|
||||||
foreach($pname['possible_values'] as $pk => $pn) {
|
|
||||||
if ($pk == 'OTHER_OBJECT') continue;
|
|
||||||
elseif ($pk == 'OTHER_ATTRIBUTE') {
|
|
||||||
if (is_array($pn) && ! isset($pn['attr'])) {
|
|
||||||
foreach($pn as $pattr => $plabel)
|
|
||||||
add($plabel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else add($pn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elseif ($pkey == 'OTHER_ATTRIBUTE') {
|
|
||||||
if (is_array($pname) && ! isset($pname['attr'])) {
|
|
||||||
foreach($pname as $pattr => $plabel)
|
|
||||||
add($plabel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elseif ($pkey != 'OTHER_OBJECT') {
|
|
||||||
add($pname);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// LSattr_html_valueWithUnit
|
if (
|
||||||
if (is_array($attr['html_options']['units'])) {
|
LSconfig :: get("LSobjects.$obj.attrs.$attr.html_options.$c.type") == 'select_list' &&
|
||||||
foreach($attr['html_options']['units'] as $pname) {
|
LSconfig :: get("LSobjects.$obj.attrs.$attr.html_options.$c.options.translate_labels", "True", "bool") &&
|
||||||
add($pname);
|
!in_array('select-list', $withouts)
|
||||||
}
|
)
|
||||||
}
|
{
|
||||||
|
foreach(LSconfig :: get("LSobjects.$obj.attrs.$attr.html_options.$c.options.possible_values", array()) as $pkey => $plabel) {
|
||||||
// LSattr_html_labeledValue
|
if ($pkey == 'OTHER_OBJECT')
|
||||||
if (is_array($attr['html_options']['labels'])) {
|
continue;
|
||||||
foreach($attr['html_options']['labels'] as $klabel => $plabel) {
|
|
||||||
add($plabel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// LSattr_html_boolean
|
|
||||||
if (isset($attr['html_options']['true_label'])) {
|
|
||||||
add($attr['html_options']['true_label']);
|
|
||||||
}
|
|
||||||
if (isset($attr['html_options']['false_label'])) {
|
|
||||||
add($attr['html_options']['false_label']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// LSattr_html_jsonCompositeAttribute
|
|
||||||
if (is_array($attr['html_options']['components'])) {
|
|
||||||
foreach($attr['html_options']['components'] as $c => $cconfig) {
|
|
||||||
add($cconfig['label']);
|
|
||||||
add($cconfig['help_info']);
|
|
||||||
|
|
||||||
// Component type select_list
|
|
||||||
if (is_array($cconfig['options']['possible_values']) && (!isset($cconfig['options']['translate_labels']) || $cconfig['options']['translate_labels']) && !$withoutselectlist) {
|
|
||||||
foreach($cconfig['options']['possible_values'] as $pkey => $pname) {
|
|
||||||
if (is_array($pname)) {
|
|
||||||
add($pname['label']);
|
|
||||||
if (is_array($pname['possible_values'])) {
|
|
||||||
foreach($pname['possible_values'] as $pk => $pn) {
|
|
||||||
if ($pk == 'OTHER_OBJECT') continue;
|
|
||||||
elseif ($pk == 'OTHER_ATTRIBUTE') {
|
|
||||||
if (is_array($pn) && ! isset($pn['attr'])) {
|
|
||||||
foreach($pn as $pattr => $plabel)
|
|
||||||
add($plabel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else add($pn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elseif ($pkey == 'OTHER_ATTRIBUTE') {
|
elseif ($pkey == 'OTHER_ATTRIBUTE') {
|
||||||
if (is_array($pname) && ! isset($pname['attr'])) {
|
if (is_string($plabel))
|
||||||
foreach($pname as $pattr => $plabel)
|
continue;
|
||||||
add($plabel);
|
elseif (is_array($plabel)) {
|
||||||
|
if (isset($plabel['json_component_key']))
|
||||||
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.$c.options.possible_values.OTHER_ATTRIBUTE.json_component_label");
|
||||||
|
else
|
||||||
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.$c.options.possible_values.OTHER_ATTRIBUTE.*");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($pkey != 'OTHER_OBJECT') {
|
elseif(is_string($plabel)) {
|
||||||
add($pname);
|
add($plabel, "LSobjects.$obj.attrs.$attr.html_options.$c.options.possible_values.$pkey");
|
||||||
|
}
|
||||||
|
elseif (is_array($plabel)) {
|
||||||
|
// Sub possible values
|
||||||
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.$c.options.possible_values.$pkey.label");
|
||||||
|
foreach(LSconfig :: get("LSobjects.$obj.attrs.$attr.html_options.$c.options.possible_values.$pkey.possible_values", array()) as $ppkey => $pplabel) {
|
||||||
|
if ($ppkey == 'OTHER_OBJECT')
|
||||||
|
continue;
|
||||||
|
elseif ($ppkey == 'OTHER_ATTRIBUTE') {
|
||||||
|
if (is_string($pplabel))
|
||||||
|
continue;
|
||||||
|
elseif (is_array($pplabel)) {
|
||||||
|
if (isset($pplabel['json_component_key']))
|
||||||
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.$c.options.possible_values.OTHER_ATTRIBUTE.json_component_label");
|
||||||
|
else
|
||||||
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.$c.options.possible_values.OTHER_ATTRIBUTE.*");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif(is_string($pplabel)) {
|
||||||
|
add($pplabel, "LSobjects.$obj.attrs.$attr.html_options.$c.options.possible_values.$pkey.possible_values.$ppkey");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check data
|
break;
|
||||||
if (is_array($cconfig['check_data'])) {
|
case 'labeledValue':
|
||||||
foreach($cconfig['check_data'] as $check) {
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.labels.*");
|
||||||
add($check['msg']);
|
break;
|
||||||
|
case 'password':
|
||||||
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.mail.subject");
|
||||||
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.mail.msg");
|
||||||
|
break;
|
||||||
|
case 'select_list':
|
||||||
|
case 'select_box':
|
||||||
|
if (LSconfig :: get("LSobjects.$obj.attrs.$attr.html_options.translate_labels", "True", "bool") && !in_array('select-list', $withouts)) {
|
||||||
|
foreach(LSconfig :: get("LSobjects.$obj.attrs.$attr.html_options.possible_values", array()) as $pkey => $plabel) {
|
||||||
|
if ($pkey == 'OTHER_OBJECT')
|
||||||
|
continue;
|
||||||
|
elseif ($pkey == 'OTHER_ATTRIBUTE') {
|
||||||
|
if (is_string($plabel))
|
||||||
|
continue;
|
||||||
|
elseif (is_array($plabel)) {
|
||||||
|
if (isset($plabel['json_component_key']))
|
||||||
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.possible_values.OTHER_ATTRIBUTE.json_component_label");
|
||||||
|
else
|
||||||
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.possible_values.OTHER_ATTRIBUTE.*");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif(is_string($plabel)) {
|
||||||
|
add($plabel, "LSobjects.$obj.attrs.$attr.html_options.possible_values.$pkey");
|
||||||
|
}
|
||||||
|
elseif (is_array($plabel)) {
|
||||||
|
// Sub possible values
|
||||||
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.possible_values.$pkey.label");
|
||||||
|
foreach(LSconfig :: get("LSobjects.$obj.attrs.$attr.html_options.possible_values.$pkey.possible_values", array()) as $ppkey => $pplabel) {
|
||||||
|
if ($ppkey == 'OTHER_OBJECT')
|
||||||
|
continue;
|
||||||
|
elseif ($ppkey == 'OTHER_ATTRIBUTE') {
|
||||||
|
if (is_string($pplabel))
|
||||||
|
continue;
|
||||||
|
elseif (is_array($pplabel)) {
|
||||||
|
if (isset($pplabel['json_component_key']))
|
||||||
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.possible_values.OTHER_ATTRIBUTE.json_component_label");
|
||||||
|
else
|
||||||
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.possible_values.OTHER_ATTRIBUTE.*");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif(is_string($pplabel)) {
|
||||||
|
add($pplabel, "LSobjects.$obj.attrs.$attr.html_options.possible_values.$pkey.possible_values.$ppkey");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
|
case 'valueWithUnit':
|
||||||
// Check data
|
addFromLSconfig("LSobjects.$obj.attrs.$attr.html_options.units.*");
|
||||||
if (is_array($attr['check_data'])) {
|
break;
|
||||||
foreach($attr['check_data'] as $check) {
|
|
||||||
add($check['msg']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// validation
|
|
||||||
if (is_array($attr['validation'])) {
|
|
||||||
foreach($attr['validation'] as $valid) {
|
|
||||||
add($valid['msg']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -334,112 +414,177 @@ if (loadDir(LS_OBJECTS_DIR) && loadDir(LS_LOCAL_DIR.LS_OBJECTS_DIR)) {
|
||||||
/*
|
/*
|
||||||
* Manage template file
|
* Manage template file
|
||||||
*/
|
*/
|
||||||
|
if (!in_array('templates', $withouts) && (!$only || $only == 'templates')) {
|
||||||
function parse_template_file($file) {
|
function parse_template_file($file) {
|
||||||
foreach(file($file) as $line) {
|
debug("parse_template_file($file) : start ...");
|
||||||
if (preg_match_all('/\{ *tr +msg=["\']([^\}]+)["\'] *\}/',$line,$matches)) {
|
$count = 0;
|
||||||
foreach($matches[1] as $t)
|
foreach(file($file) as $line) {
|
||||||
add($t);
|
$count ++;
|
||||||
}
|
if (preg_match_all('/\{ *tr +msg=["\']([^\}]+)["\'] *\}/',$line,$matches)) {
|
||||||
}
|
foreach($matches[1] as $t) {
|
||||||
}
|
debug(" - \"$t\" # Line $count");
|
||||||
|
add($t, "$file:$count");
|
||||||
function find_and_parse_template_file($dir) {
|
|
||||||
if (is_dir($dir)) {
|
|
||||||
if ($dh = opendir($dir)) {
|
|
||||||
while (($file = readdir($dh)) !== false) {
|
|
||||||
if ($file=='.' || $file=='..') continue;
|
|
||||||
if (is_dir($dir.'/'.$file)) {
|
|
||||||
find_and_parse_template_file($dir.'/'.$file);
|
|
||||||
}
|
|
||||||
elseif (is_file($dir."/".$file) && preg_match('/\.tpl$/',$file)) {
|
|
||||||
parse_template_file($dir.'/'.$file);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir($dh);
|
}
|
||||||
|
debug("parse_template_file($file) : done.");
|
||||||
|
}
|
||||||
|
|
||||||
|
function find_and_parse_template_file($dir) {
|
||||||
|
if (is_dir($dir)) {
|
||||||
|
if ($dh = opendir($dir)) {
|
||||||
|
while (($file = readdir($dh)) !== false) {
|
||||||
|
if ($file=='.' || $file=='..') continue;
|
||||||
|
if (is_dir($dir.'/'.$file)) {
|
||||||
|
find_and_parse_template_file($dir.'/'.$file);
|
||||||
|
}
|
||||||
|
elseif (is_file($dir."/".$file) && preg_match('/\.tpl$/',$file)) {
|
||||||
|
parse_template_file($dir.'/'.$file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir($dh);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
find_and_parse_template_file(LS_TEMPLATES_DIR);
|
find_and_parse_template_file(LS_TEMPLATES_DIR);
|
||||||
find_and_parse_template_file(LS_LOCAL_DIR.LS_TEMPLATES_DIR);
|
find_and_parse_template_file(LS_LOCAL_DIR.LS_TEMPLATES_DIR);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Manage addons files
|
* Manage addons files
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function parse_addon_file($file) {
|
if (!in_array('addons', $withouts) && (!$only || $only == 'addons')) {
|
||||||
foreach(file($file) as $line) {
|
function parse_addon_file($file) {
|
||||||
$offset=0;
|
$count = 0;
|
||||||
while ($pos = strpos($line,'__(',$offset)) {
|
foreach(file($file) as $line) {
|
||||||
$quote='';
|
$count++;
|
||||||
$res='';
|
$offset=0;
|
||||||
for ($i=$pos+3;$i<strlen($line);$i++) {
|
while ($pos = strpos($line,'__(',$offset)) {
|
||||||
if (empty($quote)) {
|
$quote='';
|
||||||
// Quote char not detected : try to detect it
|
$res='';
|
||||||
if ($line[$i]=='\\' || $line[$i]==" " || $line[$i]=="\t") {
|
for ($i=$pos+3;$i<strlen($line);$i++) {
|
||||||
// Space or escape char : pass
|
if (empty($quote)) {
|
||||||
$i++;
|
// Quote char not detected : try to detect it
|
||||||
|
if ($line[$i]=='\\' || $line[$i]==" " || $line[$i]=="\t") {
|
||||||
|
// Space or escape char : pass
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
elseif ($line[$i]=='"' || $line[$i]=="'") {
|
||||||
|
// Quote detected
|
||||||
|
$quote=$line[$i];
|
||||||
|
}
|
||||||
|
elseif ($line[$i]=='$' || $line[$i]==')') {
|
||||||
|
// Variable translation not possible or end function call detected
|
||||||
|
$offset=$i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Unknown case : continue
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elseif ($line[$i]=='"' || $line[$i]=="'") {
|
elseif (!empty($quote)) {
|
||||||
// Quote detected
|
// Quote char already detected : try to detect end quote char
|
||||||
$quote=$line[$i];
|
if ($line[$i]=='\\') {
|
||||||
}
|
// Escape char detected : pass this char and the following one
|
||||||
elseif ($line[$i]=='$' || $line[$i]==')') {
|
$res.=$line[$i];
|
||||||
// Variable translation not possible or end function call detected
|
$i++;
|
||||||
$offset=$i;
|
$res.=$line[$i];
|
||||||
break;
|
}
|
||||||
}
|
elseif ($line[$i]==$quote) {
|
||||||
else {
|
// End quote char detected : set offset for next detection and break this one
|
||||||
// Unknown case : continue
|
$offset=$i;
|
||||||
$i++;
|
break;
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
elseif (!empty($quote)) {
|
// End quote char not detected : append current char to result
|
||||||
// Quote char already detected : try to detect end quote char
|
$res.=$line[$i];
|
||||||
if ($line[$i]=='\\') {
|
}
|
||||||
// Escape char detected : pass this char and the following one
|
|
||||||
$res.=$line[$i];
|
|
||||||
$i++;
|
|
||||||
$res.=$line[$i];
|
|
||||||
}
|
|
||||||
elseif ($line[$i]==$quote) {
|
|
||||||
// End quote char detected : set offset for next detection and break this one
|
|
||||||
$offset=$i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// End quote char not detected : append current char to result
|
|
||||||
$res.=$line[$i];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!empty($res)) add($res, "$file:$count");
|
||||||
}
|
}
|
||||||
if (!empty($res)) add($res);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function find_and_parse_addon_file($dir) {
|
function find_and_parse_addon_file($dir) {
|
||||||
if (is_dir($dir)) {
|
if (is_dir($dir)) {
|
||||||
if ($dh = opendir($dir)) {
|
if ($dh = opendir($dir)) {
|
||||||
while (($file = readdir($dh)) !== false) {
|
while (($file = readdir($dh)) !== false) {
|
||||||
if (preg_match('/^LSaddons\.(.+)\.php$/',$file)) {
|
if (preg_match('/^LSaddons\.(.+)\.php$/',$file)) {
|
||||||
parse_addon_file($dir.'/'.$file);
|
parse_addon_file($dir.'/'.$file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
closedir($dh);
|
||||||
}
|
}
|
||||||
closedir($dh);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
find_and_parse_addon_file(LS_ADDONS_DIR);
|
||||||
|
find_and_parse_addon_file(LS_LOCAL_DIR.LS_ADDONS_DIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
find_and_parse_addon_file(LS_ADDONS_DIR);
|
// Sort resulting strings
|
||||||
find_and_parse_addon_file(LS_LOCAL_DIR.LS_ADDONS_DIR);
|
|
||||||
|
|
||||||
|
|
||||||
ksort($data);
|
ksort($data);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Handle output file format
|
||||||
|
*/
|
||||||
|
function output_php($fd) {
|
||||||
|
global $additionalfileformat, $data, $copyoriginalvalue;
|
||||||
|
fwrite($fd, "<?php\n\n");
|
||||||
|
|
||||||
|
if (!$additionalfileformat) fwrite($fd, "\$GLOBALS['LSlang'] = array (\n");
|
||||||
|
|
||||||
|
foreach($data as $key => $key_data) {
|
||||||
|
if ($copyoriginalvalue && $key_data['translation'] == "") {
|
||||||
|
$val = $key;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$val = $key_data['translation'];
|
||||||
|
$key=str_replace('"','\\"',$key);
|
||||||
|
$val=str_replace('"','\\"',$val);
|
||||||
|
foreach ($key_data['contexts'] as $context)
|
||||||
|
fwrite($fd, "\n# $context");
|
||||||
|
if ($additionalfileformat) {
|
||||||
|
fwrite($fd, "\n\$GLOBALS['LSlang'][\"$key\"] = \"$val\";\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fwrite($fd, "\n\"$key\" =>\n \"$val\",\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$additionalfileformat) fwrite($fd, "\n);\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
function clean_for_pot_file($val) {
|
||||||
|
$val = str_replace('"', '\\"', $val);
|
||||||
|
return str_replace("\n", "\\n", $val);
|
||||||
|
}
|
||||||
|
|
||||||
|
function output_pot($fd) {
|
||||||
|
global $data, $copyoriginalvalue;
|
||||||
|
foreach($data as $key => $key_data) {
|
||||||
|
if ($copyoriginalvalue && $key_data['translation'] == "") {
|
||||||
|
$val = $key;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$val = $key_data['translation'];
|
||||||
|
foreach ($key_data['contexts'] as $context)
|
||||||
|
fwrite($fd, "#: $context\n");
|
||||||
|
$key = clean_for_pot_file($key);
|
||||||
|
$val = clean_for_pot_file($val);
|
||||||
|
fwrite($fd, "msgid \"$key\"\nmsgstr \"$val\"\n\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine where to write result
|
||||||
if ($output) {
|
if ($output) {
|
||||||
|
$output = realtive_path($output);
|
||||||
try {
|
try {
|
||||||
|
debug("Open output file ($output)");
|
||||||
$fd = fopen($output, 'w');
|
$fd = fopen($output, 'w');
|
||||||
}
|
}
|
||||||
catch(Exception $e) {
|
catch(Exception $e) {
|
||||||
|
@ -454,26 +599,22 @@ if ($output) {
|
||||||
else
|
else
|
||||||
$fd = STDOUT;
|
$fd = STDOUT;
|
||||||
|
|
||||||
fwrite($fd, "<?php\n\n");
|
// Generate output
|
||||||
|
debug("Output format : $format");
|
||||||
if (!$additionalfileformat) fwrite($fd, "\$GLOBALS['LSlang'] = array (\n");
|
switch($format) {
|
||||||
|
case 'pot':
|
||||||
foreach($data as $key => $val) {
|
output_pot($fd);
|
||||||
if ($copyoriginalvalue && $val=="") {
|
break;
|
||||||
$val=$key;
|
case 'php':
|
||||||
}
|
default:
|
||||||
$key=str_replace('"','\\"',$key);
|
output_php($fd);
|
||||||
$val=str_replace('"','\\"',$val);
|
break;
|
||||||
if ($additionalfileformat) {
|
|
||||||
fwrite($fd, "\$GLOBALS['LSlang'][\"$key\"] = \"$val\";\n");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fwrite($fd, "\n\"$key\" =>\n \"$val\",\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$additionalfileformat) fwrite($fd, "\n);\n");
|
// Close output file (is specified)
|
||||||
|
if ($output) {
|
||||||
if ($output)
|
debug("Close output file ($output)");
|
||||||
fclose($fd);
|
fclose($fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
|
22
public_html/lang/generate_ldapsaisie.pot.sh
Normal file → Executable file
22
public_html/lang/generate_ldapsaisie.pot.sh
Normal file → Executable file
|
@ -1,7 +1,23 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
cd ../
|
# Detect
|
||||||
|
PUBLIC_HTML=$( realpath $( dirname $0 )/../ )
|
||||||
|
|
||||||
rm -fr tmp/*
|
# Clean php file in tmp directory
|
||||||
|
[ -d "$PUBLIC_HTML/tmp" ] && rm -fr "$PUBLIC_HTML/tmp/*.php"
|
||||||
|
|
||||||
xgettext --from-code utf-8 -o lang/ldapsaisie.pot $( find -name "*.php" )
|
# Extract messages from LdapSaisie PHP files using xgettext
|
||||||
|
xgettext --from-code utf-8 \
|
||||||
|
-o "$PUBLIC_HTML/lang/ldapsaisie-main.pot" \
|
||||||
|
--omit-header \
|
||||||
|
--copyright-holder="Easter-eggs" \
|
||||||
|
--keyword="__" \
|
||||||
|
$( find "$PUBLIC_HTML" -name "*.php" )
|
||||||
|
|
||||||
|
# Extract other messages from LdapSaisie templates files
|
||||||
|
$PUBLIC_HTML/lang/generate_lang_file.php -o "$PUBLIC_HTML/lang/ldapsaisie-templates.pot" \
|
||||||
|
-f pot \
|
||||||
|
--only templates
|
||||||
|
|
||||||
|
# Merge previous results in ldapsaisie.pot file
|
||||||
|
msgcat $PUBLIC_HTML/lang/ldapsaisie-main.pot $PUBLIC_HTML/lang/ldapsaisie-templates.pot -o $PUBLIC_HTML/lang/ldapsaisie.pot
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue