mirror of
https://github.com/unraid/webgui.git
synced 2026-01-13 13:09:58 -06:00
Multi-language support
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
Title="Add Container"
|
||||
Cond="(pgrep('dockerd')!==false)"
|
||||
Markdown="false"
|
||||
---
|
||||
<?PHP
|
||||
/* Copyright 2005-2020, Lime Technology
|
||||
* Copyright 2014-2020, Guilherme Jardim, Eric Schultz, Jon Panozzo.
|
||||
* Copyright 2012-2020, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
@@ -14,9 +14,6 @@ Markdown="false"
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
?>
|
||||
<div style="text-align:right;vertical-align:top;position:relative;top:-44px;height:0;display:none;">
|
||||
<span class="toggleMode" onclick="toggleMode();"><i id="toggleMode" class="fa fa-lg"></i> _(Advanced View)_</span>
|
||||
</div>
|
||||
<?PHP
|
||||
require_once "$docroot/plugins/dynamix.docker.manager/include/CreateDocker.php";
|
||||
<?
|
||||
eval('?>'.Markdown(parse_text(file_get_contents("$docroot/plugins/dynamix.docker.manager/include/CreateDocker.php"))));
|
||||
?>
|
||||
@@ -1,10 +1,10 @@
|
||||
Title="Update Container"
|
||||
Cond="(pgrep('dockerd')!==false)"
|
||||
Markdown="false"
|
||||
---
|
||||
<?PHP
|
||||
/* Copyright 2005-2020, Lime Technology
|
||||
* Copyright 2014-2020, Guilherme Jardim, Eric Schultz, Jon Panozzo.
|
||||
* Copyright 2012-2020, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
@@ -14,9 +14,6 @@ Markdown="false"
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
?>
|
||||
<div style="text-align:right;vertical-align:top;position:relative;top:-44px;height:0;display:none;">
|
||||
<span class="toggleMode" onclick="toggleMode();"><i id="toggleMode" class="fa fa-lg"></i> _(Advanced View)_</span>
|
||||
</div>
|
||||
<?PHP
|
||||
require_once "$docroot/plugins/dynamix.docker.manager/include/CreateDocker.php";
|
||||
<?
|
||||
eval('?>'.Markdown(parse_text(file_get_contents("$docroot/plugins/dynamix.docker.manager/include/CreateDocker.php"))));
|
||||
?>
|
||||
@@ -45,7 +45,7 @@ div.spinner .unraid_mark_7{animation:mark_7 1.5s ease infinite}
|
||||
@keyframes mark_7{50% {transform:translateY(62px)} 100% {transform: translateY(0px)}}
|
||||
pre{font-family:bitstream;font-size:1.3rem}
|
||||
</style>
|
||||
<script type="text/javascript" src="<?autov('/webGui/javascript/dynamix.js')?>"></script>
|
||||
<script src="<?autov('/webGui/javascript/dynamix.js')?>"></script>
|
||||
<script>
|
||||
$(function(){
|
||||
$('div.spinner').html('<?readfile("$docroot/webGui/images/animated-logo.svg")?>');
|
||||
|
||||
@@ -436,7 +436,7 @@ if ($display['usage']) my_usage();
|
||||
echo "</div>";
|
||||
echo "<div id='nav-right'>";
|
||||
foreach ($buttons as $button) {
|
||||
eval('?>'.rewrite($button['text']));
|
||||
eval('?>'.parse_text($button['text']));
|
||||
if (empty($button['Link'])) {
|
||||
$icon = $button['Icon'];
|
||||
if (substr($icon,-4)=='.png') {
|
||||
@@ -511,7 +511,7 @@ foreach ($pages as $page) {
|
||||
echo "<div class=\"Panel\"><a href=\"$link\" onclick=\"$.cookie('one','tab1',{path:'/'})\"><span>$icon</span><div class=\"PanelText\">"._($title)."</div></a></div>";
|
||||
}
|
||||
}
|
||||
empty($page['Markdown']) || $page['Markdown']=='true' ? eval('?>'.Markdown(rewrite($page['text']))) : eval('?>'.rewrite($page['text']));
|
||||
empty($page['Markdown']) || $page['Markdown']=='true' ? eval('?>'.Markdown(parse_text($page['text']))) : eval('?>'.parse_text($page['text']));
|
||||
if ($close) echo "</div></div>";
|
||||
}
|
||||
unset($pages,$page,$pgs,$pg,$icon);
|
||||
|
||||
@@ -23,45 +23,30 @@ function _($text) {
|
||||
function parse_lang_file($file) {
|
||||
return array_filter(parse_ini_string(preg_replace(['/"/m','/^(null|yes|no|true|false|on|off|none)=/mi','/^([^>].*)=([^"\'`].*)$/m','/^:((help|plug)\d*)$/m','/^:end$/m'],['\'','$1.=','$1="$2"',"_$1_=\"",'"'],str_replace("=\n","=''\n",file_get_contents($file)))),'strlen');
|
||||
}
|
||||
function rewrite($text) {
|
||||
function parse_text($text) {
|
||||
return preg_replace_callback('/_\((.+?)\)_/m',function($m){return _($m[1]);},preg_replace(["/^:((help|plug)\d*)$/m","/^:end$/m"],["<?if (translate(\"_$1_\")):?>","<?endif;?>"],$text));
|
||||
}
|
||||
function parse_array($text,&$array) {
|
||||
parse_str(str_replace([' ',':'],['&','='],$text),$array);
|
||||
}
|
||||
function my_lang($text,$do=0) {
|
||||
global $language;
|
||||
switch ($do) {
|
||||
case 0: // date translation
|
||||
$months = isset($language['Months_array']) ? explode(' ',$language['Months_array']) : [];
|
||||
$days = isset($language['Days_array']) ? explode(' ',$language['Days_array']) : [];
|
||||
foreach ($months as $month) {
|
||||
[$word,$that] = explode(':',$month);
|
||||
if (strpos($text,$word)!==false) {$text = str_replace($word,$that,$text); break;}
|
||||
}
|
||||
foreach ($days as $day) {
|
||||
[$word,$that] = explode(':',$day);
|
||||
if (strpos($text,$word)!==false) {$text = str_replace($word,$that,$text); break;}
|
||||
}
|
||||
$keys = ['today','yesterday','day ago','days ago','week ago','weeks ago','month ago','months ago'];
|
||||
parse_array($language['Months_array'],$months);
|
||||
parse_array($language['Days_array'],$days);
|
||||
foreach ($months as $word => $that) if (strpos($text,$word)!==false) {$text = str_replace($word,$that,$text); break;}
|
||||
foreach ($days as $word => $that) if (strpos($text,$word)!==false) {$text = str_replace($word,$that,$text); break;}
|
||||
foreach ($keys as $key) if (isset($language[$key])) $text = str_replace($key,$language[$key],$text);
|
||||
break;
|
||||
case 1: // number translation
|
||||
$numbers = isset($language['Numbers_array']) ? explode(' ',$language['Numbers_array']) : [];
|
||||
foreach ($numbers as $number) {
|
||||
[$word,$that] = explode(':',$number);
|
||||
if (strpos($text,$word)!==false) {$text = str_replace($word,$that,$text); break;}
|
||||
}
|
||||
parse_array($language['Numbers_array'],$numbers);
|
||||
foreach ($numbers as $word => $that) if (strpos($text,$word)!==false) {$text = str_replace($word,$that,$text); break;}
|
||||
break;
|
||||
case 2: // time translation
|
||||
$time1 = ['days'=>$language['days']??'','hours'=>$language['hours']??'','minutes'=>$language['minutes']??'','seconds'=>$language['seconds']??''];
|
||||
$time2 = ['day'=>$language['day']??'','hour'=>$language['hour']??'','minute'=>$language['minute']??'','second'=>$language['second']??''];
|
||||
foreach ($time1 as $word => $that) {
|
||||
if ($that && strpos($text,$word)!==false) {
|
||||
$text = str_replace($word,$that,$text);
|
||||
} else {
|
||||
$one = substr($word,0,-1);
|
||||
if ($time2[$one]) $text = str_replace($one,$time2[$one],$text);
|
||||
}
|
||||
}
|
||||
if (isset($language['Average speed'])) $text = str_replace('Average speed',$language['Average speed'],$text);
|
||||
$keys = ['day','hour','minute','second','days','hours','minutes','seconds','Average speed'];
|
||||
foreach ($keys as $key) if (isset($language[$key])) $text = str_replace($key,$language[$key],$text);
|
||||
break;
|
||||
case 3: // device translation
|
||||
[$p1,$p2] = explode(' ',$text);
|
||||
|
||||
Reference in New Issue
Block a user