diff --git a/Classes/Event/Listener/UsageToolBarEventListener.php b/Classes/Event/Listener/UsageToolBarEventListener.php
index 74c0104d..0fda7c7f 100644
--- a/Classes/Event/Listener/UsageToolBarEventListener.php
+++ b/Classes/Event/Listener/UsageToolBarEventListener.php
@@ -7,6 +7,7 @@
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent;
+use TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus;
use TYPO3\CMS\Core\Localization\LanguageService;
use WebVision\WvDeepltranslate\Exception\ApiKeyNotSetException;
use WebVision\WvDeepltranslate\Service\UsageService;
@@ -40,14 +41,19 @@ public function __invoke(SystemInformationToolbarCollectorEvent $systemInformati
}
return;
}
+
+ $title = $this->getLanguageService()->sL(
+ 'LLL:EXT:wv_deepltranslate/Resources/Private/Language/locallang.xlf:usages.toolbar-label'
+ );
+ $message = $this->getLanguageService()->sL(
+ 'LLL:EXT:wv_deepltranslate/Resources/Private/Language/locallang.xlf:usages.toolbar.message'
+ );
+
$systemInformation->getToolbarItem()->addSystemInformation(
- $this->getLanguageService()->sL('LLL:EXT:wv_deepltranslate/Resources/Private/Language/locallang.xlf:usages.toolbar-label'),
- sprintf(
- '%d / %d',
- $usage->character->count,
- $usage->character->limit
- ),
+ $title,
+ sprintf($message, $this->formatNumber($usage->character->count), $this->formatNumber($usage->character->limit)),
'actions-localize-deepl',
+ InformationStatus::STATUS_NOTICE,
);
}
@@ -55,4 +61,15 @@ private function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
+
+ /**
+ * Make large API limits easier to read
+ *
+ * @param int $number Any large integer - 5000000
+ * @return string Formated, better readable string variant of the integer - 5.000.000
+ */
+ private function formatNumber(int $number): string
+ {
+ return number_format($number, 0, ',', '.');
+ }
}
diff --git a/Classes/Hooks/UsageProcessAfterFinishHook.php b/Classes/Hooks/UsageProcessAfterFinishHook.php
index 8464acd4..c6071a7c 100644
--- a/Classes/Hooks/UsageProcessAfterFinishHook.php
+++ b/Classes/Hooks/UsageProcessAfterFinishHook.php
@@ -39,22 +39,25 @@ public function processCmdmap_afterFinish(DataHandler $dataHandler): void
return;
}
- $label = $this->getLanguageService()->sL(
+ $title = $this->getLanguageService()->sL(
+ 'LLL:EXT:wv_deepltranslate/Resources/Private/Language/locallang.xlf:usages.flashmassage.title'
+ );
+ $message = $this->getLanguageService()->sL(
'LLL:EXT:wv_deepltranslate/Resources/Private/Language/locallang.xlf:usages.flashmassage.limit.description'
);
$flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
$notificationQueue = $flashMessageService->getMessageQueueByIdentifier();
- $severity = -1; // Info
+ $severity = FlashMessage::INFO;
if ($this->usageService->isTranslateLimitExceeded()) {
- $severity = 1; // Warning
+ $severity = FlashMessage::WARNING;
}
$flashMessage = GeneralUtility::makeInstance(
FlashMessage::class,
- sprintf($label, $usage->character->count, $usage->character->limit),
- 'Deepl Usage',
+ sprintf($message, $this->formatNumber($usage->character->count), $this->formatNumber($usage->character->limit)),
+ $title,
$severity,
true
);
@@ -66,4 +69,9 @@ private function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
+
+ private function formatNumber(int $number): string
+ {
+ return number_format($number, 0, ',', '.');
+ }
}
diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf
index 476ba437..929e8dbb 100644
--- a/Resources/Private/Language/de.locallang.xlf
+++ b/Resources/Private/Language/de.locallang.xlf
@@ -199,13 +199,25 @@
- DeepL Translate Limit
+ DeepL Translate Quota
DeepL Übersetzung Limit
+
+ %s / %s
+ %s / %s
+
Information not available
Information nicht verfügbar
+
+ DeepL usage and quota
+ DeepL Nutzung und Limits
+
+
+ DeepL translations for current billing period: %s of %s characters
+ DeepL Übersetzungen für den aktuellen Abrechnungszeitraum: %s von %s Zeichen
+
diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf
index 4ccdeb68..a485b81a 100644
--- a/Resources/Private/Language/locallang.xlf
+++ b/Resources/Private/Language/locallang.xlf
@@ -174,16 +174,19 @@
- DeepL Translate Limit
+ DeepL Translate Quota
+
+
+ %s / %s
Information not available
- DeepL Translate
+ DeepL usage and quota
- DeepL Translate Limit %s / %s
+ DeepL translations for current billing period: %s of %s characters
diff --git a/Resources/Public/Icons/actions-localize-deepl.svg b/Resources/Public/Icons/actions-localize-deepl.svg
index 92dd89f6..269c69c1 100644
--- a/Resources/Public/Icons/actions-localize-deepl.svg
+++ b/Resources/Public/Icons/actions-localize-deepl.svg
@@ -1,18 +1,9 @@
-
-