0

i have use the following string as value of the button

"Drag a column header here to group its column" with culture as en-US

how to change this string based on the different language settings/ culture .Is there any other way to achieve this by using Globalize.format to convert

Chris Salzberg
  • 27,099
  • 4
  • 75
  • 82
Raja
  • 209
  • 1
  • 7
  • 16
  • You can user jquery i18n. I think there is a lots of library available in the net. You can use anyone or you can make your own in javascript. – Md. Yusuf Feb 24 '14 at 05:24

1 Answers1

0

You could set the localized instructions in an object like so:

var instructions = {
  "en" : "Drag a column header here to group its column",
  "fr" : "Faites glisser un en-tête de colonne ici pour groupe sa colonne",
  "cn" : "这里将一个列标题,集团将其列"
}

And assuming your button has an id of "#example_button", you could have a jQuery function like this :

function set_button_instruction_value(text) {
  $("#example_button").prop('value', text);
}

So if you saved your localization to a variable, such as "locale":

var locale = "en";

You can call this to change the value of the button:

set_button_instruction_value(instructions[locale]);

I don't think Globalize.format can directly determine how to set the button text unless you wanted to set a locale based on the way a date is displayed.

Jaron Gao
  • 466
  • 3
  • 9
  • Hi ,thank you for your answer . is it possible to use resx files to localize the string in javascript – Raja Feb 24 '14 at 06:10
  • is it possible to localize the string in javascript using toLocaleString() method – Raja Feb 24 '14 at 07:27
  • I'm not familiar with resx, but this question is similar to what you're asking for. The first answer is also similar to mine: http://stackoverflow.com/questions/104022/localize-strings-in-javascript?rq=1 – Jaron Gao Feb 24 '14 at 13:28
  • Also, toLocaleString() appears to also be a method for converting dates. It seems to me that you're confusing converting instruction strings with date strings. For example, Globalize.format and toLocaleString() methods are used with dates only, as far as I can tell. I can't think off the top of my head any JavaScript libraries that can parse and convert different languages, but I'm sure they exist. – Jaron Gao Feb 24 '14 at 13:32