JavaScript/JQuery – How to retrieve resources translations in JS

In your JS code write you can write the following literal declaration into a JS variable.

var data = “<asp:Literal runat=”server” Text=”<%$Resources:myresourcefile,resourcetitle%>” />”;

Then you can use the value in the data variable to lets say hide something in your page based on a translation. In the following example I hid a certain breadcrumb information based on different languages.

$(“#breadcrumb ul li a:contains(” + code + “)”).hide();

Advertisements

One thought on “JavaScript/JQuery – How to retrieve resources translations in JS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s