mirror of
https://github.com/unraid/webgui.git
synced 2026-04-26 04:11:12 -05:00
Multi-language support
This commit is contained in:
@@ -23,11 +23,11 @@ function _($text) {
|
||||
}
|
||||
function parse_lang_file($file) {
|
||||
// parser for translation files, includes some trickery to handle PHP quirks.
|
||||
return secured((array)parse_ini_string(preg_replace(['/^(null|yes|no|true|false|on|off|none)=/mi','/^([^>].*)=(.*)$/m','/^:(.+_(help|plug)):$/m','/^:end$/m'],['$1.=','$1="$2"','_$1_="','"'],escapeQuotes(file_get_contents($file)))));
|
||||
return array_safe((array)parse_ini_string(preg_replace(['/^(null|yes|no|true|false|on|off|none)=/mi','/^([^>].*)=(.*)$/m','/^:(.+_(help|plug)):$/m','/^:end$/m'],['$1.=','$1="$2"','_$1_="','"'],escapeQuotes(file_get_contents($file)))));
|
||||
}
|
||||
function parse_help_file($file) {
|
||||
// parser for help text files (multi-line sections), includes some trickery to handle PHP quirks.
|
||||
return secured((array)parse_ini_string(preg_replace(['/^$/m','/^([^:;].+)$/m','/^:(.+_help):$/m','/^:end$/m'],['>','>$1','_$1_="','"'],escapeQuotes(file_get_contents($file)))));
|
||||
return array_safe((array)parse_ini_string(preg_replace(['/^$/m','/^([^:;].+)$/m','/^:(.+_help):$/m','/^:end$/m'],['>','>$1','_$1_="','"'],escapeQuotes(file_get_contents($file)))));
|
||||
}
|
||||
function parse_text($text) {
|
||||
// inline text parser
|
||||
@@ -67,7 +67,7 @@ function parse_array($text,&$array) {
|
||||
// multi keyword parser
|
||||
parse_str(str_replace([' ',':'],['&','='],$text),$array);
|
||||
}
|
||||
function secured($array) {
|
||||
function array_safe($array) {
|
||||
// remove potential dangerous tags
|
||||
return array_filter($array,function($v,$k){return strlen($v) && !preg_match('#<(script|iframe)(.*?)>(.+?)</(script|iframe)>|<(link|meta)\s(.+?)/?>#is',html_entity_decode($v));},ARRAY_FILTER_USE_BOTH);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user