Skip to content

Commit

Permalink
feat: added translations (#2492)
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Oct 15, 2023
1 parent b97857a commit a91b9ce
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 10 deletions.
11 changes: 9 additions & 2 deletions phpmyfaq/admin/api/index.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* Private phpMyFAQ Admin API: everything for the online update
* Private phpMyFAQ Admin API
*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
Expand All @@ -17,6 +17,7 @@
*/

use phpMyFAQ\Configuration;
use phpMyFAQ\Language;
use phpMyFAQ\Translation;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -38,14 +39,20 @@
$response = new JsonResponse();
$request = Request::createFromGlobals();

//
// Get language (default: english)
//
$language = new Language($faqConfig);
$currentLanguage = $language->setLanguageByAcceptLanguage();

//
// Set translation class
//
try {
Translation::create()
->setLanguagesDir(PMF_TRANSLATION_DIR)
->setDefaultLanguage('en')
->setCurrentLanguage('en') // currently hardcoded
->setCurrentLanguage($currentLanguage)
->setMultiByteLanguage();
} catch (Exception $e) {
echo '<strong>Error:</strong> ' . $e->getMessage();
Expand Down
12 changes: 6 additions & 6 deletions phpmyfaq/admin/assets/templates/configuration/upgrade.twig
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
<div id="pmf-update-step-health-check" class="card shadow w-100 mb-3">
<div class="card-body">
<h5 class="card-title">
1. Check for System Health
{{ headerCheckHealth }}
</h5>
<p class="card-text">
This checks the correct file permissions and folder structure of your phpMyFAQ installation.
{{ msgHealthCheck }}
</p>
<!-- Step 1: Check for system health -->
<div class="d-grid gap-2 d-md-flex justify-content-between">
<button type="button" class="btn btn-sm btn-primary mb-2" id="pmf-button-check-health">
System health check
{{ buttonCheckHealth }}
</button>
<output id="result-check-health"></output>
</div>
Expand All @@ -29,15 +29,15 @@
<div id="pmf-update-step-check-versions" class="card shadow w-100 mb-3">
<div class="card-body">
<h5 class="card-title">
2. Check for Updates
{{ headerCheckUpdates }}
</h5>
<p class="card-text">
You can check for new versions of phpMyFAQ, re-install or update your installation.
{{ msgUpdateCheck }}
</p>
<!-- Step 2: Check for a new version -->
<div class="d-grid gap-2 d-md-flex justify-content-between">
<button type="button" class="btn btn-sm btn-primary mb-2" id="pmf-button-check-updates">
Check for a new version
{{ buttonCheckUpdates }}
</button>
<output id="result-check-versions"></output>
</div>
Expand Down
6 changes: 6 additions & 0 deletions phpmyfaq/admin/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
if ($user->perm->hasPermission($user->getUserId(), 'editconfig')) {
$templateVars = [
'adminHeaderUpgrade' => Translation::get('ad_menu_upgrade'),
'headerCheckHealth' => Translation::get('headerCheckHealth'),
'msgHealthCheck' => Translation::get('msgHealthCheck'),
'buttonCheckHealth' => Translation::get('buttonCheckHealth'),
'headerCheckUpdates' => Translation::get('headerCheckUpdates'),
'msgUpdateCheck' => Translation::get('msgUpdateCheck'),
'buttonCheckUpdates' => Translation::get('buttonCheckUpdates'),
'isOnNightlies' => $faqConfig->get('upgrade.releaseEnvironment') === ReleaseType::NIGHTLY->value,
'releaseEnvironment' => ucfirst($faqConfig->get('upgrade.releaseEnvironment')),
'dateLastChecked' => $faqConfig->get('upgrade.dateLastChecked')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public function createTemporaryBackup(): StreamedResponse
});
}

#[Route('admin/api/extract-package')]
#[Route('admin/api/install-package')]
public function installPackage(): StreamedResponse
{
$configuration = Configuration::getConfigurationInstance();
Expand Down
8 changes: 7 additions & 1 deletion phpmyfaq/translations/language_de.php
Original file line number Diff line number Diff line change
Expand Up @@ -1332,8 +1332,14 @@
$PMF_LANG['msgBookmarkRemoved'] = 'Lesezeichen erfolgreich entfernt!';

// added v4.0.0-alpha - 2023-07-11 by Jan
$PMF_LANG['headerCheckHealth'] = '1. Systemzustand prüfen';
$PMF_LANG['headerCheckUpdates'] = '2. Suche nach Updates';
$PMF_LANG['msgHealthCheck'] = 'Dies überprüft die korrekten Dateiberechtigungen und die Ordnerstruktur Ihrer phpMyFAQ-Installation.';
$PMF_LANG['msgUpdateCheck'] = 'Sie können nach neuen Versionen von phpMyFAQ suchen, neu installieren oder Ihre Installation aktualisieren.';
$PMF_LANG['buttonCheckHealth'] = 'Systemzustand jetzt prüfen';
$PMF_LANG['buttonCheckUpdates'] = 'Suche jetzt nach Updates';
$PMF_LANG['versionIsUpToDate'] = '✅ Deine installierte Version ist aktuell.';
$PMF_LANG['healthCheckOkay'] = '✅ Deine installierte Version ist gesund.';
$PMF_LANG['healthCheckOkay'] = '✅ Deine installierte Version ist in Ordnung.';
$PMF_LANG['downloadSuccessful'] = '✅ Download-Paket erfolgreich heruntergeladen!';
$PMF_LANG['downloadFailure'] = '❌ Download-Paket konnte nicht heruntergeladen werden';
$PMF_LANG['verificationFailure'] = '❌ Download-Paket konnte nicht verifiziert werden';
Expand Down
6 changes: 6 additions & 0 deletions phpmyfaq/translations/language_en.php
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,12 @@
$PMF_LANG['msgBookmarkRemoved'] = 'Bookmark successfully removed!';

// added v4.0.0-alpha - 2023-07-11 by Jan
$PMF_LANG['headerCheckHealth'] = '1. Check for System Health';
$PMF_LANG['headerCheckUpdates'] = '2. Check for Updates';
$PMF_LANG['msgHealthCheck'] = 'This checks the correct file permissions and folder structure of your phpMyFAQ installation.';
$PMF_LANG['msgUpdateCheck'] = 'You can check for new versions of phpMyFAQ, re-install or update your installation.';
$PMF_LANG['buttonCheckHealth'] = 'Check System health now';
$PMF_LANG['buttonCheckUpdates'] = 'Check for Updates now';
$PMF_LANG['versionIsUpToDate'] = '✅ Your installed version is up-to-date!';
$PMF_LANG['healthCheckOkay'] = '✅ Your installed version is healthy!';
$PMF_LANG['downloadSuccessful'] = '✅ Package successfully downloaded!';
Expand Down

0 comments on commit a91b9ce

Please sign in to comment.