grunt-angular-translate icon indicating copy to clipboard operation
grunt-angular-translate copied to clipboard

Handle Variable Replacement with $translate Service

Open rgant opened this issue 9 years ago • 0 comments

I have the following call to $translate in my app that isn't picked up by grunt-angular-translate:

$translate(['LOGIN.RECOVERY.FORM.MESSAGES.SUCCESS',
            'LOGIN.CREATE_NEW_PASSWORD.FORM.BUTTONS.CONFIRM'], {email: vm.email})

This is because the RegEx for matching these calls looks for a closing parenthesis immediately after the first parameter in the function call. But when using variable replacement feature you include a second parameter.

I suggest changing the final character in the RegExs to look for either a closing parenthesis or a comma.

From:

JavascriptServiceArraySimpleQuote: '\\$translate\\((?:\\s*(\\[\\s*(?:(?:\'(?:(?:\\.|[^.*\'\\\\])*)\')\\s*,*\\s*)+\\s*\\])\\s*)\\)',

To:

JavascriptServiceArraySimpleQuote: '\\$translate\\((?:\\s*(\\[\\s*(?:(?:\'(?:(?:\\.|[^.*\'\\\\])*)\')\\s*,*\\s*)+\\s*\\])\\s*)[,)]',

This would apply to all of the $translate patterns. If I have time later I will work up a pull request for this fix.

rgant avatar Sep 07 '16 19:09 rgant