Forums

Multilingual syntax with variables in messages

amax 13 Jan, 2025

Hi everyone, I'm using Chronoform's multilingual system, but I'm having an issue with the syntax when trying to include variable data within a string to be translated. For example, I want to write something like

'hello {data:name} thanks for writing...',

and I tried writing it as

{l:hello {data:name} thanks for writing...},

but it's not working. Can someone tell me what the correct syntax is for this case?

Thank you in advance for your help and support!

amax 13 Jan, 2025

I also tried using a %s placeholder with the syntax

{l:hello %s thanks for writing...|{data:name}},

but it's not working. The output only shows a single closing curly brace '}'.

simelas 14 Jan, 2025

{l:hello} {data:name} {l:thanks_for_writing}...,

amax 15 Jan, 2025

Thank you, but I was hoping to find a more dynamic solution rather than having to create a series of translations.

Max_admin 15 Jan, 2025
Answer

I think for long strings with variables inside you better do it with output buffering:

The event switcher will check the active language and display a different message with different translated content, and the output buffer will capture the whole output of the message and return it inside a variable: {var:translated_message}

BUT, you need to wait for the next update to be able to use the new shortcode {str:locale} OR you can get it now in PHP as $this->locale, you can return it as a variable and use {var:php_action_name} for the switcher

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
amax 17 Jan, 2025

ok thanks, I look forward to the next update

Max_admin 26 Jan, 2025
1 Likes

new update is out!

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
You need to login to be able to post a reply.