Translate sign up form

Hey @MarsTech,

You need to add the hr ID, it’s the block id.

When you press on the block on the right corner you will see it. In my case it is user-accounts5, simply go to your block settings to find our yours :slight_smile:

image

Hi Suzie,

I made the following changes, but its still not working. Am I missing something?

Can I please ask you to contact via chat, perhaps we will need to check some more details :slight_smile:

Hey @MarsTech, @Suzie could you share how you solved this? if you did. Not working for me. Tried adding the Block id both with quotes and without. No luck.

  • My block
    Captura de pantalla 2023-08-02 a las 10.55.00

  • My code

<script>
    window.addEventListener('block-loaded-{alta-usuario}', () => {
       var label = document.querySelector("label[for='terms_and_privacy']");
       var paragraph = label.querySelector('p');
       var childElements = paragraph.children;
       
       var paragraph1 = childElements[0];
       var paragraph2 = childElements[1];
       
       paragraph1.firstChild.textContent = 'Acepto';
       var linkElement1 = paragraph1.querySelector('a');
       linkElement1.textContent = 'Condiciones';
       
       paragraph2.firstChild.textContent = 'y';
       var linkElement2 = paragraph2.querySelector('a');
       linkElement2.textContent = 'Política de privacidad';
    });
</script>

Thanks

Hi,

You just need to remove { and } for alta-usuario in window.addEventListener('block-loaded-{alta-usuario}', () => {

<script>
    window.addEventListener('block-loaded-alta-usuario', () => {
       var label = document.querySelector("label[for='terms_and_privacy']");
       var paragraph = label.querySelector('p');
       var childElements = paragraph.children;
       
       var paragraph1 = childElements[0];
       var paragraph2 = childElements[1];
       
       paragraph1.firstChild.textContent = 'Acepto';
       var linkElement1 = paragraph1.querySelector('a');
       linkElement1.textContent = 'Condiciones';
       
       paragraph2.firstChild.textContent = 'y';
       var linkElement2 = paragraph2.querySelector('a');
       linkElement2.textContent = 'Política de privacidad';
    });
</script>
3 Likes

Classic one that would take me a life time to spot, thanks heaps

Hey @matthieu_chateau

Any chance to have the same magic script for the login block ?
Thanks :pray:

Hey @yannick, can you try this code? Just replace the BLOCKID with the block name

<script>
window.addEventListener('block-loaded-BLOCKID', () => {
	document.querySelectorAll('#BLOCKID .form-input-label')[0].innerText = 'TRANSLATION FOR EMAIL';
	document.querySelectorAll('#BLOCKID .form-input-label')[1].innerText = 'TRANSLATION FOR PASSWORD';
});
</script>

It works very well thank you :slight_smile:

All that’s missing is being able to translate the error message :slight_smile:

Yes, @yannick, it’s included in our feature requests and soon it will be possible to translate them via custom code :star_struck:

1 Like

Unfortunately, this solution no longer works and creates errors in the console -_-

Hi Yannick,

Add a 100ms delay just to be sure the block is fully loaded.
Inside the header custom code of the page. From now on, almost all Javascript should be in the header, as the blocks are loaded faster than before.

<script>
window.addEventListener('block-loaded-BLOCKID', () => {
    setTimeout(() => {
        document.querySelectorAll('#BLOCKID .form-input-label')[0].innerText = 'Courrier';
        document.querySelectorAll('#BLOCKID .form-input-label')[1].innerText = 'Mot de passe';
    }, 100);
});
</script>
1 Like

Haha. Well, it works like a charm, thanks !

I imagined that the block-loaded... would be there to avoid that.

Good news for loading speed :racing_car::dash: