๐ 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 duplicating complex UI validation or calculation logic on the backend, treat the frontend component as the source of truth….
1 min readHere's a scenario every Laravel developer hits eventually: your queue job integrates with a third-party API, and that API starts…
3 min readExternal API calls are expensiveโin money, time, and rate limits. Whether you're hitting a weather service, geocoding API, or AI…
3 min read
Leave a Reply