📖 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
When agent() calls become complex with large schemas, extract them into dedicated Agent classes. This improves readability, enables reuse, and…
2 min readYou implement ShouldQueue on your event listener, add a catch block for rate limit exceptions, and write $this->release(60) to retry…
2 min readImagine you're building a social platform where users can like posts. You want to send notifications when a post hits…
3 min read
Leave a Reply