Improve localization interface #1

Closed
mckamey opened this Issue Mar 14, 2015 · 1 comment

Projects

None yet

1 participant

@mckamey
Owner
mckamey commented Mar 14, 2015

Issue migrated from Bitbucket...

Currently the localization interface is a bunch of parameters on setLabels(...) and a parameterless resetLabels(). That whole method is getting a bit long and convoluted as it organically grew without much forethought.

This task is to clean it up by creating a new method accepting a general Format object which contains all those features. It will make it easier than remembering how many nulls to put before the value you actually want to set.

The current method looks like:

  countdown.setLabels(singular, plural, last, delim, empty, formatter);

Something like this would allow setting just the things to override:

countdown.setFormat({
    singular: ' millisecond| second| minute| hour| day| week| month| year| decade| century| millennium'
    plural: ' milliseconds| seconds| minutes| hours| days| weeks| months| years| decades| centuries| millennia',
    last: ' and ',
    delim: ', ',
    empty: ' ',
    formatter: function(n){ return n.String(); }
});

It's nice and compact to allow those label lists to be simple pipe ('|') delimited strings, but it should also accept an array of strings.

countdown.setFormat({
    singular: [' millisecond', ' second', ' minute', ' hour', ' day',
        ' week', ' month', ' year', ' decade', ' century', ' millennium']
    plural: [' milliseconds', ' seconds', ' minutes', ' hours', ' days',
        ' weeks', ' months', ' years', ' decades', ' centuries', ' millennia']
});
@mckamey mckamey added the enhancement label Mar 14, 2015
@mckamey mckamey self-assigned this Mar 15, 2015
@mckamey mckamey added a commit that closed this issue Jul 11, 2015
@mckamey Improving localization interface for more customization. Fixes #1, #7.
Changing from a parameter list to a format object. This makes it easier when only changing a few settings.
Adding a formatter function option which enables custom formatting for more complex plurality rules.
472b65e
@mckamey mckamey closed this in 472b65e Jul 11, 2015
@mckamey
Owner
mckamey commented Jul 11, 2015

TODO: update docs.

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