From b1059717c72aeff7e0359bd80ac46c17ad9a5a6b Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 2 Dec 2022 13:52:24 +0100 Subject: [PATCH] more localization & yarn install script --- Core/Documents/Install.class.php | 37 +++++++++++++++++++++++ Core/Localization/de_DE/account.php | 13 ++++++++ Core/Localization/de_DE/admin.php | 1 + Core/Localization/de_DE/general.php | 1 + Core/Localization/en_US/account.php | 19 ++++++++++-- Core/Localization/en_US/admin.php | 1 + Core/Localization/en_US/general.php | 1 + Core/Templates/account/accept_invite.twig | 22 ++++++++------ Core/Templates/account/account_base.twig | 2 +- Core/Templates/account/confirm_email.twig | 20 +++++++----- Core/Templates/account/login.twig | 4 +-- Core/Templates/admin.twig | 4 +-- docker/php/Dockerfile | 5 +-- 13 files changed, 103 insertions(+), 27 deletions(-) diff --git a/Core/Documents/Install.class.php b/Core/Documents/Install.class.php index e6f45b5..ac0d2c1 100644 --- a/Core/Documents/Install.class.php +++ b/Core/Documents/Install.class.php @@ -106,6 +106,28 @@ namespace Documents\Install { return NULL; } + private function yarnInstall(string $reactDir): array { + $fds = [ + "1" => ["pipe", "w"], + "2" => ["pipe", "w"], + ]; + $proc = proc_open("yarn install --frozen-lockfile --non-interactive", $fds, $pipes, $reactDir); + $output = stream_get_contents($pipes[1]) . stream_get_contents($pipes[2]); + $status = proc_close($proc); + return [$status, $output]; + } + + private function yarnBuild(string $reactDir): array { + $fds = [ + "1" => ["pipe", "w"], + "2" => ["pipe", "w"], + ]; + $proc = proc_open("yarn run build", $fds, $pipes, $reactDir); + $output = stream_get_contents($pipes[1]) . stream_get_contents($pipes[2]); + $status = proc_close($proc); + return [$status, $output]; + } + private function composerInstall(bool $dryRun = false): array { $command = "composer install"; if ($dryRun) { @@ -159,6 +181,8 @@ namespace Documents\Install { } } + // TODO: check + $context = $this->getDocument()->getContext(); $config = $context->getConfig(); @@ -248,6 +272,11 @@ namespace Documents\Install { $success = false; } + if (!$this->command_exist("yarn")) { + $failedRequirements[] = "Yarn is not installed or cannot be found."; + $success = false; + } + if (!$success) { $msg = "The following requirements failed the check:
" . $this->createUnorderedList($failedRequirements); @@ -259,6 +288,14 @@ namespace Documents\Install { private function installDependencies(): array { list ($status, $output) = $this->composerInstall(); + if ($status === 0) { + $reactDir = implode(DIRECTORY_SEPARATOR, [WEBROOT, "react"]); + list ($status, $output) = $this->yarnInstall($reactDir); + if ($status === 0) { + list ($status, $output) = $this->yarnBuild($reactDir); + } + } + return ["success" => $status === 0, "msg" => $output]; } diff --git a/Core/Localization/de_DE/account.php b/Core/Localization/de_DE/account.php index e2d2071..4f39612 100644 --- a/Core/Localization/de_DE/account.php +++ b/Core/Localization/de_DE/account.php @@ -1,19 +1,32 @@ "Account", "login_title" => "Einloggen", "login_description" => "Loggen Sie sich in Ihren Account ein", + "accept_invite_title" => "Einladung", + "accept_invite_description" => "Schließen Sie die Registrierung ab indem Sie ein Passwort wählen", + "confirm_email_title" => "E-Mail Adresse bestätigen", + "confirm_email_description" => "Schließen Sie die Registrierung ab indem Sie Ihre E-Mail Adresse bestätigen", "form_title" => "Bitte geben Sie ihre Daten ein", "username" => "Benutzername", "username_or_email" => "Benutzername oder E-Mail", + "email" => "E-Mail Adresse", "password" => "Passwort", + "password_confirm" => "Passwort bestätigen", "remember_me" => "Eingeloggt bleiben", "signing_in" => "Einloggen", "sign_in" => "Einloggen", "forgot_password" => "Passwort vergessen?", "passwords_do_not_match" => "Die Passwörter stimmen nicht überein", + "back_to_login" => "Zurück zum Login", "register_text" => "Noch keinen Account? Jetzt registrieren", "6_digit_code" => "6-stelliger Code", "2fa_title" => "Es werden weitere Informationen zum Einloggen benötigt", "2fa_text" => "Stecke dein 2FA-Gerät ein. Möglicherweise wird noch eine Interaktion benötigt, z.B. durch Eingabe einer PIN oder durch Berühren des Geräts", + "confirming_email" => "Bestätige E-Mail Adresse", + "proceed_to_login" => "Weiter zum Login", + "invalid_link" => "Den Link den Sie besucht haben ist nicht länger gültig", + "confirm_success" => "Ihre E-Mail Adresse wurde erfolgreich bestätigt, Sie können sich jetzt einloggen", + "confirm_error" => "Fehler beim Bestätigen der E-Mail Adresse", ]; \ No newline at end of file diff --git a/Core/Localization/de_DE/admin.php b/Core/Localization/de_DE/admin.php index d74f434..3fb5441 100644 --- a/Core/Localization/de_DE/admin.php +++ b/Core/Localization/de_DE/admin.php @@ -1,6 +1,7 @@ "Administration", "dashboard" => "Dashboard", "visitor_statistics" => "Besucherstatistiken", "user_groups" => "Benutzer & Gruppen", diff --git a/Core/Localization/de_DE/general.php b/Core/Localization/de_DE/general.php index 921ae22..39fb684 100644 --- a/Core/Localization/de_DE/general.php +++ b/Core/Localization/de_DE/general.php @@ -10,4 +10,5 @@ return [ "language" => "Sprache", "loading" => "Laden", "logout" => "Ausloggen", + "noscript" => "Sie müssen Javascript aktivieren um diese Anwendung zu benutzen", ]; \ No newline at end of file diff --git a/Core/Localization/en_US/account.php b/Core/Localization/en_US/account.php index 18f9779..3020a26 100644 --- a/Core/Localization/en_US/account.php +++ b/Core/Localization/en_US/account.php @@ -1,19 +1,32 @@ "Sign In", - "description" => "Sign In into your account", + "title" => "Account", + "login_title" => "Sign In", + "login_description" => "Sign In into your account", + "accept_invite_title" => "Invitation", + "accept_invite_description" => "Complete your account registration by choosing a password", + "confirm_email_title" => "Confirm Email", + "confirm_email_description" => "Complete your registration by confirming the e-mail address", "form_title" => "Please fill with your details", "username" => "Username", "username_or_email" => "Username or E-Mail", + "email" => "E-Mail Address", "password" => "Password", + "password_confirm" => "Confirm Password", "remember_me" => "Remember Me", "signing_in" => "Signing in", "sign_in" => "Sign In", "forgot_password" => "Forgot password?", "register_text" => "Don't have an account? Sign Up", "passwords_do_not_match" => "Your passwords did not match", + "back_to_login" => "Back to Login", "6_digit_code" => "6-Digit Code", "2fa_title" => "Additional information is required for logging in", - "2fa_text" => "Plugin your 2FA-Device. Interaction might be required, e.g. typing in a PIN or touching it." + "2fa_text" => "Plugin your 2FA-Device. Interaction might be required, e.g. typing in a PIN or touching it.", + "confirming_email" => "Confirming email", + "proceed_to_login" => "Proceed to Login", + "invalid_link" => "The link you visited is no longer valid", + "confirm_success" => "Your e-mail address was successfully confirmed, you may now log in", + "confirm_error" => "Error confirming e-mail address", ]; \ No newline at end of file diff --git a/Core/Localization/en_US/admin.php b/Core/Localization/en_US/admin.php index 2fccbc4..3e822b6 100644 --- a/Core/Localization/en_US/admin.php +++ b/Core/Localization/en_US/admin.php @@ -1,6 +1,7 @@ "Administration", "dashboard" => "Dashboard", "visitor_statistics" => "Visitor Statistics", "user_groups" => "User & Groups", diff --git a/Core/Localization/en_US/general.php b/Core/Localization/en_US/general.php index 9609d28..35381b6 100644 --- a/Core/Localization/en_US/general.php +++ b/Core/Localization/en_US/general.php @@ -10,4 +10,5 @@ return [ "language" => "Language", "loading" => "Loading", "logout" => "Logout", + "noscript" => "You need Javascript enabled to run this app", ]; \ No newline at end of file diff --git a/Core/Templates/account/accept_invite.twig b/Core/Templates/account/accept_invite.twig index 5dc2f64..ca62496 100644 --- a/Core/Templates/account/accept_invite.twig +++ b/Core/Templates/account/accept_invite.twig @@ -1,44 +1,48 @@ {% extends "account/account_base.twig" %} -{% set view_title = 'Invitation' %} +{% set view_title = 'account.accept_invite_title' %} {% set view_icon = 'user-check' %} -{% set view_description = 'Finnish your account registration by choosing a password.' %} +{% set view_description = 'account.accept_invite_description' %} {% block view_content %} {% if not view.success %} - Back to login + {{ L("account.back_to_login") }} {% else %} -

Please fill with your details

+

{{ L("account.form_title") }}

- +
- +
- +
- +
- +
{% endif %} diff --git a/Core/Templates/account/account_base.twig b/Core/Templates/account/account_base.twig index 1f73e91..34368c2 100644 --- a/Core/Templates/account/account_base.twig +++ b/Core/Templates/account/account_base.twig @@ -8,7 +8,7 @@ - Account - {{ L(view_title) }} + {{ L("account.title")}} - {{ L(view_title) }} {% if site.recaptcha.enabled %} {% endif %} diff --git a/Core/Templates/account/confirm_email.twig b/Core/Templates/account/confirm_email.twig index ebc2fa2..b437a0a 100644 --- a/Core/Templates/account/confirm_email.twig +++ b/Core/Templates/account/confirm_email.twig @@ -1,17 +1,21 @@ {% extends "account/account_base.twig" %} -{% set view_title = 'Confirm Email' %} +{% set view_title = 'account.confirm_email_title' %} {% set view_icon = 'user-check' %} -{% set view_description = 'Request a password reset, once you got the e-mail address, you can choose a new password' %} +{% set view_description = 'account.confirm_email_description' %} {% block view_content %}
- Confirming email… + {{ L('account.confirming_email') }}…
- + + + diff --git a/Core/Templates/account/login.twig b/Core/Templates/account/login.twig index 80a7898..618242e 100644 --- a/Core/Templates/account/login.twig +++ b/Core/Templates/account/login.twig @@ -1,8 +1,8 @@ {% extends "account/account_base.twig" %} -{% set view_title = 'account.title' %} +{% set view_title = 'account.login_title' %} {% set view_icon = 'user-lock' %} -{% set view_description = 'account.description' %} +{% set view_description = 'account.login_description' %} {% block view_content %} diff --git a/Core/Templates/admin.twig b/Core/Templates/admin.twig index 6370959..7d669c1 100644 --- a/Core/Templates/admin.twig +++ b/Core/Templates/admin.twig @@ -1,12 +1,12 @@ {% extends "base.twig" %} {% block head %} - {{ site.name }} - Administration + {{ site.name }} - {{ L("admin.admin") }} {% endblock %} {% block body %} - +
diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile index a3faeb7..927866c 100644 --- a/docker/php/Dockerfile +++ b/docker/php/Dockerfile @@ -7,10 +7,11 @@ RUN mkdir -p /application/core/Configuration /var/www/.gnupg && \ # YAML + dev dependencies RUN apt-get update -y && \ - apt-get install -y libyaml-dev libzip-dev libgmp-dev libpng-dev gnupg2d && \ + apt-get install -y libyaml-dev libzip-dev libgmp-dev libpng-dev gnupg2d nodejs npm && \ apt-get clean && \ pecl install yaml && docker-php-ext-enable yaml && \ - docker-php-ext-install gd + docker-php-ext-install gd && \ + npm install --global yarn && ln -s /usr/local/bin/yarn /usr/bin/yarn # Runkit (no stable release available) RUN pecl install runkit7-4.0.0a3 && docker-php-ext-enable runkit7 && \