📖 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's AI SDK lets you build agents that maintain conversation context and use tools. This is perfect for multi-step…
2 min readDatabase comment fields are often filled with plain reference IDs that require manual copying and pasting into search bars or…
2 min readYour queue job hits a rate limit. You need exponential backoff. But which formula? Here are two real patterns I've…
2 min read
Leave a Reply