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:
authortheCalcaholic <3knoeppl@informatik.uni-hamburg.de>2018-02-26 22:21:59 +0300
committernachoparker <nacho@ownyourbits.com>2018-02-26 22:29:49 +0300
commit1a7c8b9b5e4b0cbda0e6c605ccab4d195c593a33 (patch)
tree6f6a586fe77287ca3d3b927a165bef936ab7589f
parentc4a111c28948d56b759566b756c04a844695d720 (diff)
ncp-web: add localization (#372)v0.46.35
* Implement localization loader L10N. Localize a few strings in index.php for testing. * Determine language from HTTP_ACCEPT_LANGUAGE header. * Fix parsing of available languages for localization. * Fix parsing of language translations (for localization). * Fix function L10N->find_language * Change variable naming to comply with conventions. * Add remaining localize calls in index.php. Add more localization strings. * Fix styles to prevent check mark from being hidden. * Handle exception in case localization couldn't be loaded. * Add module localization support. * Fix detection of core module in L10N->load * Remove module specific localization from core l10n file. * Fix determination of module name in L10N->load. * Add localization files for more modules. * Ignore l10n directory in modules path. * Add support for dropdown lists in module settings. * Add support for saving dropdown menus. * Fix regex for recognizing dropdown option lists. * Fix dropdown list regex not recognizing active option. * Fix typo in ncp-launcher.php * Workaround for jquery's 'find' method not working. //TODO: Find proper fix. * Fix parsing of dropdown lists when updating config. * Load language setting from config if available. * add ncp-provisioning to SD card images * Add intellij config to gitignore * Fix bug when loading language from nc-webui config. * Remove redundant language definition. Replace umlauts by html special char expressions. * Change selected option markup from `*<option>*` to `_<option>_`. * Remove ide metadata. * Add translations for ncp-app nc-backup. * Add translation hooks to ncp-launcher.php * Fix type in translations for nc-backup * Remove translation hooks for field contents in ncp-launcher.php
-rw-r--r--.gitignore1
-rw-r--r--changelog.md4
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-audit/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-automount/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-autoupdate-ncp/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-backup-auto/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-backup/de.json7
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-database/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-datadir/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-export-npc/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-fix-permissions/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-format-USB/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-forward-ports/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-httpsonly/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-import-ncp/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-info/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-init/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-limits/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-nextcloud/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-notify-updates/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-passwd/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-ramlogs/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-restore/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-scan-auto/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-scan/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-snapshot-auto/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-snapshot/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-static-IP/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-swapfile/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-update/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-webui/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/nc-wifi/de.json3
-rw-r--r--etc/nextcloudpi-config.d/l10n/unattended-upgrades/de.json3
-rw-r--r--etc/nextcloudpi-config.d/nc-webui.sh1
-rw-r--r--ncp-web/L10N.php127
-rw-r--r--ncp-web/index.php175
-rw-r--r--ncp-web/l10n/de.json9
-rw-r--r--ncp-web/l10n/index.html0
-rw-r--r--ncp-web/l10n/index.php1
-rw-r--r--ncp-web/ncp-launcher.php39
-rw-r--r--ncp-web/ncp.css2
-rw-r--r--ncp-web/ncp.js15
-rw-r--r--nextcloudpi.sh1
-rwxr-xr-xupdate.sh2
44 files changed, 385 insertions, 89 deletions
diff --git a/.gitignore b/.gitignore
index 75fe7a59..981ff30f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
.*.swp
*.img
*.bz2
+.idea/
qemu-raspbian-network/
torrent/
armbian/
diff --git a/changelog.md b/changelog.md
index e562b221..4e65e132 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,7 @@
-[v0.46.34](https://github.com/nextcloud/nextcloudpi/commit/2694914) (2018-02-26) ncp-web: fix responsive in iPad
+[v0.46.35](https://github.com/nextcloud/nextcloudpi/commit/e417926) (2018-02-26) ncp-web: add localization (#372)
+
+[v0.46.34](https://github.com/nextcloud/nextcloudpi/commit/3fc902b) (2018-02-26) ncp-web: fix responsive in iPad
[v0.46.33](https://github.com/nextcloud/nextcloudpi/commit/dea4836) (2018-02-23) Added some useful comments for first time users
diff --git a/etc/nextcloudpi-config.d/l10n/nc-audit/de.json b/etc/nextcloudpi-config.d/l10n/nc-audit/de.json
new file mode 100644
index 00000000..8638ebbc
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-audit/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-audit": "Sicherheitsüberprüfung"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-automount/de.json b/etc/nextcloudpi-config.d/l10n/nc-automount/de.json
new file mode 100644
index 00000000..8052bd35
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-automount/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-automount": "Automatische Datenträgereinbindung"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-autoupdate-ncp/de.json b/etc/nextcloudpi-config.d/l10n/nc-autoupdate-ncp/de.json
new file mode 100644
index 00000000..ec3bb9f0
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-autoupdate-ncp/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-autoupdate-ncp": "Automatische NextCloudPi Updates"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-backup-auto/de.json b/etc/nextcloudpi-config.d/l10n/nc-backup-auto/de.json
new file mode 100644
index 00000000..ee2d5513
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-backup-auto/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-backup-auto": "Automatische Backups"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-backup/de.json b/etc/nextcloudpi-config.d/l10n/nc-backup/de.json
new file mode 100644
index 00000000..401a905e
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-backup/de.json
@@ -0,0 +1,7 @@
+{"translations": {
+ "nc-backup": "Backup erstellen",
+ "DESTDIR": "Zielverzeichnis",
+ "INCLUDEDATA": "Inkl. Dateien",
+ "COMPRESS": "Komprimieren",
+ "BACKUPLIMIT": "Maximale Anzahl"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-database/de.json b/etc/nextcloudpi-config.d/l10n/nc-database/de.json
new file mode 100644
index 00000000..057e758a
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-database/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-database": "Datenbank"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-datadir/de.json b/etc/nextcloudpi-config.d/l10n/nc-datadir/de.json
new file mode 100644
index 00000000..e8e8605f
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-datadir/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-datadir": "Datenverzeichnis"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-export-npc/de.json b/etc/nextcloudpi-config.d/l10n/nc-export-npc/de.json
new file mode 100644
index 00000000..00f29dda
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-export-npc/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-export-ncp": "NCP Export"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-fix-permissions/de.json b/etc/nextcloudpi-config.d/l10n/nc-fix-permissions/de.json
new file mode 100644
index 00000000..ff44194f
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-fix-permissions/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-fix-permissions": "Berechtigungen wiederherstellen"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-format-USB/de.json b/etc/nextcloudpi-config.d/l10n/nc-format-USB/de.json
new file mode 100644
index 00000000..055f640b
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-format-USB/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-format-USB": "USB Laufwerke formatieren"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-forward-ports/de.json b/etc/nextcloudpi-config.d/l10n/nc-forward-ports/de.json
new file mode 100644
index 00000000..a62d07bd
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-forward-ports/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-forward-ports": "Portweiterleitungen"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-httpsonly/de.json b/etc/nextcloudpi-config.d/l10n/nc-httpsonly/de.json
new file mode 100644
index 00000000..f82b4830
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-httpsonly/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-httpsonly": "HTTPS Zwang"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-import-ncp/de.json b/etc/nextcloudpi-config.d/l10n/nc-import-ncp/de.json
new file mode 100644
index 00000000..b9880ed1
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-import-ncp/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-import-ncp": "NCP Import"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-info/de.json b/etc/nextcloudpi-config.d/l10n/nc-info/de.json
new file mode 100644
index 00000000..9993d09b
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-info/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-info": "System Informationen"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-init/de.json b/etc/nextcloudpi-config.d/l10n/nc-init/de.json
new file mode 100644
index 00000000..9bed233c
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-init/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-init": "Initialisierung"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-limits/de.json b/etc/nextcloudpi-config.d/l10n/nc-limits/de.json
new file mode 100644
index 00000000..705aefe4
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-limits/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-limits": "Systembegrenzungen"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-nextcloud/de.json b/etc/nextcloudpi-config.d/l10n/nc-nextcloud/de.json
new file mode 100644
index 00000000..1ececb2b
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-nextcloud/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-nextcloud": "Nextcloud Einstellungen"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-notify-updates/de.json b/etc/nextcloudpi-config.d/l10n/nc-notify-updates/de.json
new file mode 100644
index 00000000..21660a30
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-notify-updates/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-notify-updates": "Update-Benachrichtigungen"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-passwd/de.json b/etc/nextcloudpi-config.d/l10n/nc-passwd/de.json
new file mode 100644
index 00000000..ef69f438
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-passwd/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-passwd": "NCP Passwort"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-ramlogs/de.json b/etc/nextcloudpi-config.d/l10n/nc-ramlogs/de.json
new file mode 100644
index 00000000..bc1cb5c3
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-ramlogs/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-ramlogs": "Ram Logs"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-restore/de.json b/etc/nextcloudpi-config.d/l10n/nc-restore/de.json
new file mode 100644
index 00000000..69d4b619
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-restore/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-restore": "Wiederherstellung"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-scan-auto/de.json b/etc/nextcloudpi-config.d/l10n/nc-scan-auto/de.json
new file mode 100644
index 00000000..cf168150
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-scan-auto/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-scan-auto": "Automatischer Datei-Scan"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-scan/de.json b/etc/nextcloudpi-config.d/l10n/nc-scan/de.json
new file mode 100644
index 00000000..3469297e
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-scan/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-scan": "Datei-Scan"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-snapshot-auto/de.json b/etc/nextcloudpi-config.d/l10n/nc-snapshot-auto/de.json
new file mode 100644
index 00000000..75f71db5
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-snapshot-auto/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-snapshot-auto": "Automatische Snapshots"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-snapshot/de.json b/etc/nextcloudpi-config.d/l10n/nc-snapshot/de.json
new file mode 100644
index 00000000..b236539b
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-snapshot/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-snapshot": "Snapshot erstellen"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-static-IP/de.json b/etc/nextcloudpi-config.d/l10n/nc-static-IP/de.json
new file mode 100644
index 00000000..45f0038b
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-static-IP/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-static-IP": "Statische IP Adresse"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-swapfile/de.json b/etc/nextcloudpi-config.d/l10n/nc-swapfile/de.json
new file mode 100644
index 00000000..76fd573d
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-swapfile/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-swapfile": "Swap Datei"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-update/de.json b/etc/nextcloudpi-config.d/l10n/nc-update/de.json
new file mode 100644
index 00000000..054011ff
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-update/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-update": "Update"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-webui/de.json b/etc/nextcloudpi-config.d/l10n/nc-webui/de.json
new file mode 100644
index 00000000..4413d699
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-webui/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-webui": "NCP Weboberfläche"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/nc-wifi/de.json b/etc/nextcloudpi-config.d/l10n/nc-wifi/de.json
new file mode 100644
index 00000000..6517b76e
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/nc-wifi/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "nc-wifi": "WLAN"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/l10n/unattended-upgrades/de.json b/etc/nextcloudpi-config.d/l10n/unattended-upgrades/de.json
new file mode 100644
index 00000000..1c63a5a9
--- /dev/null
+++ b/etc/nextcloudpi-config.d/l10n/unattended-upgrades/de.json
@@ -0,0 +1,3 @@
+{"translations": {
+ "unattended-upgrades": "Unüberwachte System-Upgrades"
+}} \ No newline at end of file
diff --git a/etc/nextcloudpi-config.d/nc-webui.sh b/etc/nextcloudpi-config.d/nc-webui.sh
index e9709cdc..fe7437cb 100644
--- a/etc/nextcloudpi-config.d/nc-webui.sh
+++ b/etc/nextcloudpi-config.d/nc-webui.sh
@@ -14,6 +14,7 @@
#
ACTIVE_=yes
+LANGUAGE_=[_auto_,en,de]
DESCRIPTION="Enable or disable the NCP web interface"
configure()
diff --git a/ncp-web/L10N.php b/ncp-web/L10N.php
new file mode 100644
index 00000000..fc726922
--- /dev/null
+++ b/ncp-web/L10N.php
@@ -0,0 +1,127 @@
+<?php
+
+class L10N {
+ private $translations = [];
+ const default_language = "en_US";
+ private $language;
+
+ public function __construct($desired_languages, $l10n_dir, $modules_path=null)
+ {
+ if (!isset($desired_languages)) {
+ $desired_languages = "";
+ }
+
+ $l10n_dir = rtrim($l10n_dir, '/');
+ $available_languages = array_filter(scandir($l10n_dir),
+ function ($s) {
+ return pathinfo($s, PATHINFO_EXTENSION) == "json";
+ });
+ $available_languages = array_map(
+ function ($s) {
+ return basename($s, ".json");
+ },
+ $available_languages);
+
+ $desired_lang = $this->load_language_setting($modules_path);
+ if($desired_lang != "auto")
+ {
+ $desired_languages = $desired_lang;
+ }
+ $lang = $this->find_language($available_languages, $desired_languages);
+ $this->language = $lang;
+ if ($lang === L10N::default_language || !file_exists(join('/', [$l10n_dir, $lang . ".json"])) || !$this->load($lang, $l10n_dir, $modules_path)) {
+ $this->language = L10N::default_language;
+ }
+ }
+
+ function load($lang, $l10n_dir, $modules_path)
+ {
+ $modules_path = join('/', [rtrim($modules_path, '/'), $l10n_dir]);
+ $files = [join('/', [$l10n_dir, $lang . ".json"])];
+ if (is_dir($modules_path)) {
+ foreach (scandir($modules_path) as $dir) {
+ $file_path = join('/', [$modules_path, trim($dir, '/'), $lang . ".json"]);
+ if (is_file($file_path)) {
+ array_push($files, $file_path);
+ }
+ }
+ }
+
+ $jsonError = null;
+ foreach ($files as $file) {
+ $module_name = pathinfo(pathinfo($file, PATHINFO_DIRNAME), PATHINFO_BASENAME);
+ if( $module_name == pathinfo($l10n_dir, PATHINFO_BASENAME)) {
+ $module_name = "__core__";
+ }
+ $json = json_decode(file_get_contents($file), true);
+ if (!is_array($json)) {
+ $jsonError = json_last_error();
+ continue;
+ }
+ $this->translations[$module_name] = $json['translations'];
+ }
+ return ($jsonError == null);
+ }
+
+ public function __($text, $module="__core__") {
+ if( isset($this->translations[$module]) && isset($this->translations[$module][$text])) {
+ return $this->translations[$module][$text];
+ }
+ return $text;
+ }
+
+ function find_language(array $available_languages, $desired_language) {
+
+ $available_languages = array_flip($available_languages);
+ $langs = [];
+ preg_match_all('~([\w-]+)(?:[^,\d]+([\d.]+))?~', strtolower($desired_language), $matches, PREG_SET_ORDER);
+
+ foreach($matches as $match) {
+
+ list($a, $b) = explode('-', $match[1]) + array('', '');
+ $value = isset($match[2]) ? (float) $match[2] : 1.0;
+
+ if(isset($available_languages[$match[1]])) {
+ $langs[$match[1]] = $value;
+ continue;
+ }
+
+ if(isset($available_languages[$a])) {
+ $langs[$a] = $value - 0.1;
+ }
+
+ }
+ arsort($langs);
+
+ if(count($langs) == 0) {
+ return L10N::default_language;
+ }
+ return array_keys($langs)[0];
+ }
+
+ function load_language_setting($modules_path) {
+ $webui_config_file = join('/', [rtrim($modules_path, '/'), 'nc-webui.sh']);
+ $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;
+ }
+ }
+
+ }
+}
diff --git a/ncp-web/index.php b/ncp-web/index.php
index 52ce02c8..70a6e26d 100644
--- a/ncp-web/index.php
+++ b/ncp-web/index.php
@@ -8,57 +8,71 @@
-->
<!DOCTYPE html>
-<html class="ng-csp" data-placeholder-focus="false" lang="en" >
+<html class="ng-csp" data-placeholder-focus="false" lang="en">
<head>
- <meta charset="utf-8">
- <title>NextCloudPi Panel</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <meta name="referrer" content="never">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
- <meta name="mobile-web-app-capable" content="yes">
-<?php
+ <meta charset="utf-8">
+ <title>NextCloudPi Panel</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <meta name="referrer" content="never">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
+ <meta name="mobile-web-app-capable" content="yes">
+ <?php
session_start();
+ $modules_path = '/usr/local/etc/nextcloudpi-config.d/';
+ $l10nDir = "l10n";
+
+ // security headers
+ header("Content-Security-Policy: default-src 'none'; script-src 'self'; connect-src 'self'; img-src 'self'; style-src 'self'; object-src 'self';");
+ header("X-XSS-Protection: 1; mode=block");
+ header("X-Content-Type-Options: nosniff");
+ header("X-Robots-Tag: none");
+ header("X-Permitted-Cross-Domain-Policies: none");
+ header("X-Frame-Options: DENY");
+ header("Cache-Control: max-age=15778463");
+ ini_set('session.cookie_httponly', 1);
+ if (isset($_SERVER['HTTPS']))
+ ini_set('session.cookie_secure', 1);
+
+ // HTTP2 push headers
+ header("Link: </minified.js>; rel=preload; as=script;,</ncp.js>; rel=preload; as=script;,</ncp.css>; rel=preload; as=style;,</img/ncp-logo.svg>; rel=preload; as=image;, </loading-small.gif>; rel=preload; as=image;, rel=preconnect href=ncp-launcher.php;");
- // security headers
- header("Content-Security-Policy: default-src 'none'; script-src 'self'; connect-src 'self'; img-src 'self'; style-src 'self'; object-src 'self';");
- header("X-XSS-Protection: 1; mode=block");
- header("X-Content-Type-Options: nosniff");
- header("X-Robots-Tag: none");
- header("X-Permitted-Cross-Domain-Policies: none");
- header("X-Frame-Options: DENY");
- header("Cache-Control: max-age=15778463");
- ini_set('session.cookie_httponly', 1);
- if ( isset($_SERVER['HTTPS']) )
- ini_set('session.cookie_secure', 1);
-
- // HTTP2 push headers
- header("Link: </minified.js>; rel=preload; as=script;,</ncp.js>; rel=preload; as=script;,</ncp.css>; rel=preload; as=style;,</img/ncp-logo.svg>; rel=preload; as=image;, </loading-small.gif>; rel=preload; as=image;, rel=preconnect href=ncp-launcher.php;");
-?>
-<link rel="icon" type="image/png" href="img/favicon.png" />
-<link rel="stylesheet" href="ncp.css">
+ ?>
+ <link rel="icon" type="image/png" href="img/favicon.png"/>
+ <link rel="stylesheet" href="ncp.css">
</head>
<body id="body-user">
- <noscript>
- <div id="nojavascript"> <div>This application requires JavaScript for correct operation. Please <a href="http://enable-javascript.com/" target="_blank" rel="noreferrer">enable JavaScript</a> and reload the page. </div> </div>
- </noscript>
- <div id="notification-container">
- <?php
- exec( "ncp-test-updates" , $output, $ret );
- if ( $ret == 0 )
- {
- echo '<div id="notification">';
- echo '<div id="update-notification" class="row type-error closeable">';
- echo "version " . file_get_contents( "/var/run/.ncp-latest-version" ) . " is available";
- echo '<a class="action close icon-close" href="#" alt="Dismiss"></a>';
- echo '</div>';
- echo '</div>';
- }
- ?>
- </div>
+<?php
+ require("L10N.php");
+ try {
+ $l = new L10N($_SERVER["HTTP_ACCEPT_LANGUAGE"], $l10nDir, $modules_path);
+ } catch (Exception $e) {
+ die("<p class='error'>Error while loading localizations!</p>");
+ }
+?>
+<noscript>
+ <div id="nojavascript">
+ <div>
+ <?php sprintf($l->__("This application requires JavaScript for correct operation. Please %s enable JavaScript %s and reload the page."),
+ "<a href=\"http://enable-javascript.com/\" target=\"_blank\" rel=\"noreferrer\">", "</a>"); ?>
+ </div>
+ </div>
+</noscript>
+<div id="notification-container">
+ <?php
+ exec("ncp-test-updates", $output, $ret);
+ if ($ret == 0) {
+ echo '<div id="notification">';
+ echo '<div id="update-notification" class="row type-error closeable">';
+ sprintf($l->__("version %s is available"), file_get_contents("/var/run/.ncp-latest-version"));
+ echo '<a class="action close icon-close" href="#" alt="Dismiss"></a>';
+ echo '</div>';
+ echo '</div>';
+ }
+ ?>
+</div>
<?php
- if ( file_exists( 'wizard') && !file_exists( 'wizard.cfg' ) )
- {
+ if (file_exists('wizard') && !file_exists('wizard.cfg')) {
echo <<<HTML
<div id="first-run-wizard">
<div class='dialog'>
@@ -68,14 +82,14 @@
<br>
<a href="wizard"><img class="wizard-btn" src="wizard/img/ncp-logo.svg" class="wizard"></a>
<br>
- <button type="button" class="wizard-btn" id="go-wizard" >run </button>
- <button type="button" class="first-run-close" id="skip-wizard" >skip </button>
- <button type="button" class="first-run-close" id="close-wizard">close</button>
+ <button type="button" class="wizard-btn" id="go-wizard" >{$l->__("run")} </button>
+ <button type="button" class="first-run-close" id="skip-wizard" >{$l->__("skip")} </button>
+ <button type="button" class="first-run-close" id="close-wizard">{$l->__("close")}</button>
<br><br>
</div>
</div>
HTML;
- touch( 'wizard.cfg' );
+ touch('wizard.cfg');
}
?>
@@ -103,14 +117,14 @@ HTML;
</div>
</a>
HTML;
-?>
- <div id="poweroff">
- <div id="expand">
- <div class="icon-power-white"></div>
+ ?>
+ <div id="poweroff">
+ <div id="expand">
+ <div class="icon-power-white"></div>
+ </div>
+ </div>
</div>
- </div>
- </div>
- </header>
+</header>
<div id="content-wrapper">
<div id="content" class="app-files" role="main">
@@ -119,40 +133,38 @@ HTML;
<ul id="ncp-options">
<?php
- // fill options with contents from directory
- $path = '/usr/local/etc/nextcloudpi-config.d/';
- $files = array_diff(scandir($path), array('.', '..','nc-wifi.sh'));
+ // fill options with contents from directory
+ $files = array_diff(scandir($modules_path), array('.', '..', 'nc-wifi.sh', 'l10n'));
- foreach($files as $file)
- {
- $script = pathinfo( $file , PATHINFO_FILENAME );
- $txt = file_get_contents( $path . $file );
+ foreach ($files as $file) {
+ $script = pathinfo($file, PATHINFO_FILENAME);
+ $txt = file_get_contents($modules_path . $file);
- $active = "";
- if ( preg_match('/^ACTIVE_=yes$/m', $txt, $matches) )
- $active = " ✓";
+ $active = "";
+ if (preg_match('/^ACTIVE_=yes$/m', $txt, $matches))
+ $active = " ✓";
- echo "<li id=\"$script\" class=\"nav-recent\">";
- echo "<a href=\"#\"> $script$active </a>";
+ echo "<li id=\"$script\" class=\"nav-recent\">";
+ echo "<a href=\"#\"> {$l->__($script, $script)}$active </a>";
- if ( preg_match('/^DESCRIPTION="(.*)"$/m', $txt, $matches) )
- echo "<input id=\"$script-desc\" type=\"hidden\" value=\"$matches[1]\" />";
+ if (preg_match('/^DESCRIPTION="(.*)"$/m', $txt, $matches))
+ echo "<input id=\"$script-desc\" type=\"hidden\" value=\"{$l->__($matches[1], $script)}\" />";
- if ( preg_match('/^INFO="(.*)"/msU', $txt, $matches) )
- echo "<input id=\"$script-info\" type=\"hidden\" value=\"$matches[1]\" />";
+ if (preg_match('/^INFO="(.*)"/msU', $txt, $matches))
+ echo "<input id=\"$script-info\" type=\"hidden\" value=\"{$l->__($matches[1], $script)}\" />";
- if ( preg_match('/^INFOTITLE="(.*)"/msU', $txt, $matches) )
- echo "<input id=\"$script-infotitle\" type=\"hidden\" value=\"$matches[1]\" />";
+ if (preg_match('/^INFOTITLE="(.*)"/msU', $txt, $matches))
+ echo "<input id=\"$script-infotitle\" type=\"hidden\" value=\"{$l->__($matches[1], $script)}\" />";
- echo "</li>";
- }
+ echo "</li>";
+ }
?>
</ul>
</div>
<div id="app-content">
<div id="app-navigation-toggle" class="icon-menu hidden"></div>
- <h2 id="config-box-title">Configure NextCloudPi features</h2>
+ <h2 id="config-box-title"><?php echo $l->__("Configure NextCloudPi features"); ?></h2>
<a href="#" target="_blank">
<div id="config-extra-info" class="icon-info"></div>
</a>
@@ -162,16 +174,15 @@ HTML;
<form>
<div id="config-box"></div>
<div id="config-button-wrapper">
- <button id="config-button">Run</button>
+ <button id="config-button"><?php echo $l->__("Run"); ?></button>
<img id="loading-gif" src="loading-small.gif">
<div id="circle-retstatus" class="icon-red-circle"></div>
</div>
</form>
<textarea readonly id="details-box" rows="12"></textarea>
</div>
- </div>
- </div>
+ </div>
<div id="poweroff-dialog" class='dialog primary hidden'>
<div id='poweroff-option_shutdown' class='button big-button'>
@@ -183,11 +194,11 @@ HTML;
</div>
<?php
- include ('csrf.php');
+ include('csrf.php');
echo '<input type="hidden" id="csrf-token" name="csrf-token" value="' . getCSRFToken() . '"/>';
?>
- <script src="minified.js"></script>
- <script src="ncp.js"></script>
+ <script src="minified.js"></script>
+ <script src="ncp.js"></script>
</body>
</html>
diff --git a/ncp-web/l10n/de.json b/ncp-web/l10n/de.json
new file mode 100644
index 00000000..59684a9e
--- /dev/null
+++ b/ncp-web/l10n/de.json
@@ -0,0 +1,9 @@
+{"translations": {
+ "This application requires JavaScript for correct operation. Please %s enable JavaScript %s and reload the page.":
+ "Diese Anwendung ben&ouml;tigt Javascript um richtig zu funktionieren. Bitte %s aktivieren Sie JavaScript %s und laden die Seite dann neu.",
+ "version %s is available": "Eine neue Version ist verf&uuml;gbar: %s.",
+ "run": "Ausführen",
+ "skip": "&Uuml;berspringen",
+ "close": "Schlie&szlig;en",
+ "Configure NextCloudPi features": "NextCloudPi Funktionen konfigurieren"
+}}
diff --git a/ncp-web/l10n/index.html b/ncp-web/l10n/index.html
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/ncp-web/l10n/index.html
diff --git a/ncp-web/l10n/index.php b/ncp-web/l10n/index.php
new file mode 100644
index 00000000..a8143662
--- /dev/null
+++ b/ncp-web/l10n/index.php
@@ -0,0 +1 @@
+<?php \ No newline at end of file
diff --git a/ncp-web/ncp-launcher.php b/ncp-web/ncp-launcher.php
index 7e905e7c..f0bb591d 100644
--- a/ncp-web/ncp-launcher.php
+++ b/ncp-web/ncp-launcher.php
@@ -11,8 +11,18 @@
include ('csrf.php');
session_start();
+$modules_path = '/usr/local/etc/nextcloudpi-config.d/';
+$l10nDir = "l10n";
ignore_user_abort( true );
+
+require("L10N.php");
+try {
+ $l = new L10N($_SERVER["HTTP_ACCEPT_LANGUAGE"], $l10nDir, $modules_path);
+} catch (Exception $e) {
+ die(json_encode("<p class='error'>Error while loading localizations!</p>"));
+}
+
if ( $_POST['action'] == "cfgreq" )
{
if ( !$_POST['ref'] ) exit( '{ "output": "Invalid request" }' );
@@ -43,16 +53,33 @@ if ( $_POST['action'] == "cfgreq" )
if ( $matches[2] == "yes" )
$checked = "checked";
$output = $output . "<tr>";
- $output = $output . "<td><label for=\"$matches[1]\">$matches[1]</label></td>";
+ $output = $output . "<td><label for=\"$matches[1]\">". $l->__($matches[1], $_POST['ref']) ."</label></td>";
$output = $output . "<td><input type=\"checkbox\" id=\"$matches[1]\" name=\"$matches[1]\" value=\"$matches[2]\" $checked></td>";
$output = $output . "</tr>";
}
-
+ // drop down menu
+ else if(preg_match('/^(\w+)_=\[(([_\w]+,)*[_\w]+)\]$/', $line, $matches))
+ {
+ $options = explode(",", $matches[2]);
+ $output .= "<tr>";
+ $output .= "<td><label for=\"$matches[1]\">". $l->__($matches[1], $_POST['ref']) ."</label></td>";
+ $output .= "<td><select id=\"$matches[1]\" name=\"$matches[1]\">";
+ foreach($options as $option)
+ {
+ $output .= "<option value='". trim($option, "_") ."' ";
+ if( $option[0] == "_" && $option[count($option) - 1] == "_" )
+ {
+ $output .="selected='selected'";
+ }
+ $output .= ">". $l->__(trim($option, "_"), $_POST['ref']) ."</option>";
+ }
+ $output .= "</select></td></tr>";
+ }
// text field
else if ( preg_match('/^(\w+)_=(.*)$/', $line, $matches) )
{
$output = $output . "<tr>";
- $output = $output . "<td><label for=\"$matches[1]\">$matches[1]</label></td>";
+ $output = $output . "<td><label for=\"$matches[1]\">". $l->__($matches[1], $_POST['ref']) ."</label></td>";
$output = $output . "<td><input type=\"text\" name=\"$matches[1]\" id=\"$matches[1]\" value=\"$matches[2]\" size=\"40\"></td>";
$output = $output . "</tr>";
}
@@ -87,7 +114,11 @@ else if ( $_POST['action'] == "launch" && $_POST['config'] )
if ( !empty( $params ) )
foreach( $params as $name => $value )
{
- preg_match( '/^[\w.,@_\/-]+$/' , $value , $matches )
+ if( is_array($value))
+ {
+ $value = "[". join(",", $value) ."]";
+ }
+ preg_match( '/^[\[\]\w.,@_\/-]+$/' , $value , $matches )
or exit( '{ "output": "Invalid input" , "token": "' . getCSRFToken() . '" }' );
$code = preg_replace( '/\n' . $name . '_=.*' . PHP_EOL . '/' ,
PHP_EOL . $name . '_=' . $value . PHP_EOL ,
diff --git a/ncp-web/ncp.css b/ncp-web/ncp.css
index 97ac4b23..447a9c47 100644
--- a/ncp-web/ncp.css
+++ b/ncp-web/ncp.css
@@ -628,7 +628,7 @@ kbd {
}
#app-navigation li > a {
display:block;
- width:100%;
+ width:90%;
line-height:44px;
min-height:44px;
padding:0 12px;
diff --git a/ncp-web/ncp.js b/ncp-web/ncp.js
index 615d091b..5d60537c 100644
--- a/ncp-web/ncp.js
+++ b/ncp-web/ncp.js
@@ -96,12 +96,25 @@ $(function()
// create configuration object
var cfg = {};
- $( 'input' , '#config-box' ).each( function(item){
+ $( 'input' , '#config-box' ).each( function(item){
if( item.getAttribute('type') == 'checkbox' )
item.value = item.checked ? 'yes' : 'no';
+
cfg[item.name] = item.value;
} );
+ $( 'select', '#config-box' ).each( function(item) {
+ var select = {
+ 'id': item.name,
+ 'value': []
+ };
+ $("#" + item.id + '>option').each(function(option) {
+ select.value.push(option.selected ? "_" + option.value + "_" : "" + option.value);
+ });
+ cfg[select.id] = select.value;
+ });
+
+
// reset box
$('#details-box').fill();
$('#details-box').show();
diff --git a/nextcloudpi.sh b/nextcloudpi.sh
index 03b1227a..b070b712 100644
--- a/nextcloudpi.sh
+++ b/nextcloudpi.sh
@@ -88,6 +88,7 @@ Listen 4443
</Directory>
EOF
+
$APTINSTALL libapache2-mod-authnz-external pwauth
a2enmod authnz_external authn_core auth_basic
a2ensite ncp
diff --git a/update.sh b/update.sh
index 8706dde4..a5b9785d 100755
--- a/update.sh
+++ b/update.sh
@@ -99,6 +99,8 @@ for file in etc/nextcloudpi-config.d/*; do
cp "$file" /usr/local/"$file"
done
+cp -rT etc/nextcloudpi-config.d/l10n /usr/local/etc/nextcloudpi-config.d/l10n
+
# these files can contain sensitive information, such as passwords
chown -R root:www-data /usr/local/etc/nextcloudpi-config.d
chmod 660 /usr/local/etc/nextcloudpi-config.d/*