2

I cannot localize a string to present a javascript alert to the user. @Localizer works in my views outside of javascript in HTML: @Localizer["messageToLocalize"];

Here is my code block inside tags:

The commented-out line returns this javascript error in Chrome Developer Tools:

Uncaught SyntaxError: missing ) after argument list

But of course outside of a javascript block it works: @Localizer["Please select a Provider"]

How can I localize the string I want to return to the user?

if (providerIndex < 1) {
//alert(@Localizer["Please select a Provider"]);
alert("Please select a Provider");
return
}

1 Answer 1

5

I figured it out, perhaps this will help someone else. All I had to do is put the entire Localizer text in single quotes:

Instead of: alert(@Localizer["Please select a Provider"]);

Do it this way: alert('@Localizer["Please select a Provider"]');

This works as expected.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.