Skip to content

Commit

Permalink
Merge pull request #10 from ubilabs/translations_backend_#9
Browse files Browse the repository at this point in the history
Make backend translatable #9
  • Loading branch information
TheAmazingPT authored Oct 17, 2023
2 parents 91ba93b + 01576ce commit e4f2322
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 36 deletions.
70 changes: 67 additions & 3 deletions drupal/modules/custom/dipas/files/translations/dipas.de.po
Original file line number Diff line number Diff line change
Expand Up @@ -535,15 +535,65 @@ msgstr "Einstellungen für die Verschlagwortung"
msgid "Settings for the keyword service."
msgstr "Einstellungen für die Verschlagwortung."

#: src/Plugin/SettingsSection/MenuSettings.php:102
#: src/Plugin/SettingsSection/MenuSettings.php:68
msgctxt "DIPAS"
msgid "Contribution list"
msgstr "Beitragsliste"

#: src/Plugin/SettingsSection/MenuSettings.php:78
msgctxt "DIPAS"
msgid "About the proceeding"
msgstr "Über das Verfahren"

#: src/Plugin/SettingsSection/MenuSettings.php:84
msgctxt "DIPAS"
msgid "Appointments"
msgstr "Termine"

#: src/Plugin/SettingsSection/MenuSettings.php:90
msgctxt "DIPAS"
msgid "Analysis"
msgstr "Auswertungen"

#: src/Plugin/SettingsSection/MenuSettings.php:95
msgctxt "DIPAS"
msgid "Poll"
msgstr "Umfrage"

#: src/Plugin/SettingsSection/MenuSettings.php:101
msgctxt "DIPAS"
msgid "my page"
msgstr "eigene Seite"

#: src/Plugin/SettingsSection/MenuSettings.php:107
msgctxt "DIPAS"
msgid "Compare concepts"
msgstr "Entwürfe vergleichen"

#: src/Plugin/SettingsSection/MenuSettings.php:115
msgctxt "DIPAS"
msgid "Privacy"
msgstr "Datenschutz"

#: src/Plugin/SettingsSection/MenuSettings.php:121
msgctxt "DIPAS"
msgid "FAQ"
msgstr "FAQ"

#: src/Plugin/SettingsSection/MenuSettings.php:126
msgctxt "DIPAS"
msgid "Contact"
msgstr "Kontakt"

#: src/Plugin/SettingsSection/MenuSettings.php:250
msgid "Please choose"
msgstr "Bitte wählen"

#: src/Plugin/SettingsSection/MenuSettings.php:118
#: src/Plugin/SettingsSection/MenuSettings.php:142
msgid "Main menu settings"
msgstr "Hauptmenü Einstellungen"

#: src/Plugin/SettingsSection/MenuSettings.php:122
#: src/Plugin/SettingsSection/MenuSettings.php:146
msgid "Footer menu settings"
msgstr "Footer Menü Einstellungen"

Expand Down Expand Up @@ -1035,6 +1085,11 @@ msgctxt "DIPAS"
msgid "Select the media item that contains the project image. If you need to create one first, click @here."
msgstr "Wählen Sie das Medienelement, dass das Projektbild enthält. Wenn Sie zuerst eines erzeugen müssen, klicken Sie @here."

#: src/Plugin/SettingsSection/ProjectInformation.php:321
msgctxt "DIPAS"
msgid "No partner logos defined. Click the \"Add logo\" button to add a new logo."
msgstr "Keine Partner Logos definiert. Klicken Sie den \"Logo hinzufügen\" Button, um ein neues Logo hinzuzufügen."

#: src/Plugin/SettingsSection/ProjectInformation.php:301
msgctxt "DIPAS"
msgid "Partner logo"
Expand Down Expand Up @@ -1196,6 +1251,11 @@ msgctxt "DIPAS"
msgid "Check the blocks you want to show on the website. Sort by drag and drop."
msgstr "Aktivieren Sie die Blöcke, die Sie in der Seitenspalte anzeigen wollen. Sortieren Sie sie mit Drag'n'drop."

#: src/Plugin/SettingsSection/SidebarSettings.php:97
msgctxt "DIPAS"
msgid "No available block plugins."
msgstr "Keine verfügbaren Blöcke."

#: src/Plugin/SettingsSection/SidebarSettings.php:14
msgid "Sidebar settings"
msgstr "Seitenleisten-Einstellungen"
Expand Down Expand Up @@ -1244,3 +1304,7 @@ msgstr "Stellt das Projektlogo in einem Block dar"
#: src/Service/EntityServices.php:230
msgid "Default"
msgstr "Standard"

#: src/Service/DipasNlpServices.php:419
msgid "Finished"
msgstr "Abgeschlossen"
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Drupal\Component\DependencyInjection\Container;
use Drupal\Core\Form\FormStateInterface;
use Drupal\node\NodeInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
* Class MenuSettings.
Expand Down Expand Up @@ -64,65 +65,65 @@ public static function getDefaults() {
'mainmenu' => [
'contributionmap' => [
'enabled' => 1,
'name' => 'Beitragskarte',
'name' => new TranslatableMarkup('Contribution map', [], ['context' => 'DIPAS']),
'icon' => 'room',
],
'contributionlist' => [
'enabled' => 1,
'name' => 'Beitragsliste',
'name' => new TranslatableMarkup('Contribution list', [], ['context' => 'DIPAS']),
'icon' => 'sms',
],
'projectinfo' => [
'enabled' => 1,
'name' => 'Über das Verfahren',
'name' => new TranslatableMarkup('About the proceeding', [], ['context' => 'DIPAS']),
'icon' => 'info',
'node' => '',
],
'schedule' => [
'enabled' => 1,
'name' => 'Termine',
'name' => new TranslatableMarkup('Appointments', [], ['context' => 'DIPAS']),
'icon' => 'event',
'mapinstance' => 'default',
],
'statistics' => [
'enabled' => 1,
'name' => 'Auswertungen',
'name' => new TranslatableMarkup('Analysis', [], ['context' => 'DIPAS']),
'icon' => 'timeline',
],
'survey' => [
'enabled' => 1,
'name' => 'Umfrage',
'name' => new TranslatableMarkup('Poll', [], ['context' => 'DIPAS']),
'icon' => 'phone',
'url' => '',
],
'custompage' => [
'enabled' => 0,
'name' => 'eigene Seite',
'name' => new TranslatableMarkup('my page', [], ['context' => 'DIPAS']),
'icon' => 'keyboard',
'node' => '',
],
'conceptionlist' => [
'enabled' => 0,
'name' => 'Entwürfe vergleichen',
'name' => new TranslatableMarkup('Compare concepts', [], ['context' => 'DIPAS']),
'icon' => 'compare_arrows',
'overwriteFrontpage' => 0,
],
],
'footermenu' => [
'dataprivacy' => [
'enabled' => 1,
'name' => 'Datenschutz',
'name' => new TranslatableMarkup('Privacy', [], ['context' => 'DIPAS']),
'node' => '',
],
'imprint' => ['enabled' => 1, 'name' => 'Impressum', 'node' => ''],
'faq' => [
'enabled' => 1,
'name' => 'FAQ',
'name' => new TranslatableMarkup('FAQ', [], ['context' => 'DIPAS']),
'node' => '',
],
'contact' => [
'enabled' => 1,
'name' => 'Kontakt',
'name' => new TranslatableMarkup('Contact', [], ['context' => 'DIPAS']),
'node' => '',
],
],
Expand Down Expand Up @@ -184,7 +185,7 @@ public function getForm(array $form, FormStateInterface $form_state) {
],
'menuitem' => [
'#type' => 'markup',
'#markup' => $this->t('Endpoint: %endpoint', ['%endpoint' => $endpoint], ['context' => 'DIPAS']),
'#markup' => $this->t('Endpoint: %endpoint', ['%endpoint' => $defaults[$menu][$endpoint]['name']], ['context' => 'DIPAS']),
'#prefix' => '<div class="endpointname">',
'#suffix' => '</div>',
'#weight' => 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public function getForm(array $form, FormStateInterface $form_state) {
'partner_logos',
$form_state,
$this->partner_logos ?: [],
'No partner logos defined. Click the "Add logo" button to add a new logo.'
$this->t('No partner logos defined. Click the "Add logo" button to add a new logo.')->__toString()
);

foreach ($topics as $tid => $value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function (&$plugin) {
'blocks',
$form_state,
$availableBlockPlugins,
'No available block plugins.'
$this->t('No available block plugins.')
);

return $form;
Expand Down
11 changes: 6 additions & 5 deletions drupal/modules/custom/dipas/src/Service/DipasNlpServices.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RequestStack;
use Drupal\dipas\Plugin\ResponseKey\RetrieveCommentsTrait;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
* Class DipasNlpServices.
Expand Down Expand Up @@ -165,7 +166,7 @@ public function executeNlpScoresProcessing(array $contribution_nodes) {
if (
$this->dipasConfig->get('NLPSettings.enabled') === TRUE &&
$this->dipasConfig->get('NLPSettings.enable_score_service') === TRUE &&
$this->state->get(sprintf('dipas.nlp.score.status%s', $this->domainSuffix)) !== 'Processing'
$this->state->get(sprintf('dipas.nlp.score.status%s', $this->domainSuffix)) !== new TranslatableMarkup('Processing')
) {
return $this->executeNlp(
$contribution_nodes,
Expand Down Expand Up @@ -248,7 +249,7 @@ public function executeNlpClusteringProcessing(array $contribution_nodes, $filte
if (
$this->dipasConfig->get('NLPSettings.enabled') === TRUE &&
$this->dipasConfig->get('NLPSettings.enable_clustering') === TRUE &&
$this->state->get(sprintf('dipas.nlp.clustering.status%s', $this->domainSuffix)) !== 'Processing'
$this->state->get(sprintf('dipas.nlp.clustering.status%s', $this->domainSuffix)) !== new TranslatableMarkup('Processing')
) {
return $this->executeNlp(
$contribution_nodes,
Expand Down Expand Up @@ -324,7 +325,7 @@ public function executeNlpWordcloudProcessing(array $contribution_nodes, $filter
if (
$this->dipasConfig->get('NLPSettings.enabled') === TRUE &&
$this->dipasConfig->get('NLPSettings.enable_wordcloud') === TRUE &&
$this->state->get(sprintf('dipas.nlp.wordcloud.status%s', $this->domainSuffix)) !== 'Processing'
$this->state->get(sprintf('dipas.nlp.wordcloud.status%s', $this->domainSuffix)) !== new TranslatableMarkup('Processing')
) {
return $this->executeNlp(
$contribution_nodes,
Expand Down Expand Up @@ -394,7 +395,7 @@ protected function executeNlp(
) {
$response = [];

$this->state->set($status_key, 'Processing');
$this->state->set($status_key, new TranslatableMarkup('Processing'));

try {
if ($contribution_nodes && !empty($contribution_nodes)) {
Expand All @@ -416,7 +417,7 @@ protected function executeNlp(
$response = ($result = json_decode($nlp_score->getBody()->__toString())) ? $result : [];

$timestamp = time();
$this->state->set($status_key, 'Finished');
$this->state->set($status_key, new TranslatableMarkup('Finished'));
$this->state->set(sprintf('dipas.nlp.%s.last_run_time%s', $service_name, $this->domainSuffix), $timestamp);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#: src/Form/Settings.php:80
msgctxt "DIPAS_STATISTICS"
msgid "Export complete tracking data: "
msgstr "Komplette Trackingdaten exportieren: "

#: src/Form/Settings.php:100
msgctxt "DIPAS_STATISTICS"
msgid "Export tracking data"
msgstr "Trackingdaten exportieren"

#: src/Form/Settings.php:115
msgctxt "DIPAS_STATISTICS"
msgid "Select the endpoints to track"
msgstr "Tracking Endpunkte wählen"
42 changes: 28 additions & 14 deletions drupal/modules/custom/dipas_statistics/src/Form/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\Core\Link;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
Expand Down Expand Up @@ -77,36 +78,49 @@ public function buildForm(array $form, FormStateInterface $form_state) {

$form['#tree'] = TRUE;

$markup = $this->t('Export complete tracking data: ', [], ['context' => 'DIPAS_STATISTICS']);
$markup .= $this->t('(@Export tracking data)',
[
'@Export tracking data' => Link::fromTextAndUrl(
'Export tracking data',
Url::fromRoute('dipas_statistics.export', [])
)->toString(),
],
['context' => 'DIPAS_STATISTICS']
);

$form['preface'] = [
'#type' => 'markup',
'#markup' => sprintf(
'Export complete tracking data: <a href="%s" target="_blank">(Export tracking data)</a>',
Url::fromRoute('dipas_statistics.export', [])->toString()
),
'#markup' => $markup,
'#prefix' => '<p>',
'#suffix' => '</p>',
];

foreach ($this->pluginManager as $section => $pluginManager) {
$plugins = $pluginManager->getDefinitions();

$description = $this->t('(@Export tracking data)',
[
'@Export tracking data' => Link::fromTextAndUrl(
'Export tracking data',
Url::fromRoute(
'dipas_statistics.export',
[ 'api' => $section ]
)
)->toString(),
],
['context' => 'DIPAS_STATISTICS']
);

$form[$section] = [
'#type' => 'details',
'#title' => $section,
'#description' => sprintf(
'<a href="%s" target="_blank">(Export tracking data)</a>',
Url::fromRoute(
'dipas_statistics.export',
[
'api' => $section,
]
)->toString()
),
'#description' => $description
];

$form[$section]['endpoints'] = [
'#type' => 'checkboxes',
'#title' => 'Select the endpoints to track',
'#title' => $this->t('Select the endpoints to track', [], ['context' => 'DIPAS_STATISTICS']),
'#options' => array_combine(
array_keys($plugins),
array_map(
Expand Down

0 comments on commit e4f2322

Please sign in to comment.