zerospam / laravel-gettext

Adds localization support to laravel applications using PoEdit and GNU-Gettext.
99 stars 56 forks source link

Passing 0 or empty string for %d and %s does not work as expected #31

Closed smares closed 3 years ago

smares commented 5 years ago

Given the following call:

_i('Hello %sWorld%s', '<strong>', '</strong>');

The returned string is correctly: Hello <strong>World</strong>.

However, given the following call:

_i('Hello %sWorld%s', '', '');

I would expect the returned string to be Hello World but in fact it's Hello %sWorld%s.

This seems to be caused by the if (!empty($args)) { line in Support/helpers.php because the string is empty. Instead of empty(), the check should be against null.

smares commented 4 years ago

Update:

Something like this also doesn't work: _i('You have %d contacts in your list.', 0) because the number 0 is treated as empty.