mirror of
https://github.com/unraid/webgui.git
synced 2026-01-26 19:48:55 -06:00
Merge pull request #668 from bergware/mutli-language
Multi-language support
This commit is contained in:
@@ -116,9 +116,9 @@ function language($method, $xml_file, &$error) {
|
||||
$path = "$docroot/languages/$name";
|
||||
exec("rm -rf $path");
|
||||
@unlink("$docroot/webGui/javascript/translate.$name.js");
|
||||
@unlink("$boot/dynamix.$name.xml");
|
||||
@unlink("$plugins/dynamix.$name.xml");
|
||||
@unlink("$tmp/dynamix.$name.xml");
|
||||
@unlink("$boot/lang-$name.xml");
|
||||
@unlink("$plugins/lang-$name.xml");
|
||||
@unlink("$tmp/lang-$name.xml");
|
||||
@unlink("$boot/dynamix/lang-$name.zip");
|
||||
return true;
|
||||
} else {
|
||||
@@ -150,11 +150,11 @@ $method = $argv[1];
|
||||
|
||||
if ($method == 'checkall') {
|
||||
echo "language: checking all language packs\n";
|
||||
foreach (glob("$plugins/dynamix.*.xml", GLOB_NOSORT) as $link) {
|
||||
foreach (glob("$plugins/lang-*.xml", GLOB_NOSORT) as $link) {
|
||||
$lang_file = @readlink($link);
|
||||
if ($lang_file === false) continue;
|
||||
if (language('LanguageURL', $lang_file, $error) === false) continue;
|
||||
$name = str_replace('dynamix.', '', basename($lang_file, '.xml'));
|
||||
$name = str_replace('lang-', '', basename($lang_file, '.xml'));
|
||||
$lang = language('Language', $lang_file, $error) ?: $name;
|
||||
echo "language: checking $lang language pack ...\n";
|
||||
exec(realpath($argv[0])." check $name >/dev/null");
|
||||
@@ -164,14 +164,14 @@ if ($method == 'checkall') {
|
||||
|
||||
if ($method == 'updateall') {
|
||||
echo "language: updating all language packs\n";
|
||||
foreach (glob("$plugins/dynamix.*.xml", GLOB_NOSORT) as $link) {
|
||||
foreach (glob("$plugins/lang-*.xml", GLOB_NOSORT) as $link) {
|
||||
$lang_file = @readlink($link);
|
||||
if ($lang_file === false) continue;
|
||||
if (language('LanguageURL', $lang_file, $error) === false) continue;
|
||||
$version = language('Version', $lang_file, $error);
|
||||
$name = str_replace('dynamix.', '', basename($lang_file, '.xml'));
|
||||
$name = str_replace('lang-', '', basename($lang_file, '.xml'));
|
||||
$lang = language('Language', $lang_file, $error) ?: $name;
|
||||
$latest = language('Version', "$tmp/dynamix.$name.xml", $error);
|
||||
$latest = language('Version', "$tmp/lang-$name.xml", $error);
|
||||
// update only when newer
|
||||
if (strcmp($latest, $version) > 0) {
|
||||
echo "language: updating $lang language pack ...\n";
|
||||
@@ -193,7 +193,7 @@ if ($method == 'install') {
|
||||
$langURL = $argv[2];
|
||||
echo "language: downloading $langURL\n";
|
||||
$name = basename($langURL);
|
||||
$xml_file = "$tmp/dynamix.$name";
|
||||
$xml_file = "$tmp/$name";
|
||||
if (!download($langURL, $xml_file, $error)) {
|
||||
echo "language: $error\n";
|
||||
@unlink($xml_file);
|
||||
@@ -201,10 +201,10 @@ if ($method == 'install') {
|
||||
}
|
||||
} else {
|
||||
$xml_file = realpath($argv[2]);
|
||||
$name = str_replace('dynamix.', '', basename($xml_file));
|
||||
$name = basename($xml_file);
|
||||
}
|
||||
$link_file = "$plugins/dynamix.$name";
|
||||
$lang_file = "$boot/dynamix.$name";
|
||||
$link_file = "$plugins/$name";
|
||||
$lang_file = "$boot/$name";
|
||||
@unlink($link_file);
|
||||
if (language('install', $xml_file, $error) === false) {
|
||||
echo "language: $error\n";
|
||||
@@ -220,7 +220,7 @@ if ($method == 'install') {
|
||||
if ($method == 'check') {
|
||||
$name = $argv[2];
|
||||
echo "language: checking language pack\n";
|
||||
$link_file = "$plugins/dynamix.$name.xml";
|
||||
$link_file = "$plugins/lang-$name.xml";
|
||||
$lang_file = @readlink($link_file);
|
||||
if ($lang_file === false) {
|
||||
echo "language: $name language pack not installed\n";
|
||||
@@ -231,7 +231,7 @@ if ($method == 'check') {
|
||||
echo "language: $error\n";
|
||||
exit(1);
|
||||
}
|
||||
$xml_file = "$tmp/dynamix.$name.xml";
|
||||
$xml_file = "$tmp/lang-$name.xml";
|
||||
if (!download($templateURL, $xml_file, $error)) {
|
||||
echo "language: $error\n";
|
||||
@unlink($xml_file);
|
||||
@@ -249,14 +249,14 @@ if ($method == 'check') {
|
||||
if ($method == 'update') {
|
||||
$name = $argv[2];
|
||||
echo "language: updating language pack\n";
|
||||
$link_file = "$plugins/dynamix.$name.xml";
|
||||
$link_file = "$plugins/lang-$name.xml";
|
||||
$lang_file = @readlink($link_file);
|
||||
if ($lang_file === false) {
|
||||
echo "language: $name language pack not installed\n";
|
||||
exit(1);
|
||||
}
|
||||
// verify previous check has been done
|
||||
$xml_file = "$tmp/dynamix.$name.xml";
|
||||
$xml_file = "$tmp/lang-$name.xml";
|
||||
if (!file_exists($xml_file)) {
|
||||
echo "language: update does not exist, perform a check first\n";
|
||||
exit (1);
|
||||
@@ -285,7 +285,7 @@ if ($method == 'update') {
|
||||
if ($method == 'remove') {
|
||||
$name = $argv[2];
|
||||
echo "language: removing language pack\n";
|
||||
$link_file = "$plugins/dynamix.$name.xml";
|
||||
$link_file = "$plugins/lang-$name.xml";
|
||||
$lang_file = @readlink($link_file);
|
||||
if ($lang_file === false) {
|
||||
echo "language: $name language pack not installed\n";
|
||||
|
||||
@@ -132,10 +132,10 @@ $(function() {
|
||||
_(Language)_:
|
||||
: <select name="locale">
|
||||
<?echo mk_option($display['locale'], "","English");
|
||||
foreach (glob("$plugins/dynamix.*.xml",GLOB_NOSORT) as $xml_file) {
|
||||
foreach (glob("$plugins/lang-*.xml",GLOB_NOSORT) as $xml_file) {
|
||||
$lang = language('Language', $xml_file);
|
||||
$home = language('LanguageLocal', $xml_file);
|
||||
$name = str_replace('dynamix.', '', basename($xml_file,'.xml'));
|
||||
$name = language('LanguagePack', $xml_file);
|
||||
echo mk_option($display['locale'], $name, "$home ($lang)");
|
||||
}
|
||||
?></select>
|
||||
|
||||
@@ -64,9 +64,9 @@ case 'add':
|
||||
}
|
||||
[$home,$name] = explode(' (',urldecode($_POST['name']));
|
||||
$name = rtrim($name,')'); $i = 0;
|
||||
$place = "$plugins/dynamix.$file.xml";
|
||||
$child = ['LanguageURL','Language','LanguageLocal','Author','Name','TemplateURL','Version','Icon','Description','Changes'];
|
||||
$value = ['',$name,$home,$_SERVER['HTTP_HOST'],"$name translation",$place,date('Y.m.d',time()),'','',''];
|
||||
$place = "$plugins/lang-$file.xml";
|
||||
$child = ['LanguageURL','Language','LanguageLocal','LanguagePack','Author','Name','TemplateURL','Version','Icon','Description','Changes'];
|
||||
$value = ['',$name,$home,$file,$_SERVER['HTTP_HOST'],"$name translation",$place,date('Y.m.d',time()),'','',''];
|
||||
// create a corresponding XML file
|
||||
$xml = new SimpleXMLElement('<Language/>');
|
||||
foreach ($child as $key) $xml->addChild($key,$value[$i++]);
|
||||
@@ -84,9 +84,9 @@ case 'rm':
|
||||
if ($result = is_dir($path)) {
|
||||
exec("rm -rf $path");
|
||||
@unlink("$docroot/webGui/javascript/translate.$file.js");
|
||||
@unlink("$boot/dynamix.$file.xml");
|
||||
@unlink("$plugins/dynamix.$file.xml");
|
||||
@unlink("$tmp/dynamix.$file.xml");
|
||||
@unlink("$boot/lang-$file.xml");
|
||||
@unlink("$plugins/lang-$file.xml");
|
||||
@unlink("$tmp/lang-$file.xml");
|
||||
@unlink("$boot/dynamix/lang-$file.zip");
|
||||
// return list of installed language packs
|
||||
$installed = [];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
af_ZA=Afrikaans (Afrikaans)
|
||||
ar_SA=العربية (Arabic)
|
||||
ar_AR=العربية (Arabic)
|
||||
bs_BA=Bosanski (Bosnian)
|
||||
cs_CZ=Čeština (Czech)
|
||||
da_DK=Dansk (Danish)
|
||||
|
||||
Reference in New Issue
Block a user