jackmaessen LiteCart Fan Da Netherlands Membro dal dic 2022 jackmaessen 27 dic 2023 19:35 I am struggling with translating a text in which a variable is inside. I am using sprint_f() for it: $email = testemail@live.nl;notices::add('success', language::translate('email_confirmation', sprintf('A link is sent to %s',$email)));This is how it is stored in translations:email_confirmation -> A link is sent to testemail@live.nlI was expecting that the translations looked like:A link is sent to %sHow can i achieve this?
dream_09 LiteCart Fan Da Czech Republic Membro dal dic 2023 dream_09 27 dic 2023 22:38 Hello,you can try this:$email = 'testemail@live.nl';notices::add('success', sprintf(language::translate('email_confirmation', 'A link is sent to %s'),$email));
jackmaessen LiteCart Fan Da Netherlands Membro dal dic 2022 jackmaessen 27 dic 2023 23:23 Found the correct one that works:$email = $_POST['email'];notices::add('success', sprintf(language::translate('email_confirmation_sent1', 'A link is sent to %s'),$email));The translation function should be inside the sprint_f() function!
tim Founder Da Sweden Membro dal mag 2013 tim 28 dic 2023 03:55 I like the use of strtr(). And even for inserting HTML.https://www.php.net/manual/en/function.strtr.phpecho strtr(language::translate('text_hello_user', 'Hello %user'), [ '%user' => '<span class="name">John</span>',]);