0

I know I can translate in Laravel using the __ helper function, eg - in my blade template:

{{ __("Hello") }}

But what happens when I want to mix in variables to that? For example, imagine in my controller I am using MySQL to return a concat string as a variable which I want to output in my blade:

Controller

SELECT CONCAT("Commences ", commencement_date) AS calculated_current_year ...

Template

{{ __($collection->calculated_current_year) }}

If I have the necessary translation setup (in this case, Portuguese: "Commences": "Início", in the translation file, my expected result/output would be:

Início 2022-09-06

but instead I get

Commences 2022-09-06

How can I translate the partial match?

SupaMonkey
  • 876
  • 2
  • 9
  • 25
  • You can use carbon translation for translate *date* – Aro Aug 24 '22 at 12:06
  • in which file your translation is? like there should be a file mile messages.php – Zia Aug 24 '22 at 12:06
  • To clarify, my translations are in ```/resources/lange/pt.json``` and work fine in all other instances. If I only try to translate the word "Commences" it works, but the moment that becomes "Commences " (trailing space) or "Commences 2022-09-26" (or whatever date) - it doesnt work. Need it to work with the date. – SupaMonkey Aug 24 '22 at 12:12
  • /lang/ ^typo above – SupaMonkey Aug 24 '22 at 12:18

0 Answers0