angular-gettext
angular-gettext copied to clipboard
plural translate returns when translate-n is zero
for this example
<translate translate-n="model.userInfo.view_count | number" translate-plural="{{$count}} views">{{$count}} view</translate>
when $count
is 0 it returns plural text
That is correct behavior in English.
What were you expecting to happen here?
Well, because of that could change according to different languages, we might want to show user different texts. For example I want to show our users when view count is zero: "No views here" and when it's one: "One post" and if more than 1, "$count posts". I think availability of setting this behaviour should be done by using a new attribute translate-zero
or something else, instead of using if/else condition inside singularstr
Well, because of that could change according to different languages
The formula used changes based on the language passed to setCurrentLanguage
. See https://github.com/rubenv/angular-gettext/blob/master/src/plural.js
You need to specify an ISO language code such as tr
or nl_BE
.
I would also like this feature. Angular's ngPluralize supports it, as does their new MessageFormat support, as does with MessageFormat. It may be outside the scope of an angular-gettext lib since technically it would still be correct grammar in English to say something like "0 apples". But it's usually more for friendly messaging since 0 can be so empty. "0 comments" vs "No comments yet. Add your voice!" Currently you have to have separate translation labels/logic to manage it.
@hworld You'll have to go with that then. It was a conscious decision not to support this to keep things simple. There are other choices available when you want all the options, angular-gettext is, by design, simple.