Skip to content

Commit

Permalink
[email protected]: allow mf(key, text, params) ordering (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
gadicc committed May 4, 2017
1 parent db765a1 commit 93accd1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
10 changes: 10 additions & 0 deletions packages/core/History.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
## vNEXT

## v2.0.0-preview.24 (2017-05-04)

### Added

* Allow `mf('key', 'text', params)` in addition to the regular
`mf('key', params, 'text')` Previously, `mf('key', 'text')` was accepted
too, but there was no way to provide `params` in this ordering. Now if
the second argument is a String, the second and third arguments are swapped.
(#253).

## v2.0.0-preview.23 (2016-09-05)

### Changed
Expand Down
9 changes: 6 additions & 3 deletions packages/core/lib/msgfmt.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ msgfmt.addFormat('number', { ZAR: { style: 'currency', currency: 'ZAR' } });
msgfmt.addCurrencyShortcut('ILS');

mf = function mfcall(key, params, message, locale) {
var tmp;

if (!locale) {
if (Meteor.isClient) {
locale = Session.get('locale');
Expand All @@ -176,12 +178,13 @@ mf = function mfcall(key, params, message, locale) {
}

}
}
}
if (!locale || (!mfPkg.strings[locale] && !mfPkg.compiled[locale]))
locale = mfPkg.native;
if (_.isString(params)) {
tmp = message;
message = params;
params = null;
params = tmp;
}

var mf = mfPkg.objects[locale];
Expand Down Expand Up @@ -226,7 +229,7 @@ mf = function mfcall(key, params, message, locale) {
// Give up
}
}

return formatted;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
name: "msgfmt:core",
version: "2.0.0-preview.23",
version: "2.0.0-preview.24",
summary: "MessageFormat i18n support, the Meteor way",
git: "https://github.com/gadicc/meteor-messageformat.git",
documentation: 'README.md'
Expand Down

0 comments on commit 93accd1

Please sign in to comment.