Skip to content
This repository was archived by the owner on Jun 23, 2026. It is now read-only.

New plural unit decision functions - #132

Merged
siddii merged 9 commits into
siddii:masterfrom
sanderai:master
Dec 2, 2014
Merged

siddii merged 9 commits into
siddii:masterfrom
sanderai:master

Conversation

@sanderai

@sanderai sanderai commented Dec 2, 2014

Copy link
Copy Markdown
Contributor

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') }}

sanderaido added 4 commits December 2, 2014 13:32
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') }}
@siddii

siddii commented Dec 2, 2014

Copy link
Copy Markdown
Owner

Can you all fix the build please?

sanderaido added 3 commits December 2, 2014 15:02
Added missing semicolons.
Added missing semicolons
Edited tests to match pull request
@sanderai

sanderai commented Dec 2, 2014

Copy link
Copy Markdown
Contributor Author

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).

sanderaido added 2 commits December 2, 2014 15:34
If no custom strings are given as inputs, returns default English units
If no custom strings are given as inputs, returns default English units
@sanderai

sanderai commented Dec 2, 2014

Copy link
Copy Markdown
Contributor Author

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' }}.

siddii added a commit that referenced this pull request Dec 2, 2014
New plural unit decision functions
@siddii
siddii merged commit c138086 into siddii:master Dec 2, 2014
@siddii

siddii commented Dec 2, 2014

Copy link
Copy Markdown
Owner

Didn't spend too much time reviewing. I am trusting you guys :)

Thanks for the PR 👍

@sanderai

sanderai commented Dec 2, 2014

Copy link
Copy Markdown
Contributor Author

Wow, cool, thanks! :)
I didn't know about the best practices when it comes to completely redefining functions like this, so I left the old code in there (with the zero-plural fix) just in case. Actually it is not needed anymore and could be removed in the next version (1.2, so it's quite suitable hehe).
I like the idea of @polomarcus to add a parameter to select if zero should be plural or singular. Maybe as a parameter for the directive?

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.

@siddii

siddii commented Dec 2, 2014

Copy link
Copy Markdown
Owner

@sanderaido - I appreciate this, please add samples for unit selecting & multilingual setup.

@xaralis

xaralis commented Jan 16, 2015

Copy link
Copy Markdown

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?

@polomarcus

Copy link
Copy Markdown
Collaborator

I work on the i18n of online alarm clock and MomentJS makes this really easy.
What do you think if we use MomentJS @siddii ? I could make a PR quite soon

More details :
http://momentjs.com/docs/#/i18n/

@siddii

siddii commented Feb 13, 2015

Copy link
Copy Markdown
Owner

@polomarcus - Sounds good! Please send a PR.

@polomarcus

Copy link
Copy Markdown
Collaborator

@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.

@siddii

siddii commented Feb 17, 2015

Copy link
Copy Markdown
Owner

Awesome... Can you also add docs/sample code related this change?

@polomarcus

Copy link
Copy Markdown
Collaborator

That's already done with a Spanish and french example, and also e2e tests :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants