📖 1 minute read
When defining translation strings in Laravel, always use named placeholders (like :count or :percent) instead of positional ones or manual string concatenation.
// Bad
__('You have ' . $count . ' notifications');
// Good
__('You have :count notifications', ['count' => $count]);
Different languages have varying word orders; named placeholders allow translators to move variables within the sentence without breaking the logic or requiring code changes for each locale.
Daryle De Silva
VP of Technology
11+ years building and scaling web applications. Writing about what I learn in the trenches.
Related Articles
Laravel 12 removed routes/api.php from the default skeleton to keep new projects lean. When you're ready to build APIs, here's…
2 min readThe Question How do you enable Laravel AI's provider tools (like WebSearch, WebFetch, or FileSearch) when using the agent() helper?…
2 min readStop sending test emails or checking mail catches every time you tweak an email design. Create test routes that render…
2 min read
Leave a Reply