📖 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
A user reports "the status field isn't saving." You need to find where that field is stored in the database….
2 min readEver get a bug report that sounds impossible? "I filtered by SGD, but I'm still seeing USD records in the…
3 min readThis one has bitten me and probably every Laravel developer at least once. You're combining two collections and items silently…
2 min read
Leave a Reply