Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UHF-8835 Accordion translations #698

Merged
merged 4 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions modules/hdbt_admin_tools/hdbt_admin_tools.module
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use Drupal\hdbt_admin_tools\Plugin\Field\FieldType\SelectIcon;
use Drupal\helfi_api_base\Link\UrlHelper;
use Drupal\helfi_tpr\Entity\Service;
use Drupal\node\NodeInterface;
use Drupal\paragraphs\Entity\ParagraphsType;
use Drupal\user\UserInterface;

/**
Expand Down Expand Up @@ -894,6 +895,40 @@ function hdbt_admin_tools_preprocess_links__dropbutton__operations__paragraphs(&
}
}

/**
* Implements hook_preprocess_HOOK().
*/
function hdbt_admin_tools_preprocess_input__submit__paragraph_action(array &$variables): void {

// According to UX team it's better to show the "Add @type" buttons without
// the Add word. Fix the texts from these buttons.
$paragraph_add_more_buttons = [
'accordion_item_add_more',
];

foreach ($paragraph_add_more_buttons as $button) {
if (
!isset($variables['element']['#name']) ||
!str_contains($variables['element']['#name'], $button)
) {
return;
}

// Get the label from the paragraph type and change the button label to
// match the label of the paragraph type.
$paragraph_storage = \Drupal::entityTypeManager()->getStorage('paragraphs_type');
$paragraph_type = $paragraph_storage->load($variables['element']['#bundle_machine_name']);

if (!$paragraph_type instanceof ParagraphsType) {
return;
}

$variables['attributes']['value'] = t('@type', [
'@type' => $paragraph_type->get('label'),
]);
}
}

/**
* Implements hook_form_alter().
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ id: paragraph.accordion.field_accordion_heading_level
field_name: field_accordion_heading_level
entity_type: paragraph
bundle: accordion
label: 'Items heading level'
description: 'Select the heading level of the accordion so that they are semantically correct with the rest of the content.'
label: 'Accordion item title level'
description: "If the accordion has a title, the level for accordion item titles should be one level lower. If the accordion doesn't have a title, the level of the accordion title will be used for accordion item titles."
required: true
translatable: false
default_value:
-
value: '2'
value: '3'
default_value_callback: ''
settings: { }
field_type: list_string
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ id: paragraph.accordion.field_accordion_title
field_name: field_accordion_title
entity_type: paragraph
bundle: accordion
label: Title
label: 'Accordion title'
description: ''
required: false
translatable: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ field_name: field_accordion_title_level
entity_type: paragraph
bundle: accordion
label: 'Accordion title level'
description: 'Select the title level of the accordion so that they are semantically correct with the rest of the content.'
description: 'Choose the appropriate level for the accordion title in the page title hierarchy. Typically, the accordion title level is H2.'
required: true
translatable: false
default_value:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
label: 'Sisällön pääotsikoiden taso'
description: 'Valitse sisällön pääotsikoiden taso siten että ne ovat semanttisesti oikealla tasolla muun sisällön suhteen.'
label: 'Haitarikohtien otsikkojen taso'
description: 'Jos haitarilla on otsikko, pitää haitarikohtien otsikkojen tason olla yhtä tasoa alempana. Jos haitarilla ei ole otsikkoa, käyttää Drupal haitarikohtien otsikkotasona haitarin otsikon tasoa.'
Original file line number Diff line number Diff line change
@@ -1 +1 @@
label: Otsikko
label: 'Haitarin otsikko'
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
label: 'Haitarin otsikon taso'
description: 'Valitse haitarin otsikon taso niin, että se on semanttisesti oikein muun sisällön kanssa.'
description: 'Valitse haitarin otsikolle sivun otsikkohierarkiaan sopiva taso. Yleensä haitarin otsikon taso on H2.'
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
label: 'Haitarin sisältökohta'
label: Haitarikohta
description: 'Yksittäinen haitarin sisältökohta, jossa on otsikko ja sisältö.'
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
declare(strict_types=1);

/**
* UHF-8135 Update accordion paragraph translations.
* UHF-8835 Update accordion paragraph translations.
*/
function helfi_paragraphs_accordion_update_9001(): void {
function helfi_paragraphs_accordion_update_9002(): void {
\Drupal::service('helfi_platform_config.config_update_helper')
->update('helfi_paragraphs_accordion');
}
Loading