Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extractor having trouble with parameters in javascript #253

Open
monitz87 opened this issue Mar 10, 2017 · 2 comments
Open

Extractor having trouble with parameters in javascript #253

monitz87 opened this issue Mar 10, 2017 · 2 comments

Comments

@monitz87
Copy link

Hi,

I have a line like this in my javascript code:

mf('error_field_invalid', { field: 'phone' }, 'Invalid {field}')

I then use it again as such:

mf('error_field_invalid', { field: 'email' })

When I do, the meteor log throws the following error:

warn: [msgfmt:extracts] { error_field_invalid: "email" } in imports/ui/pages/accounts/profile.js:375 replaces DUP_KEY

And if I check the database, the mfString with key 'error_field_invalid' has 'email' as its 'text' attribute. I'm assuming that the regular expression tasked with parsing the javascript files is having trouble recognizing parameters.

Cheers

@monitz87
Copy link
Author

monitz87 commented May 2, 2017

Indeed, the regexp sees the string literal and assumes it's a text value instead of a parameter. My workaround was to assign the parameter object previously like so:

const fieldParam = { field: 'phone' };
mf('error_field_invalid', fieldParam, 'Invalid {field}');

@gadicc
Copy link
Owner

gadicc commented May 4, 2017

That's annoying :) Since this would be hard to fix in regexp, maybe this will help.

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.
    (Extractor having trouble with parameters in javascript #253).

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

No branches or pull requests

2 participants