Skip to content

Commit

Permalink
Merge branch 'patch-1' of https://github.com/AdamWillden/i18n into Ad…
Browse files Browse the repository at this point in the history
…amWillden-patch-1
  • Loading branch information
zewa666 committed Jul 22, 2016
2 parents b6ffedb + 168f556 commit 1937202
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/nf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,21 @@ export class NfValueConverter {
this.service = i18n;
}

toView(value, formatOptions, locale, numberFormat) {
let nf = numberFormat || this.service.nf(formatOptions, locale || this.service.getLocale());
toView(value, nfOrOptions, locale, nf) {
if (value === null
|| typeof value === 'undefined'
|| (typeof value === 'string' && value.trim() === '')
) {
return value;
}

if (nfOrOptions && (typeof nfOrOptions.format === 'function')) {
return nfOrOptions.format(value);
} else if (nf) {
console.warn('This ValueConverter signature is depcrecated and will be removed in future releases. Please use the signature [nfOrOptions, locale]'); // eslint-disable-line no-console
} else {
nf = this.service.nf(nfOrOptions, locale || this.service.getLocale());
}

return nf.format(value);
}
Expand Down

0 comments on commit 1937202

Please sign in to comment.