diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | changelog.md | 6 | ||||
-rw-r--r-- | ncp-web/L10N.php | 36 | ||||
-rw-r--r-- | ncp-web/index.php | 26 | ||||
-rw-r--r-- | ncp-web/langs.cfg | 5 | ||||
-rw-r--r-- | ncp-web/ncp-web.cfg | 1 |
6 files changed, 32 insertions, 43 deletions
@@ -8,4 +8,5 @@ armbian/ raspbian_root raspbian_boot ncp-web/wizard.cfg +ncp-web/ncp-web.cfg docker-armhf/qemu-arm-static diff --git a/changelog.md b/changelog.md index 2d6ad8b2..c7ee6284 100644 --- a/changelog.md +++ b/changelog.md @@ -1,7 +1,9 @@ -[v0.60.7](https://github.com/nextcloud/nextcloudpi/commit/bd464b2) (2018-09-24) docker: disable auto-upgrade until it is adapted to containers +[v0.60.8](https://github.com/nextcloud/nextcloudpi/commit/57999b6) (2018-09-24) ncp-web: put configuration in a separate file from available languages -[v0.60.6](https://github.com/nextcloud/nextcloudpi/commit/1150ed8) (2018-09-24) nc-format-USB: fix +[v0.60.7](https://github.com/nextcloud/nextcloudpi/commit/cdbb750) (2018-09-24) docker: disable auto-upgrade until it is adapted to containers + +[v0.60.6 ](https://github.com/nextcloud/nextcloudpi/commit/1150ed8) (2018-09-24) nc-format-USB: fix [v0.60.5 ](https://github.com/nextcloud/nextcloudpi/commit/3de5fe0) (2018-09-23) armbian: fix locales for ncp-config 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] |