3 ms·
You have 1 new message(s)
Can someone explain to me why it's so common to see this, yet so simple to remedy?
$plural = $count > 1 ? "s" : "";
$subject = "You have " . $count . " new message" . $plural;
- slater 6y agoLaziness or indifference.
- lucozade 6y agoAs long as your site only works for English and is only intended to work for English this is fine. If it needs to work for other languages too, even common ones, then this isn't fine. Getting plurals to work correctly for multiple languages is hard so an alternative (that often works well) is to have locale specific strings with holes in them.
- onion2k 6y agoAs with most things in development, it looks trivial. In an MVP it is trivial (as your code demonstrates). Now try it in an internationalized app. It's a matter of handling up to 6 plural forms (http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html#f1 http://docs.translatehouse.org/projects/localization-guide/e... - see Arabic). That's a lot more effort than just having 1 translated line of text for "messages".
- escapedconvict 6y agoDespite internationalization, I still see this as a trivial issue. Just use a map: const plurals = {'en': { 'message': 'messages' }, 'de': { 'Nachricht': 'Nachrichten' }; You can add grammatical cases to the map to handle different plural forms. It's not like you'll need a big list/map since you're likely to use it in only a few places.
- emptyparadise 6y agoPoor internationalization support.