jackmaessen LiteCart Fan Nuo Netherlands Narys nuo gruod. 2022 jackmaessen 27 gruod. 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.nl I was expecting that the translations looked like: A link is sent to %s How can i achieve this?
dream_09 LiteCart Fan Nuo Czech Republic Narys nuo gruod. 2023 dream_09 27 gruod. 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 Nuo Netherlands Narys nuo gruod. 2022 jackmaessen 27 gruod. 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 Nuo Sweden Narys nuo geg. 2013 tim 28 gruod. 2023 03:55 I like the use of strtr(). And even for inserting HTML. https://www.php.net/manual/en/function.strtr.php echo strtr(language::translate('text_hello_user', 'Hello %user'), [ '%user' => 'John', ]);