Navigation überspringen

Dies ist das technische Support-Forum für WPML – das mehrsprachige WordPress-Plugin.

Mitlesen können alle, doch nur WPML-Kunden können hier Fragen veröffentlichen. Das WPML-Team antwortet im Forum an 6 Tagen pro Woche, 22 Stunden am Tag.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 13:00 9:00 – 13:00 9:00 – 13:00 8:00 – 12:00 8:00 – 12:00 -
- 14:00 – 17:00 14:00 – 18:00 14:00 – 18:00 13:00 – 17:00 13:00 – 17:00 -

Unterstützt die Zeitzone: Europe/Zagreb (GMT+02:00)

Dieses Thema enthält 5 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Bruno Kos Vor 5 Monaten, 3 Wochen.

Assistiert von: Bruno Kos.

Verfasser Beiträge
Oktober 15, 2024 at 10:08 am #16289848

stefanE-2

Hintergrund des Themas:
I am trying to translate text in ACF (Advanced Custom Fields) blocks, but the text is not being translated when a shortcode is used in the same field. You can see the issue on this page: versteckter Link section "Table reservation (possible from 2 persons)"

Die Symptome:
The text, both normal and button text from the shortcode, is not being translated.

Fragen:
Why is the text in ACF blocks not being translated when using a shortcode?
How can I ensure that both normal text and button text from shortcodes are translated?

Oktober 15, 2024 at 2:00 pm #16291227

Bruno Kos
Unterstützer

Sprachen: Englisch (English ) Deutsch (Deutsch ) Französisch (Français )

Zeitzone: Europe/Zagreb (GMT+02:00)

Hi,

Thank you for contacting WPML support!

versteckter Link

Can you import your field group into this sandbox, add this field and its content to a page, does it show in ATE?

I already installed ACF there.

Regards,
Bruno Kos

Oktober 15, 2024 at 2:23 pm #16291373

stefanE-2

i created the field group and i'll put content in it but
We use ACF Pro and we got a custom block.

<?php

/**
* voncontent Block Template.
*
* @param array $block The block settings and attributes.
* @param string $content The block inner HTML (empty).
* @param bool $is_preview True during AJAX preview.
* @param (int|string) $post_id The post ID this block is saved to.
*/

$group = get_field('content');
$content_title = $group['content_title'];
$title_tag = $group['title_tag'];
$style = $group['style'];
$column_one = $group['column_one'];
$column_two = $group['column_two'];
$target = "";

if (isset($group['tabelle_'.get_locale()])){
$table = $group['tabelle_'.get_locale()];
} else {
$table = "";
}

$buttontext = $group['button_text'];
if ($group['button_url'] != ""){
$buttonurl = get_permalink($group['button_url']);
} elseif (isset($group['button_extern_url_'.get_locale()])){
$buttonurl = $group['button_extern_url_'.get_locale()];
$target = 'target="_BLANK"';
}

if ($style == 'Text 2-Columns') {

?>

<section class="full_grid text-light">
<div class="container-full">
<div class="max_90_d">
<div class="row">
<?php if ($content_title) { ?>
<<?= $title_tag ?> class="mb-4 heading"><?= $content_title ?></<?= $title_tag ?>>
<?php } ?>
<div class="col-md-6 pr-md-25">
<?= wpautop($column_one) ?>
<?php
if ($table != "") {
echo do_shortcode('[table id="' . $table . '" responsive="stack" responsive_breakpoint="tablet" /]');
}
?>
</div>
<div class="col-md-6 pl-md-25"><?= wpautop($column_two) ?></div>
<?php if ($buttontext) { ?>
<div class="mt-4">
" class="btn btn-success btn-rounded">
</div>
<?php } ?>
</div>
</div>
</div>
</section>

<?php
} else {
?>

<section class="full_grid text-light">
<div class="container-full">
<div class="max_90_d">
<div class="row">
<?php if ($content_title) { ?>
<<?= $title_tag ?> class="mb-4 heading"><?= $content_title ?></<?= $title_tag ?>>
<?php } ?>
<div class="col-md-8">
<?= wpautop($column_one) ?>
<?php
if ($table != "") {
echo do_shortcode('[table id="' . $table . '" responsive="stack" responsive_breakpoint="tablet" /]');
}
?>
</div>
<?php if ($buttontext) { ?>
<div class="mt-4">
" class="btn btn-success btn-rounded">
</div>
<?php } ?>
</div>
</div>
</div>
</section>

<?php } ?>

Bildschirmfoto 2024-10-15 um 16.19.37.png
Oktober 16, 2024 at 6:24 am #16293245

Bruno Kos
Unterstützer

Sprachen: Englisch (English ) Deutsch (Deutsch ) Französisch (Français )

Zeitzone: Europe/Zagreb (GMT+02:00)

Can you add such content on versteckter Link, try translating it and show me what does not show in translation editor?

Oktober 21, 2024 at 6:13 am #16310275

stefanE-2

To be able to test this, I need the custom block. I have sent you the code for this. I see that it is not yet implemented in the editor

Oktober 21, 2024 at 8:57 am #16311039

Bruno Kos
Unterstützer

Sprachen: Englisch (English ) Deutsch (Deutsch ) Französisch (Français )

Zeitzone: Europe/Zagreb (GMT+02:00)

There is a File Manager available on versteckter Link

We could go through:

// Add this to your theme's `functions.php` file or a custom plugin.

function register_acf_block_types() {
    // Check if function exists.
    if( function_exists('acf_register_block_type') ) {
        
        // Register a custom block.
        acf_register_block_type(array(
            'name'              => 'voncontent',
            'title'             => __('Voncontent Block'),
            'description'       => __('A custom block for displaying content.'),
            'render_template'   => 'template-parts/blocks/voncontent/voncontent.php', // Adjust the path as necessary
            'category'          => 'formatting',
            'icon'              => 'admin-comments',
            'keywords'          => array( 'voncontent', 'content', 'custom' ),
            'supports'          => array(
                'align' => true,
                'mode' => false,
            ),
        ));
    }
}
add_action('acf/init', 'register_acf_block_types');

And add voncontent.php, inside a folder such as template-parts/blocks/voncontent/ within the theme.

However our sandboxes don't have FTP access, only File Manager plugin (so if we make syntax error it would take the site down) so if you think it would be simpler for to you to upload your theme by all means.

Let me know!

The topic ‘[Geschlossen] Text in ACF (Advanced Custom Fields) blocks is not being translated when Shortcode is being used in …’ is closed to new replies.