Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornachoparker <nacho@ownyourbits.com>2018-09-25 03:35:43 +0300
committernachoparker <nacho@ownyourbits.com>2018-09-25 03:38:30 +0300
commit6152e7e2addede53d8d521ebea918563ab3a4e23 (patch)
treebd708340a2d53c6ddc5f23f0f8a5a5265904d799 /ncp-web
parentcdbb750e716824cc9af11bab33e7cfd5b400416f (diff)
ncp-web: put configuration in a separate file from available languagesv0.60.8
Diffstat (limited to 'ncp-web')
-rw-r--r--ncp-web/L10N.php36
-rw-r--r--ncp-web/index.php26
-rw-r--r--ncp-web/langs.cfg5
-rw-r--r--ncp-web/ncp-web.cfg1
4 files changed, 27 insertions, 41 deletions
diff --git a/ncp-web/L10N.php b/ncp-web/L10N.php
index 71a2ab18..2fdf5434 100644
--- a/ncp-web/L10N.php
+++ b/ncp-web/L10N.php
@@ -70,15 +70,7 @@ class L10N
{
$cfg = 'ncp-web.cfg';
$line = file_get_contents( $cfg );
- $str = '';
- if (preg_match('/^LANGUAGE_=\[(([_\w]+,)*[_\w]+)\]$/', $line, $matches)) {
- $options = explode(',', $matches[1]);
- foreach ($options as $option) {
- $opt = trim( $option, "_" );
- $str .= $opt == $lang ? '_' . $opt . '_,' : $opt . ',';
- }
- }
- $str = 'LANGUAGE_=[' . rtrim( $str, ',' ) . ']';
+ $str = "LANGUAGE_=$lang";
return file_put_contents( $cfg , $str );
}
@@ -147,25 +139,15 @@ class L10N
return array_keys($langs)[0];
}
- function load_language_setting($modules_path)
+ function load_language_setting()
{
$webui_config_file = 'ncp-web.cfg';
- $fh = fopen($webui_config_file, 'r')
- or exit('{ "output": "' . $webui_config_file . ' read error" }');
- $lang = "auto";
- while ($line = fgets($fh)) {
- // drop down menu
- if (preg_match('/^LANGUAGE_=\[(([_\w]+,)*[_\w]+)\]$/', $line, $matches)) {
- $options = explode(',', $matches[1]);
- foreach ($options as $option) {
- if ($option[0] == "_" && $option[count($option) - 1] == "_") {
- fclose($fh);
- $lang = trim($option, '_');
- }
- }
- fclose($fh);
- return $lang;
- }
- }
+ $fh = fopen($webui_config_file, 'r');
+ if ($fh === false)
+ return "auto";
+
+ $lang=file_get_contents($webui_config_file);
+ fclose($fh);
+ return ltrim($lang, 'LANGUAGE_=');
}
}
diff --git a/ncp-web/index.php b/ncp-web/index.php
index 9c8ca46c..a55bd69f 100644
--- a/ncp-web/index.php
+++ b/ncp-web/index.php
@@ -114,20 +114,20 @@ HTML;
</a>
<?php
// language selection drop
- if( preg_match('/^(\w+)_=\[(([_\w]+,)*[_\w]+)\]$/', file_get_contents( 'ncp-web.cfg') , $matches) )
- {
- $options = explode(",", $matches[2]);
- echo "<select id=\"language-selection\" name=\"$matches[1]\">";
- foreach($options as $option)
- {
- echo "<option value='". trim($option, "_") ."' ";
- if( $option[0] == "_" && $option[count($option) - 1] == "_" )
- echo "selected='selected'";
- echo ">". trim($option, "_") ."</option>";
- }
- echo "<option value=\"[new]\">new..</option>";
- echo "</select>";
+ $selected_lang=$l->load_language_setting();
+
+ $fh = fopen('langs.cfg', 'r');
+ echo "<select id=\"language-selection\" name=\"language-selection\">";
+ while ($line = fgets($fh)) {
+ echo "<option value='" . $line . "' ";
+ error_log("NACHO $line - $selected_lang");
+ if( $line == $selected_lang )
+ echo "selected='selected'";
+ echo ">". $line ."</option>";
}
+ echo "<option value=\"[new]\">new..</option>";
+ echo "</select>";
+ fclose($fh);
?>
</div>
<div id="header-right">
diff --git a/ncp-web/langs.cfg b/ncp-web/langs.cfg
new file mode 100644
index 00000000..d43309ff
--- /dev/null
+++ b/ncp-web/langs.cfg
@@ -0,0 +1,5 @@
+auto
+en
+de
+es
+zh
diff --git a/ncp-web/ncp-web.cfg b/ncp-web/ncp-web.cfg
deleted file mode 100644
index 57888595..00000000
--- a/ncp-web/ncp-web.cfg
+++ /dev/null
@@ -1 +0,0 @@
-LANGUAGE_=[_auto_,en,de,es,zh]