Repository navigation
New plural unit decision functions - #132
Conversation
Removed zero-unit pluralization and added new unit functions with custom string support.
Removed zero-unit pluralization and added new unit functions with custom string support.
Removed zero-unit pluralization and added new unit functions with custom string support. Exaple usage in html:
<timer>{{ minutes }} {{ minuteUnit('minute','minutes') }} {{ seconds }} {{ secondUnit('second','seconds') }}
Removed zero-unit pluralization and added new unit functions with custom string support. Exaple usage in html:
<timer>{{ minutes }} {{ minuteUnit('minute','minutes') }} {{ seconds }} {{ secondUnit('second','seconds') }}
|
Can you all fix the build please? |
Added missing semicolons.
Added missing semicolons
Edited tests to match pull request
|
Sorry, I'm new to GitHub and versioning in general. Should be fixed now, added missing semicolons for JSHint and updated tests to reflect new zero-unit pluralization (although this should be looked into more, if we want user-selectable zero-pluralization). |
If no custom strings are given as inputs, returns default English units
If no custom strings are given as inputs, returns default English units
|
Added one more touch. Now you can just use {{ minuteUnit() }} if you want English units and it will return either 'minute' or 'minutes'. But you can also give the function two inputs for strings like {{ minuteUnit('minute','minutes' }} or {{ minuteUnit('minut','minutit' }}. |
New plural unit decision functions
|
Didn't spend too much time reviewing. I am trusting you guys :) Thanks for the PR 👍 |
|
Wow, cool, thanks! :) If you want I can help out with the samples as well, make changes to reflect the new unit selecting functions ( {{ minutes }} {{ minuteUnit() }} instead of {{ minutes }} minute{{ minutesS }} ) and add a sample for multilingual setup. |
|
@sanderaido - I appreciate this, please add samples for unit selecting & multilingual setup. |
|
I'm afraid that current implementation is insufficient, for example in Czech language, there are more forms than just two. It would be nice if we could join this somehow with ng-pluralize in order to use current locale. Does someone has any idea how to go about this? |
|
I work on the i18n of online alarm clock and MomentJS makes this really easy. More details : |
|
@polomarcus - Sounds good! Please send a PR. |
|
@siddii My PR is almost ready. Waiting for another PR to be accepted : EvanHahn/HumanizeDuration.js#40 I used MomentJS and HumanizeDuration to have a correct time display. We will have 17 languages (https://github.com/EvanHahn/HumanizeDuration.js#supported-languages) available using the language attribut with a directive. |
|
Awesome... Can you also add docs/sample code related this change? |
|
That's already done with a Spanish and french example, and also e2e tests :) |
Removed singular units from zero-units and added new unit functions with custom string support for multilingual support.
Example usage in HTML:
English:
{{ minutes }} {{ minuteUnit('minute','minutes') }} {{ seconds }} {{ secondUnit('second','seconds') }}
Estonian:
{{ minutes }} {{ minuteUnit('minut','minutit') }} {{ seconds }} {{ secondUnit('sekund','sekundit') }}